Disassemble into x86_64 on OSX10.6 (But with _Intel_ Syntax)

后端 未结 5 1921
庸人自扰
庸人自扰 2021-02-08 18:58

I know of otool -tv, but I would much rather use the Intel syntax rather than AT&Ts, mainly to easily follow along in a book and not have to look over

相关标签:
5条回答
  • 2021-02-08 19:04

    For GDB, in your .gdbinit file, add:

    set disassembly-flavor intel

    then it will be the default syntax for gdb.

    0 讨论(0)
  • 2021-02-08 19:06

    You can use A2I to translate from AT&T to Intel syntax: http://membres.lycos.fr/placr/a2i.html

    0 讨论(0)
  • 2021-02-08 19:13

    With Objdump you can disassemble with -d -M intel, and apparently -m can be used to specify the architecture.

    0 讨论(0)
  • 2021-02-08 19:22

    (I know this is an old question, but I want to provide an updated answer for people who come here through search engines).

    On recent versions of macOS (I'm running 10.14.5), an objdump command is available, which is based on LLVM and is not the one from the GNU project. It offers a (hidden) option to disassemble using Intel syntax. For example, /bin/echo can be disassembled as follows:

    objdump -disassemble -x86-asm-syntax=intel /bin/echo
    
    0 讨论(0)
  • 2021-02-08 19:25

    To answer your second question, if the code has been compiled into a fat binary with both 64-bit and 32-bit, you can use otool -arch i386 -tv to disassemble the 32-bit slice of the binary; otool -arch x86_64 -tv will give you the 64-bit portion (on SnowLeopard, this is also the default behavior if no -arch flag is passed).

    Also note that while otool doesn't support the Intel syntax, gdb (set disassembly-flavor intel) and XCode (Preferences -> Debugging -> Disassembly Style) do.

    0 讨论(0)
提交回复
热议问题