12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
$ cat > hello_world.c
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
^D
$ gcc -g -Wa,-adhln -fverbose-asm hello_world.c > hello_world.s
$ cat hello_world.s
1 .file "hello_world.c"
2 # GNU C17 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
3 # compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2
4
5 # GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
6 # options passed: -imultiarch x86_64-linux-gnu hello_world.c
7 # -mtune=generic -march=x86-64 -g -fverbose-asm
8 # -fasynchronous-unwind-tables
9 # options enabled: -fPIC -fPIE -faggressive-loop-optimizations
10 # -fallocation-dce -fasynchronous-unwind-tables -fauto-inc-dec
11 # -fdelete-null-pointer-checks -fdwarf2-cfi-asm -fearly-inlining
12 # -feliminate-unused-debug-symbols -feliminate-unused-debug-types
13 # -ffp-int-builtin-inexact -ffunction-cse -fgcse-lm -fgnu-unique -fident
14 # -finline-atomics -fipa-stack-alignment -fira-hoist-pressure
15 # -fira-share-save-slots -fira-share-spill-slots -fivopts
16 # -fkeep-static-consts -fleading-underscore -flifetime-dse -fmath-errno
17 # -fmerge-debug-strings -fpeephole -fplt -fprefetch-loop-arrays
18 # -freg-struct-return -fsched-critical-path-heuristic
19 # -fsched-dep-count-heuristic -fsched-group-heuristic -fsched-interblock
20 # -fsched-last-insn-heuristic -fsched-rank-heuristic -fsched-spec
21 # -fsched-spec-insn-heuristic -fsched-stalled-insns-dep -fschedule-fusion
22 # -fsemantic-interposition -fshow-column -fshrink-wrap-separate
23 # -fsigned-zeros -fsplit-ivs-in-unroller -fssa-backprop -fstdarg-opt
24 # -fstrict-volatile-bitfields -fsync-libcalls -ftrapping-math -ftree-cselim
25 # -ftree-forwprop -ftree-loop-if-convert -ftree-loop-im -ftree-loop-ivcanon
26 # -ftree-loop-optimize -ftree-parallelize-loops= -ftree-phiprop
27 # -ftree-reassoc -ftree-scev-cprop -funit-at-a-time -funwind-tables
28 # -fverbose-asm -fzero-initialized-in-bss -m128bit-long-double -m64 -m80387
29 # -malign-stringops -mavx256-split-unaligned-load
30 # -mavx256-split-unaligned-store -mfancy-math-387 -mfp-ret-in-387 -mfxsr
31 # -mglibc -mieee-fp -mlong-double-80 -mmmx -mno-sse4 -mpush-args -mred-zone
32 # -msse -msse2 -mstv -mtls-direct-seg-refs -mvzeroupper
33
34 .text
35 .Ltext0:
36 .section .rodata
37 .LC0:
38 0000 48656C6C .string "Hello, World!"
38 6F2C2057
38 6F726C64
38 2100
39 .text
40 .globl main
42 main:
43 .LFB0:
44 .file 1 "hello_world.c"
1:hello_world.c **** #include <stdio.h>
2:hello_world.c **** int main() {
45 .loc 1 2 12
46 .cfi_startproc
47 0000 55 pushq %rbp #
48 .cfi_def_cfa_offset 16
49 .cfi_offset 6, -16
50 0001 4889E5 movq %rsp, %rbp #,
51 .cfi_def_cfa_register 6
52 # hello_world.c:3: printf("Hello, World!");
3:hello_world.c **** printf("Hello, World!");
53 .loc 1 3 4
54 0004 488D3D00 leaq .LC0(%rip), %rdi #,
54 000000
55 000b B8000000 movl $0, %eax #,
55 00
56 0010 E8000000 call printf@PLT #
56 00
57 # hello_world.c:4: return 0;
4:hello_world.c **** return 0;
58 .loc 1 4 11
59 0015 B8000000 movl $0, %eax #, _3
59 00
60 # hello_world.c:5: }
5:hello_world.c **** }
61 .loc 1 5 1
62 001a 5D popq %rbp #
63 .cfi_def_cfa 7, 8
64 001b C3 ret
65 .cfi_endproc
66 .LFE0:
68 .Letext0:
$