六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 45|回复: 0

linux高级程序设计 读书笔记 gcc

[复制链接]

升级  0.65%

321

主题

321

主题

321

主题

探花

Rank: 6Rank: 6

积分
1013
 楼主| 发表于 2013-1-26 12:29:20 | 显示全部楼层 |阅读模式
在编译源文件时指定"-S",输出汇编代码到.s文件
gcc -S hello.c
使用GNU汇编器as来编译源代码hello.s
as -o hello.o hello.s

[root@localhost kernel]# gcc -S hello.c [root@localhost kernel]# lshello.c  hello.s[root@localhost kernel]# cat hello.s         .file   "hello.c"        .section        .rodata.LC0:        .string "haha"        .text        .globl  main        .type   main, @functionmain:.LFB0:        .cfi_startproc        pushl   %ebp        .cfi_def_cfa_offset 8        .cfi_offset 5, -8        movl    %esp, %ebp        .cfi_def_cfa_register 5        andl    $-16, %esp        subl    $16, %esp        movl    $.LC0, %eax        movl    %eax, (%esp)        call    printf        movl    $0, %eax        leave        .cfi_restore 5        .cfi_def_cfa 4, 4        ret        .cfi_endproc.LFE0:        .size   main, .-main        .ident  "GCC: (GNU) 4.6.3 20120306 (Red Hat 4.6.3-2)"        .section        .note.GNU-stack,"",@progbits[root@localhost kernel]# [root@localhost kernel]# [root@localhost kernel]# [root@localhost kernel]# cat hello.c #include <stdio.h>#include <stdlib.h>int main(){        printf("haha");        return 0;}[root@localhost kernel]#
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表