How to disable compiler optimizations in gcc?

后端 未结 7 835
误落风尘
误落风尘 2020-12-07 11:07

I am trying to learn assembly language. I have searched and found how to disassemble a .c file but I think it produces some optimized version of the program. Is

7条回答
  •  悲&欢浪女
    2020-12-07 11:43

    For gcc you want to omit any -O1 -O2 or -O3 options passed to the compiler or if you already have them you can append the -O0 option to turn it off again. It might also help you to add -g for debug so that you can see the c source and disassembled machine code in your debugger.

    See also: http://sourceware.org/gdb/onlinedocs/gdb/Optimized-Code.html

提交回复
热议问题