2

How can I see the disassembled version of the executable (eg. a.out) of a C++ program on Mac OSx?

Brett Hale
  • 21,653
  • 2
  • 61
  • 90
Nemo
  • 4,601
  • 11
  • 43
  • 46

2 Answers2

4

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

Community
  • 1
  • 1
Tony Delroy
  • 102,968
  • 15
  • 177
  • 252
3

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.

Community
  • 1
  • 1
Brett Hale
  • 21,653
  • 2
  • 61
  • 90