GCC编译流程

 

 

furtherchan@ubuntu910:~$ ls

aaa.c            Desktop    examples.desktop  Music     Templates  workspace

aaa.h            Documents  macrotest         Pictures  test.c     文档

apue_src.tar.gz  Downloads  macrotest.c       Public    Videos     桌面

furtherchan@ubuntu910:~$ gcc -E -o aaa.i aaa.c

 

furtherchan@ubuntu910:~$ ls

aaa.c            Desktop    examples.desktop  Music     Templates  workspace

aaa.h            Documents  macrotest         Pictures  test.c     文档

aaa.i          apue_src.tar.gz  Downloads  macrotest.c       Public    Videos     桌面

 

furtherchan@ubuntu910:~$ cat aaa.i

 

# 1 "aaa.c"

# 1 "<built-in>"

# 1 "<command-line>"

# 1 "aaa.c"

# 1 "/usr/include/stdio.h" 1 3 4

#......

 

# 3 "aaa.c" 2

# 1 "aaa.h" 1

 

 

 

typedef int integer;

# 4 "aaa.c" 2

 

int main()

{

 integer i = 5;

 printf("Integer i = %d/n",i);

 return 0;

}

 

furtherchan@ubuntu910:~$ gcc -S -o aaa.s aaa.i

 

furtherchan@ubuntu910:~$ ls

aaa.c  apue_src.tar.gz  examples.desktop  Pictures   Videos

aaa.h  Desktop          macrotest         Public     workspace

aaa.i  Documents        macrotest.c       Templates  文档

aaa.s  Downloads        Music             test.c     桌面

 

furtherchan@ubuntu910:~$ cat aaa.s

       .file  "aaa.c"

       .section   .rodata

.LC0:

       .string     "Integer i = %d/n"

       .text

.globl main

       .type       main, @function

main:

       pushl       %ebp

       movl       %esp, %ebp

       andl $-16, %esp

       subl $32, %esp

       movl       $5, 28(%esp)

       movl       $.LC0, %eax

       movl       28(%esp), %edx

       movl       %edx, 4(%esp)

       movl       %eax, (%esp)

       call  printf

       movl       $0, %eax

       leave

       ret

       .size main, .-main

       .ident      "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1"

       .section   .note.GNU-stack,"",@progbits

 

furtherchan@ubuntu910:~$ gcc -c aaa.s -o aaa.o

furtherchan@ubuntu910:~$ ls

aaa.c  aaa.s            Downloads         Music      test.c     桌面

aaa.h  apue_src.tar.gz  examples.desktop  Pictures   Videos

aaa.i  Desktop          macrotest         Public     workspace

aaa.o  Documents        macrotest.c       Templates  文档

 

furtherchan@ubuntu910:~$ gcc aaa.o -o aaa

furtherchan@ubuntu910:~$ ./aaa

Integer i = 5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值