How do I compile to assembly instead of an executable with gcc. I know there is an -S flag, but where do I use it in the makefile. For example, if I use flags -O3 -o exe_name, where should I put the -S flag?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
I suggest also using
-fverbose-asm
because then the generated assembler has some generated comments which "explains" the code. For example:would generate in
foo.s
(with some comments) the assembler code produced by compilingfoo.c
And to understand what the GCC optimizations are doing one could even try
-fdump-tree-all
(but this produces hundreds of files!).Put it pretty much anywhere.
will store the generated assemby in
output.asm
.You can ask GCC to produce the assembly file, instead of an object file (or an executable).
For instance:
Will produce an object file from test.c (test.o).
Will produce an executable file named 'test' from test.c
Will produce an assembly file from test.c (test.s)