How can I view the C code after compilation in binary code?

后端 未结 5 901
春和景丽
春和景丽 2020-12-10 23:44

The compiler is what takes this code, and translates it into the machine code

How can I see the original C code after compilation in bin

5条回答
  •  青春惊慌失措
    2020-12-11 00:19

    If you compile with debug information embedded in the object files ( binary output files generated by compiling the source files ), links to the original locations of the source files will be embedded in the object files. This allows a debugger ( e.g. gdb ) to jump to the line in the source file corresponding to a breakpoint when that breakpoint is encountered whilst debugging the program. You can compile with debug info added by specifying the -g switch if you're using gcc. For example:

    gcc -g -o myProgram myProgram.c
    

    compiles myProgram.c into a executable myProgram which you can run or debug. To debug myProgram you can use gdb:

    gdb myProgram
    

提交回复
热议问题