Add script to build and test GDB using enable-targets=all.
[deliverable/binutils-gdb.git] / gas / testsuite / gas / cfi / cfi-x86_64.s
CommitLineData
2ebaa23b
AM
1#; $ as -o test.o gas-cfi-test.s && gcc -nostdlib -o test test.o
2
3 .text
4
5#; func_locvars
6#; - function with a space on the stack
7#; allocated for local variables
8
9 .type func_locvars,@function
10func_locvars:
11 .cfi_startproc
12
13 #; alocate space for local vars
14 sub $0x1234,%rsp
15 .cfi_adjust_cfa_offset 0x1234
16
17 #; dummy body
18 movl $1,%eax
19
20 #; release space of local vars and return
21 add $0x1234,%rsp
22 .cfi_adjust_cfa_offset -0x1234
23 ret
24 .cfi_endproc
25
26#; func_prologue
27#; - functions that begins with standard
28#; prologue: "pushq %rbp; movq %rsp,%rbp"
29
30 .type func_prologue,@function
31func_prologue:
32 .cfi_startproc
33
34 #; prologue, CFI is valid after
35 #; each instruction.
36 pushq %rbp
37 .cfi_def_cfa_offset 16
4b7d318b 38 .cfi_offset %rbp, -16
2ebaa23b 39 movq %rsp, %rbp
4b7d318b 40 .cfi_def_cfa_register %rbp
2ebaa23b
AM
41
42 #; function body
43 call func_locvars
44 addl $3, %eax
45
46 #; epilogue with valid CFI
47 #; (we're better than gcc :-)
48 leaveq
4b7d318b 49 .cfi_def_cfa %rsp, 8
2ebaa23b
AM
50 ret
51 .cfi_endproc
52
53#; func_otherreg
54#; - function that moves frame pointer to
55#; another register (r12) and then allocates
56#; a space for local variables
57
58 .type func_otherreg,@function
59func_otherreg:
60 .cfi_startproc
61
4b7d318b
L
62 #; save frame pointer to r8
63 movq %rsp,%r8
64 .cfi_def_cfa_register r8
2ebaa23b
AM
65
66 #; alocate space for local vars
67 #; (no .cfi_{def,adjust}_cfa_offset here,
4b7d318b 68 #; because CFA is computed from r8!)
2ebaa23b
AM
69 sub $100,%rsp
70
71 #; function body
72 call func_prologue
73 addl $2, %eax
74
4b7d318b
L
75 #; restore frame pointer from r8
76 movq %r8,%rsp
2ebaa23b
AM
77 .cfi_def_cfa_register rsp
78 ret
79 .cfi_endproc
80
81#; main
82#; - typical function
83 .type main,@function
84main:
85 .cfi_startproc
86
87 #; only function body that doesn't
88 #; touch the stack at all.
89 call func_otherreg
90
91 #; return
92 ret
93 .cfi_endproc
94
95#; _start
96#; - standard entry point
97
98 .type _start,@function
99 .globl _start
100_start:
101 .cfi_startproc
102 call main
103 movq %rax,%rdi
104 movq $0x3c,%rax
105 syscall
106 hlt
107 .cfi_endproc
4b7d318b
L
108
109#; func_alldirectives
110#; - test for all .cfi directives.
111#; This function is never called and the CFI info doesn't make sense.
112
113 .type func_alldirectives,@function
114func_alldirectives:
115 .cfi_startproc simple
116 .cfi_def_cfa rsp,8
117 nop
118 .cfi_def_cfa_offset 16
119 nop
120 .cfi_def_cfa_register r8
121 nop
122 .cfi_adjust_cfa_offset 0x1234
123 nop
124 .cfi_offset %rsi, 0x10
125 nop
126 .cfi_register %r8, %r9
127 nop
128 .cfi_remember_state
129 nop
130 .cfi_restore %rbp
131 nop
132 .cfi_undefined %rip
133 nop
134 .cfi_same_value rbx
135 nop
136 .cfi_restore_state
137 ret
138 .cfi_endproc
This page took 0.222515 seconds and 4 git commands to generate.