質問

I wrote a small piece of code and compiled it with gcc -S to see the ASM output:

...
movl    %esp, %ebp
.cfi_def_cfa_register 5
subl    $16, %esp
movl    $0, -4(%ebp)
...

Now I expect that on Linux a call to objdump -D (disassemble) lead to an equivalent structure but it looks like:

80483b5:   89 e5                   mov    %esp,%ebp
80483b7:   83 ec 10                sub    $0x10,%esp
80483ba:   c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%ebp)

Why do I get mov / sub instead of movl /subl?

役に立ちましたか?

解決

The outputs are equivalent. The b/l/etc. prepended to the end of instructions is simply a way of telling the reader the size of the data being manipulated. The underlying x86 architecture makes no such internal distinguishment since the sizes can be inferred from the operands. The sizes are an AT&T syntax 'idiom'/sugar which seems to have not been used consistently across the gcc toolchain and objdump from binutils.

他のヒント

Also, the output from gcc -S is unlinked and hence is not an executable while that from objdump.exe has been linked.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top