I usually write my code on Windows, and there are two different types of development environments, each providing their own tools to view the assembly code of an object file(*.obj
) or executable (*.exe
).
If I am working with Visual Studio build system from command line, the dumpbin /disasm file.obj
command can generate disassemble a binary file. A snippet of a disassembly from an executable, produced by dumpbin
:
000000014000E712: 41 81 F0 6E 74 65 xor r8d,6C65746Eh
6C
000000014000E719: 41 81 F1 47 65 6E xor r9d,756E6547h
75
000000014000E720: 44 8B D2 mov r10d,edx
000000014000E723: 8B F0 mov esi,eax
000000014000E725: 33 C9 xor ecx,ecx
000000014000E727: 41 8D 43 01 lea eax,[r11+1]
000000014000E72B: 45 0B C8 or r9d,r8d
000000014000E72E: 0F A2 cpuid
000000014000E730: 41 81 F2 69 6E 65 xor r10d,49656E69h
49
000000014000E737: 89 04 24 mov dword ptr [rsp],eax
However, if I am working with the GNU toolkit (I mean mingw64, which works with native windows binaries), then running objdump -D file.obj
gives a disassembly like this:
14000e712: 41 81 f0 6e 74 65 6c xor $0x6c65746e,%r8d
14000e719: 41 81 f1 47 65 6e 75 xor $0x756e6547,%r9d
14000e720: 44 8b d2 mov %edx,%r10d
14000e723: 8b f0 mov %eax,%esi
14000e725: 33 c9 xor %ecx,%ecx
14000e727: 41 8d 43 01 lea 0x1(%r11),%eax
14000e72b: 45 0b c8 or %r8d,%r9d
14000e72e: 0f a2 cpuid
14000e730: 41 81 f2 69 6e 65 49 xor $0x49656e69,%r10d
14000e737: 89 04 24 mov %eax,(%rsp)
Now, it is immediately clear that both are providing the same information. However, I want to know what the numbers on the left column mean (e.g. 14000e712
)? Also why is the instruction written differently (e.g. on the first line, dumpbin
writes r8d,6C65746Eh
, while objdump
writes $0x6c65746e,%r8d
). Why is this, and what do the different representations mean? Additionally dumpbin seems to write extra information such as dword ptr
that objdump
doesn't write.
dumpbin
is using what is known as Intel (dis)assembly syntax.By default, objdump
, being a GNU utility is using what is known as AT&T (dis)assembly syntax. If you wantobjdump
to display output in Intel syntax, add-Mintel
to yourobjdump
command line.