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.


source to share

1 answer

Use the -S

c parameter gcc

to generate an output assembly file.

gcc -S file.c


If you want to view output assembly

and code C

side by side, use gdb -tui a.out


Splitting layout


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



All Articles