问题
Yesterday, I got caught a problem on re-asselembling the disassembly.
My experiment was like below. :
1. Disassemble binary_A into A.s
2. Re-assemble A.s into binary_A'
I expected binary_A
and binary_A'
to be completely identical.
However, it wasn't !
1. disassembly of binary_A
was :
53 # push %ebx
83 ec 08 # sub $0x8,%esp
81 c3 4b 1d 00 00 # add $0x1d4b,%ebx
8b 83 fc ff ff ff # mov -0x4(%ebx),%eax <= Here
85 c0 # test %eax,%eax
2. I parsed it and made A.s
file:
push %ebx
sub $0x8,%esp
add $0x1d4b,%ebx
mov -0x4(%ebx),%eax
test %eax,%eax
3. finally I re-assembled it into binary_A'
(Look carefully at the arrow):
53 # push %ebx
83 ec 08 # sub $0x8,%esp
81 c3 4b 1d 00 00 # add $0x1d4b,%ebx
8b 43 fc # mov -0x4(%ebx),%eax <= Here!
85 c0 # test %eax,%eax
Here is my problem :
I want binary_A
and binary_A'
to be completely identical.
However, it wasn't because mov eax, DWORD PTR [ebx - 0x4]
is assembled in a different way.
Question :
Can I direct assembler to use specific encoding?
(using assembler directive or sth like that?)
来源:https://stackoverflow.com/questions/51491342/how-to-enforce-the-assembler-to-emit-code-using-using-specific-encoding