94

How can I tell objdump to emit assembly in Intel Syntax rather than the default AT&T syntax?

Rafał Dowgird
  • 43,216
  • 11
  • 77
  • 90
pythonic
  • 20,589
  • 43
  • 136
  • 219

2 Answers2

148

What you're looking for is -M intel. Use it as follows.

objdump -M intel -d program_name
pythonic
  • 20,589
  • 43
  • 136
  • 219
Daniel Kamil Kozar
  • 18,476
  • 5
  • 50
  • 64
  • 24
    On OS X, it turns out that /usr/bin/objdump may not actually be objdump at all, but actually llvm-objdump. You can use objdump --help, but it actually doesn't tell you about the option that gives you intel-style output, which appears to be `-x86-asm-syntax=intel` . Sigh. – John Clements Mar 28 '19 at 22:51
  • 3
    Is there an easy way how to make `objdump` use the option `-M intel` as a **permanent default**? – vitsoft May 14 '20 at 16:01
  • 1
    @vitsoft Not really, it seems like `objdump` doesn't support passing "default" parameters via an environment variable or a `rc` file. The best way to go seems to be creating a function in your shell, like `objdump() { /usr/bin/objdump -M intel "$@" }` in Bash. This has its own set of issues, of course, for example I have no idea if `objdump` isn't going to complain about `-M intel` if you're not actually disassembling something. – Daniel Kamil Kozar Dec 02 '20 at 10:07
  • 1
    @JohnClements as of https://reviews.llvm.org/rGe510860656bb81bd90ae3cf8bb5ef4dc8cd33c18 , llvm-objdump understands `-Mintel` like you'd expect. This will be in LLVM 13. – thakis May 14 '21 at 14:15
12

If you want Intel mnemonic codes as well (instead of AT&T mnemonic codes), you can use:

objdump -M intel intel-mnemonic -D <program's-object-file>

shigoel
  • 447
  • 4
  • 11
  • 3
    Actually, `-M intel` already takes care of that. Try disassembling the sequence `0f b7 c3` - with `-M intel` this will give you `movzx eax,bx`, while without it objdump reverts to AT&T by default and you get `movzwl %bx,%eax`. – Daniel Kamil Kozar Apr 29 '12 at 15:07
  • 1
    Oh right. I overlooked that completely in the interest of being more explicit. Thanks! – shigoel Apr 29 '12 at 18:44
  • 7
    From reading the manual, `-M intel-mnemonic` _implies_ `intel`, not the other way around. I still don't know the differences between the two though. I did `objdump -M intel -d file > intel`, `objdump -M intel-mnemonic -d file > intel-mnemonic`, then `diff intel intel-mnemonic` and there were no differences. I even tried with `-D` instead of `-d` just in case there would be differences in the other sections. – RastaJedi Aug 03 '16 at 06:33