Disassemble the executable created by g++ in mac osx

吃可爱长大的小学妹 提交于 2019-12-12 10:09:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!