linux高级程序设计 读书笔记 gcc
在编译源文件时指定"-S",输出汇编代码到.s文件gcc -S hello.c
使用GNU汇编器as来编译源代码hello.s
as -o hello.o hello.s
# gcc -S hello.c # lshello.chello.s# cat hello.s .file "hello.c" .section .rodata.LC0: .string "haha" .text .globlmain .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# # # # cat hello.c #include <stdio.h>#include <stdlib.h>int main(){ printf("haha"); return 0;}#
页:
[1]