Subject: Re: tracking program counter / assembling objdump output
To: None <>
From: None <>
List: port-m68k
Date: 10/12/2006 06:50:44
In a message dated 10/12/2006 2:45:34 A.M. Eastern Standard Time, writes:
Because it isn't possible.
The disassembler cannot  know whether constants should be absolute numbers,
diffences between  addresses, or addresses themselves.  So when you
reassemmble the output  you'll end up with incorrect code.
Thanks David.  I followed agrier's suggestion last night to ask the  binutils 
mailing list and got a similar response.  I still think it would  be neat to 
make a converter from objdump output to gcc-assemblable source and  have it 
ask for human help when needed, but the more I think about - not neat  enough to 
actually go through the work of doing it.
> It  appears that the objdump output is quite similar to, but  deliberately 
> different  from, the assembly created from compiling  a c program with "gcc 
> Is  there a mechanism to  convert the objdump disassembly output to an 
> assemblable   form?
Apart from doing this by hand, no.
> Or is that a deliberate objdump decision to have the output   
> different, as my desire is inherently unworkable,
It was a deliberate decision but the motive was to make disassembler's  
output be useful to people who want to examine the contents of a binary  
file, not to allow re-assembly.  To this end, more information is  
presented to the user than is needed to just re-assemble the  
disassembled output.
> as modifying the disassembly  
> would change all the  branch offsets and cause everything to break?
No, the real problem is coping with relocations.  The disassembled  
output of a file is not just the textual disassembly, but also the  
relocations that are associated with that disassembly.  You would need  
some way to re-install those relocations back into the assembler source,  
possibly regenerating local labels as you go.  A difficult task.