Alex Rivera | Logout

How can I view assembly code produced for C functions?

Asked 2013-04-26T17:10:16.357
12

I need to view the assembly code produced for certain C functions.

What flags should I use when compiling the C code using the g++ compiler?

Edit
Report

1 Answer

3

With gcc or g++ compiler, you can use the -S flag to see the assembly code generated.

GNU C Compiler Documentation

-S: Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified.

By default, the assembler file name for a source file is made by replacing the suffix .c, .i, etc., with .s.

Input files that don't require compilation are ignored.

Then you have to look for the identifier of your function in the file (if the compiler has not inlined it).

answered 2013-04-26T17:11:07.163

Your Answer