|
发表于 2021-1-6 13:44:18
|
显示全部楼层
- #include <stdio.h>
- unsigned int a;
- unsigned int b;
- unsigned int c;
- int main( void ){
- a=1;
- printf("%x\n",b);
- c=2;
- return 0;
- }
复制代码
- .file "test.c"
- .comm a,4,4
- .comm b,4,4
- .comm c,4,4
- .section .rodata
- .LC0:
- .string "%x\n"
- .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 $1, a(%rip)
- movl b(%rip), %eax
- movl %eax, %esi
- movl $.LC0, %edi
- movl $0, %eax
- call printf
- movl $2, c(%rip)
- movl $0, %eax
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
- .LFE0:
- .size main, .-main
- .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609"
- .section .note.GNU-stack,"",@progbits
- ~
复制代码
这是gcc产生的汇编,不会有任何的主动初始化。如果你说在crt0里有操作的话,那不属于c语言的特性。 |
|