Is the disassembled code in att syntax guaranteed to generate the same machine code?

Peng Yu pengyu.ut@gmail.com
Thu Apr 29 01:33:29 GMT 2021


On 4/28/21, Christian Groessler <chris@groessler.org> wrote:
> On 4/28/21 4:26 PM, Peng Yu via Binutils wrote:
>>
>> It is a fair expectation that the disassembled code can generate
>> exactly the same machine code from which the disassembled code is
>> derived from.
>
>
> No. It is not. It's a "nice to have", but in reality not the case for
> many targets.

The question is what is not possible.

I consider, for cases like "nop eax" the intel manual clearly stated
"don't care", it is not possible to recover from the original machine
code. However, for the case of nop with different lengths, there is no
reason to confuse an n-byte nop instruction with a m-byte nop
instruction where n != m. After all, they may run for different
numbers of CPU cycles, why would you consider instructions with
different runtime to be the same instruction? It doesn't make much
sense. I'd rather a disassembler shows users the difference rather
than hiding such info from the users.

For those cases that are possible, the disassembler should do a better
job to faithfully represent what is in the machine code. The current
version of `objdump -d` clearly does not do as much as it could do to
faithfully disassemble the machine code.

-- 
Regards,
Peng


More information about the Binutils mailing list