x86-64: fix handling of PUSH/POP of segment register
[deliverable/binutils-gdb.git] / gas / testsuite / gas / cfi / cfi-x86_64.s
CommitLineData
2ebaa23b
AM
1 .text
2
3#; func_locvars
4#; - function with a space on the stack
5#; allocated for local variables
6
2ebaa23b
AM
7func_locvars:
8 .cfi_startproc
9
10 #; alocate space for local vars
11 sub $0x1234,%rsp
12 .cfi_adjust_cfa_offset 0x1234
13
14 #; dummy body
15 movl $1,%eax
16
17 #; release space of local vars and return
18 add $0x1234,%rsp
19 .cfi_adjust_cfa_offset -0x1234
20 ret
21 .cfi_endproc
22
23#; func_prologue
24#; - functions that begins with standard
25#; prologue: "pushq %rbp; movq %rsp,%rbp"
26
2ebaa23b
AM
27func_prologue:
28 .cfi_startproc
29
30 #; prologue, CFI is valid after
31 #; each instruction.
32 pushq %rbp
33 .cfi_def_cfa_offset 16
4b7d318b 34 .cfi_offset %rbp, -16
2ebaa23b 35 movq %rsp, %rbp
4b7d318b 36 .cfi_def_cfa_register %rbp
2ebaa23b
AM
37
38 #; function body
39 call func_locvars
40 addl $3, %eax
41
42 #; epilogue with valid CFI
43 #; (we're better than gcc :-)
44 leaveq
4b7d318b 45 .cfi_def_cfa %rsp, 8
2ebaa23b
AM
46 ret
47 .cfi_endproc
48
49#; func_otherreg
50#; - function that moves frame pointer to
51#; another register (r12) and then allocates
52#; a space for local variables
53
2ebaa23b
AM
54func_otherreg:
55 .cfi_startproc
56
4b7d318b
L
57 #; save frame pointer to r8
58 movq %rsp,%r8
59 .cfi_def_cfa_register r8
2ebaa23b
AM
60
61 #; alocate space for local vars
62 #; (no .cfi_{def,adjust}_cfa_offset here,
4b7d318b 63 #; because CFA is computed from r8!)
2ebaa23b
AM
64 sub $100,%rsp
65
66 #; function body
67 call func_prologue
68 addl $2, %eax
69
4b7d318b
L
70 #; restore frame pointer from r8
71 movq %r8,%rsp
2ebaa23b
AM
72 .cfi_def_cfa_register rsp
73 ret
74 .cfi_endproc
75
76#; main
77#; - typical function
2ebaa23b
AM
78main:
79 .cfi_startproc
80
81 #; only function body that doesn't
82 #; touch the stack at all.
83 call func_otherreg
84
85 #; return
86 ret
87 .cfi_endproc
88
89#; _start
90#; - standard entry point
91
2ebaa23b
AM
92 .globl _start
93_start:
94 .cfi_startproc
95 call main
96 movq %rax,%rdi
97 movq $0x3c,%rax
98 syscall
99 hlt
100 .cfi_endproc
4b7d318b
L
101
102#; func_alldirectives
103#; - test for all .cfi directives.
104#; This function is never called and the CFI info doesn't make sense.
105
4b7d318b
L
106func_alldirectives:
107 .cfi_startproc simple
108 .cfi_def_cfa rsp,8
109 nop
110 .cfi_def_cfa_offset 16
111 nop
112 .cfi_def_cfa_register r8
113 nop
114 .cfi_adjust_cfa_offset 0x1234
115 nop
116 .cfi_offset %rsi, 0x10
117 nop
118 .cfi_register %r8, %r9
119 nop
120 .cfi_remember_state
121 nop
122 .cfi_restore %rbp
123 nop
124 .cfi_undefined %rip
125 nop
126 .cfi_same_value rbx
127 nop
128 .cfi_restore_state
129 ret
130 .cfi_endproc
a60de03c
JB
131
132#; func_all_registers
133#; - test for all .cfi register numbers.
134#; This function is never called and the CFI info doesn't make sense.
135
a60de03c
JB
136func_all_registers:
137 .cfi_startproc simple
138
139 .cfi_undefined rip ; nop
140 .cfi_undefined rax ; nop
141 .cfi_undefined rcx ; nop
142 .cfi_undefined rdx ; nop
143 .cfi_undefined rbx ; nop
144 .cfi_undefined rsp ; nop
145 .cfi_undefined rbp ; nop
146 .cfi_undefined rsi ; nop
147 .cfi_undefined rdi ; nop
148 .cfi_undefined r8 ; nop
149 .cfi_undefined r9 ; nop
150 .cfi_undefined r10 ; nop
151 .cfi_undefined r11 ; nop
152 .cfi_undefined r12 ; nop
153 .cfi_undefined r13 ; nop
154 .cfi_undefined r14 ; nop
155 .cfi_undefined r15 ; nop
156 .cfi_undefined rflags ; nop
157
158 .cfi_undefined es ; nop
159 .cfi_undefined cs ; nop
160 .cfi_undefined ds ; nop
161 .cfi_undefined ss ; nop
162 .cfi_undefined fs ; nop
163 .cfi_undefined gs ; nop
164 .cfi_undefined tr ; nop
165 .cfi_undefined ldtr ; nop
166 .cfi_undefined fs.base ; nop
167 .cfi_undefined gs.base ; nop
168
169 .cfi_undefined mxcsr ; nop
170 .cfi_undefined xmm0 ; nop
171 .cfi_undefined xmm1 ; nop
172 .cfi_undefined xmm2 ; nop
173 .cfi_undefined xmm3 ; nop
174 .cfi_undefined xmm4 ; nop
175 .cfi_undefined xmm5 ; nop
176 .cfi_undefined xmm6 ; nop
177 .cfi_undefined xmm7 ; nop
178 .cfi_undefined xmm8 ; nop
179 .cfi_undefined xmm9 ; nop
180 .cfi_undefined xmm10 ; nop
181 .cfi_undefined xmm11 ; nop
182 .cfi_undefined xmm12 ; nop
183 .cfi_undefined xmm13 ; nop
184 .cfi_undefined xmm14 ; nop
185 .cfi_undefined xmm15 ; nop
186
187 .cfi_undefined fcw ; nop
188 .cfi_undefined fsw ; nop
189 .cfi_undefined st ; nop
190 .cfi_undefined st(1) ; nop
191 .cfi_undefined st(2) ; nop
192 .cfi_undefined st(3) ; nop
193 .cfi_undefined st(4) ; nop
194 .cfi_undefined st(5) ; nop
195 .cfi_undefined st(6) ; nop
196 .cfi_undefined st(7) ; nop
197
198 .cfi_undefined mm0 ; nop
199 .cfi_undefined mm1 ; nop
200 .cfi_undefined mm2 ; nop
201 .cfi_undefined mm3 ; nop
202 .cfi_undefined mm4 ; nop
203 .cfi_undefined mm5 ; nop
204 .cfi_undefined mm6 ; nop
205 .cfi_undefined mm7 ; nop
206
43234a1e
L
207 .cfi_undefined xmm16 ; nop
208 .cfi_undefined xmm17 ; nop
209 .cfi_undefined xmm18 ; nop
210 .cfi_undefined xmm19 ; nop
211 .cfi_undefined xmm20 ; nop
212 .cfi_undefined xmm21 ; nop
213 .cfi_undefined xmm22 ; nop
214 .cfi_undefined xmm23 ; nop
215 .cfi_undefined xmm24 ; nop
216 .cfi_undefined xmm25 ; nop
217 .cfi_undefined xmm26 ; nop
218 .cfi_undefined xmm27 ; nop
219 .cfi_undefined xmm28 ; nop
220 .cfi_undefined xmm29 ; nop
221 .cfi_undefined xmm30 ; nop
222 .cfi_undefined xmm31 ; nop
223
224 .cfi_undefined k0 ; nop
225 .cfi_undefined k1 ; nop
226 .cfi_undefined k2 ; nop
227 .cfi_undefined k3 ; nop
228 .cfi_undefined k4 ; nop
229 .cfi_undefined k5 ; nop
230 .cfi_undefined k6 ; nop
231 .cfi_undefined k7 ; nop
232
a60de03c 233 .cfi_endproc
This page took 0.722632 seconds and 4 git commands to generate.