How can I see the assembly code for a C++ program?
What are the popular tools to do this?
If you are building the program yourself, you can ask your compiler to emit assembly source. For most UNIX compilers use the -S switch.
-S
If you are using the GNU assembler, compiling with -g -Wa,-alh will give intermixed source and assembly on stdout (-Wa asks compiler driver to pass options to assembler, -al turns on assembly listing, and -ah adds "high-level source" listing):
-g -Wa,-alh
-Wa
-al
-ah
g++ -g -c -Wa,-alh foo.cc
For Visual Studio, use /FAsc.
/FAsc
If you have compiled binary,
objdump -d a.out
dumpbin /DISASM foo.exe
Debuggers could also show disassebly.
disas
set disassembly-flavor intel
1.4m articles
1.4m replys
5 comments
57.0k users