linux 下gcc生成intel汇编

  留作备忘:

  gcc -S -masm=intel xxxx.c

  生成elf可执行文件:
  gcc -o xxx xxxx.s

 

  反汇编
  objdump xxx

 

  补充:  

在使用gcc 对C语言程序进行编译时,可细分为四个阶段:预处理(Pre-processing)、编译(Compiling)、汇编(Assembling)、链接(Linking)。用test.c为例说明:

 

1)预处理:gcc -E test.c -o test.i 对预编译指令都做相应的处理

2)编译:gcc -S test.i -o test.s 编译成汇编指令代码

3)汇编:gcc -c test.s -o test.o 将汇编指令代码转化为目标文件

4)链接:gcc test.o -o test 将目标文件与库文件(静态库或动态库)链接得到可执行文件。

 

posted @ 2014-04-30 00:09  ExiaHan  阅读(1923)  评论(0编辑  收藏  举报