问题
How can I see the disassembled version of the executable (eg. a.out) of a C++ program on Mac OSx?
回答1:
It's not exactly what you're asking for, but g++ -S produces assembly from source code and can be expected to be more readable than a disassembled version.
If you can't recompile with -S (e.g. no source code), then gdb lets you disassemble, as does objdump --disassemble. Depends what you've installed.
See also: https://superuser.com/questions/206547/how-can-i-install-objdump-on-mac-os-x
回答2:
Look at otool. i.e., otool -tv a.out
Edit: To add to Tony's answer, objdump also has name demangling for C++, i.e.,
objdump -tC a.out (IIRC)
I gave a previous answer on how to build and install the binutils for darwin.
来源:https://stackoverflow.com/questions/9510074/disassemble-the-executable-created-by-g-in-mac-osx