Copy the C source code

Is there anyway using a C compiler like GCC or clang to generate an assembly that has C code displayed in the build output (so that you can see which build block is represented in the C code) on a Linux system? I am trying to figure out what the output is of a piece of C code with O3 enabled, but I am having a hard time as I am lacking in assembly knowledge.

+3


source to share


1 answer


Use the -S

c parameter gcc

to generate an output assembly file.

gcc -S file.c

EDIT:



If you want to view output assembly

and code C

side by side, use gdb -tui a.out

:

Splitting layout

(gdb)

The split layout command divides the window into two parts: one that displays the source code and the other displays the corresponding assembly.

0


source







All Articles