The disassembly for call and jmp looks like this: 43a: 0e 94 7e 0e call 0x1cfc <__divmodhi4> This causes problems since the "<identifier>" part is not correct assembler syntax. It should read like this: 43a: 0e 94 7e 0e call 0x1cfc ; <__divmodhi4> The following patch solves the problem for me: diff -ubr binutils-2.16/opcodes/avr-dis.c binutils-2.16-patched/opcodes/avr-dis. --- binutils-2.16/opcodes/avr-dis.c Thu Mar 3 12:49:47 2005 +++ binutils-2.16-patched/opcodes/avr-dis.c Mon Mar 13 15:54:06 2006 @@ -142,7 +142,8 @@ case 'h': *sym = 1; *sym_addr = ((((insn & 1) | ((insn & 0x1f0) >> 3)) << 16) | insn2) * 2; - sprintf (buf, "0x"); + sprintf (buf, "0x%x", *sym_addr); + sprintf (comment, "0x"); break; case 'L': -----
This patch suggests that you are trying to make the disassembler's output suitable for input back into the assembler, correct? This is not normally something that the disassembler strives for. What are you trying to do?
Why not strive for it if it can be done easily? I use avrora (http://compilers.cs.ucla.edu/avrora/) to simulate the AVR program before writing it onto the real device. This simulator reads the input from objdump and expects correct syntax. The call/jmp mnemonics are the only ones which cause it to stumble.
Subject: Re: New: incorrect syntax in avr disassembly Hi hochstein, > The disassembly for call and jmp looks like this: > > 43a: 0e 94 7e 0e call 0x1cfc <__divmodhi4> > > This causes problems since the "<identifier>" part is not correct assembler > syntax. It should read like this: > > 43a: 0e 94 7e 0e call 0x1cfc ; <__divmodhi4> > Do you have a *small* test case to reproduce this behaviour ? Also - have you tried the current sources in the mainline binutils CVS repository ? I think that they may already have the desired behaviour. Cheers Nick
Here comes the test case: call __divmodhi4 .org 0x1cfc __divmodhi4: nop I compile the above program $ avr-as -I/usr/include/avr -mmcu=atmega32 -o call-test.o call-test.asm $ avr-gcc -mmcu=atmega32 -nostdlib -o call-test call-test.o and then dump it $ avr-objdump -zD call-test The output is 0: 0e 94 7e 0e call 0x1cfc <__divmodhi4> ... I also tried the sources from CVS but they do not resolve the problem.
Thank you. I am now able to reproduce the bug and I have approved your patch. it does not quite perform as you say, since the hexadecimal form of the address is displayed twice: 0: 0e 94 7e 0e call 0x1cfc ; 0x1cfc <__divmodhi4> But this is not too big of a problem, and fixing it would mean altering the generic sources in objdump.c. I have checked your patch in alogn with this ChangeLog entry. Cheers Nick opcodes/ChangeLog 2006-04-12 Hochstein <hochstein@algo.informatik.tu-darmstadt.de> PR binutils/2454 * avr-dis.c (avr_operand): Arrange for a comment to appear before the symolic form of an address, so that the output of objdump -d can be reassembled.