How can I compile to assembly with gcc

前端 未结 3 1765
挽巷
挽巷 2020-12-29 02:08

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 fla

3条回答
  •  暖寄归人
    2020-12-29 02:45

    You can ask GCC to produce the assembly file, instead of an object file (or an executable).

    For instance:

    gcc -Wall -c test.c
    

    Will produce an object file from test.c (test.o).

    gcc -Wall -o test test.c
    

    Will produce an executable file named 'test' from test.c

    gcc -Wall -S test.c
    

    Will produce an assembly file from test.c (test.s)

提交回复
热议问题