这已经是汇编了,跟 gcc 没太大关系。 其实它叫啥不重要,它就类似 goto 语法里的标记一样,不一定非得叫 LC0、LC1,你叫 FOO、BAR 也是都可以的。 但一般有一些约定俗成的起法,比如: .LCn:是 Local Constant 的缩写。 .LFBn:是 Local Function Beginning 的缩写。 .LFEn:是 Local Function Ending 的缩写。
.section .rodata .LC0: .string "helloworld" .text .globl main .type main, @function main: .LFB0: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 ... -c表示汇编,把汇编文件变成二进制文件,但是这个二进制文件还...
.section .rodata .LC0: .string "Hello world !" .LC1: .string "TEST_NUM = %d\n" .LC2: .string "sub_func() = %d\n" .text .globl main .type main, @function main: .LFB0: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cf...
.cfi_def_cfa_register 6 leaq .LC0(%rip), %rdi call puts@PLT movl $0, %eax popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property...
0: 48 83 c4 08 add $0x8,%rsp 4: c3 ret -lc表示链接C标准库 : C 标准库中提供 __libc_start_main (main,__libc_csu_init,__libc_csu_fini) __libc_csu_init(负责调用_init()) __libc_csu_fini (负责调用_finit()) 然后用ld 链接 这几个头文件即可 : ...
3 .LC0: 4 .string "Hello World!" 5 .text 6 .globl main 7 .type main, @function 8 main: 9 leal 4(%esp), %ecx 10 andl $-16, %esp 11 pushl -4(%ecx) 12 pushl %ebp 13 movl %esp, %ebp 14 pushl %ecx 15 subl $4, %esp ...
.LC0: .string "hello world! " .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl $.LC0, %edi call puts ...
外部库链接(-llib)这个选项可以链接一些外部可选的库,比如GCc默认main()由exit()终止,也就是GCc会以执行exit(main())的形式调用main(),所以需要加入libc.a和libnosys.a编译,否则会报错,对应指令为-lc -lnosys,链接器会自动添加前缀lib和拓展名.a。
pushl $.LC0 call puts addl $16, %esp movl $0, �x leave ret .size main, .-main .ident "GCC: (GNU) 4.0.0 20050519 (Red Hat 4.0.0-8)" .section .note.GNU-stack,"",@progbits (3)汇编阶段 汇编阶段是把编译阶段生成的”.s”文件转成目标文件,读者在此可使用选项”-c”就可看到汇编...
.LC0:.string"hello, world".text .globl main .type main, @functionmain:.LFB0:.cfi_startproc pushl %ebp .cfi_def_cfa_offset8.cfi_offset5, -8movl %esp, %ebp .cfi_def_cfa_register5andl $-16, %esp subl $16, %esp movl $.LC0, (%esp)callputsleave.cfi_restore5.cfi_def_cfa4,4ret....