Using GCC to produce readable assembly?

后端 未结 10 2098
死守一世寂寞
死守一世寂寞 2020-11-22 06:13

I was wondering how to use GCC on my C source file to dump a mnemonic version of the machine code so I could see what my code was being compiled into. You can do this with J

10条回答
  •  借酒劲吻你
    2020-11-22 06:53

    Did you try gcc -S -fverbose-asm -O source.c then look into the generated source.s assembler file ?

    The generated assembler code goes into source.s (you could override that with -o assembler-filename ); the -fverbose-asm option asks the compiler to emit some assembler comments "explaining" the generated assembler code. The -O option asks the compiler to optimize a bit (it could optimize more with -O2 or -O3).

    If you want to understand what gcc is doing try passing -fdump-tree-all but be cautious: you'll get hundreds of dump files.

    BTW, GCC is extensible thru plugins or with MELT (a high level domain specific language to extend GCC; which I abandoned in 2017)

提交回复
热议问题