Note that function definition lines from C++ do not appear though, but I can usually identify them by looking at their mangled label name. This makes it easy to identify which assembly code lines correspond to every C++ source line. First, every statement of the C++ code appears in the assembly code. This option adds two types of extra commentary.
To get assembly code with annotations of the C++ source code: $ gcc -S -fverbose-asm foobar.cpp The assembly code generated by the above -S option does not have any annotations indicating which lines of the C++ code correspond to which assembly instructions. To generate assembly code in Intel syntax: $ g++ -S -masm=intel foobar.cpp For x86 and 圆4 assembly code, the AT&T syntax is used by default. This writes the assembly code to a foobar.s file. To generate assembly code: $ g++ -S foobar.cpp
To generate assembly code we essentially request GCC to stop before the assembly stage of compilation and dump what it has generated from the compiler backend. I find it useful to generate assembly code to understand what the compiler is doing to my C++ code. For example, this command generates an a.out executable: $ g++ foobar.cpp When we use GCC to compile C or C++ code, it directly generates the final object or executable file. 📅 2019-Dec-30 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ assembly, gcc ⬩ 📚 Archive