File: cfi-x86_64.s

package info (click to toggle)
binutils 2.31.1-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 307,644 kB
  • sloc: ansic: 1,161,122; asm: 638,494; cpp: 128,815; exp: 68,557; makefile: 55,816; sh: 22,360; yacc: 14,238; lisp: 13,272; perl: 2,111; ada: 1,681; lex: 1,652; pascal: 1,446; cs: 879; sed: 195; python: 154; xml: 95; awk: 25
file content (233 lines) | stat: -rw-r--r-- 4,694 bytes parent folder | download | duplicates (29)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
	.text

#; func_locvars
#; - function with a space on the stack 
#;   allocated for local variables

func_locvars:
	.cfi_startproc
	
	#; alocate space for local vars
	sub	$0x1234,%rsp
	.cfi_adjust_cfa_offset	0x1234
	
	#; dummy body
	movl	$1,%eax
	
	#; release space of local vars and return
	add	$0x1234,%rsp
	.cfi_adjust_cfa_offset	-0x1234
	ret
	.cfi_endproc

#; func_prologue
#; - functions that begins with standard
#;   prologue: "pushq %rbp; movq %rsp,%rbp"

func_prologue:
	.cfi_startproc
	
	#; prologue, CFI is valid after 
	#; each instruction.
	pushq	%rbp
	.cfi_def_cfa_offset	16
	.cfi_offset		%rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register	%rbp

	#; function body
	call	func_locvars
	addl	$3, %eax

	#; epilogue with valid CFI
	#; (we're better than gcc :-)
	leaveq
	.cfi_def_cfa		%rsp, 8
	ret
	.cfi_endproc

#; func_otherreg
#; - function that moves frame pointer to 
#;   another register (r12) and then allocates 
#;   a space for local variables

func_otherreg:
	.cfi_startproc

	#; save frame pointer to r8
	movq	%rsp,%r8
	.cfi_def_cfa_register	r8

	#; alocate space for local vars
	#;  (no .cfi_{def,adjust}_cfa_offset here,
	#;   because CFA is computed from r8!)
	sub	$100,%rsp

	#; function body
	call	func_prologue
	addl	$2, %eax
	
	#; restore frame pointer from r8
	movq	%r8,%rsp
	.cfi_def_cfa_register	rsp
	ret
	.cfi_endproc

#; main
#; - typical function
main:
	.cfi_startproc
	
	#; only function body that doesn't
	#; touch the stack at all.
	call	func_otherreg
	
	#; return
	ret
	.cfi_endproc

#; _start
#; - standard entry point

	.globl	_start
_start:
	.cfi_startproc
	call	main
	movq	%rax,%rdi
	movq	$0x3c,%rax
	syscall
	hlt
	.cfi_endproc

#; func_alldirectives
#; - test for all .cfi directives. 
#;   This function is never called and the CFI info doesn't make sense.

func_alldirectives:
	.cfi_startproc simple
	.cfi_def_cfa	rsp,8
	nop
	.cfi_def_cfa_offset	16
	nop
	.cfi_def_cfa_register	r8
	nop
	.cfi_adjust_cfa_offset	0x1234
	nop
	.cfi_offset	%rsi, 0x10
	nop
	.cfi_register	%r8, %r9
	nop
	.cfi_remember_state
	nop
	.cfi_restore %rbp
	nop
	.cfi_undefined %rip
	nop
	.cfi_same_value rbx
	nop
	.cfi_restore_state
	ret
	.cfi_endproc

#; func_all_registers
#; - test for all .cfi register numbers. 
#;   This function is never called and the CFI info doesn't make sense.

func_all_registers:
	.cfi_startproc simple

	.cfi_undefined rip	; nop
	.cfi_undefined rax	; nop
	.cfi_undefined rcx	; nop
	.cfi_undefined rdx	; nop
	.cfi_undefined rbx	; nop
	.cfi_undefined rsp	; nop
	.cfi_undefined rbp	; nop
	.cfi_undefined rsi	; nop
	.cfi_undefined rdi	; nop
	.cfi_undefined r8	; nop
	.cfi_undefined r9	; nop
	.cfi_undefined r10	; nop
	.cfi_undefined r11	; nop
	.cfi_undefined r12	; nop
	.cfi_undefined r13	; nop
	.cfi_undefined r14	; nop
	.cfi_undefined r15	; nop
	.cfi_undefined rflags	; nop

	.cfi_undefined es	; nop
	.cfi_undefined cs	; nop
	.cfi_undefined ds	; nop
	.cfi_undefined ss	; nop
	.cfi_undefined fs	; nop
	.cfi_undefined gs	; nop
	.cfi_undefined tr	; nop
	.cfi_undefined ldtr	; nop
	.cfi_undefined fs.base	; nop
	.cfi_undefined gs.base	; nop

	.cfi_undefined mxcsr	; nop
	.cfi_undefined xmm0	; nop
	.cfi_undefined xmm1	; nop
	.cfi_undefined xmm2	; nop
	.cfi_undefined xmm3	; nop
	.cfi_undefined xmm4	; nop
	.cfi_undefined xmm5	; nop
	.cfi_undefined xmm6	; nop
	.cfi_undefined xmm7	; nop
	.cfi_undefined xmm8	; nop
	.cfi_undefined xmm9	; nop
	.cfi_undefined xmm10	; nop
	.cfi_undefined xmm11	; nop
	.cfi_undefined xmm12	; nop
	.cfi_undefined xmm13	; nop
	.cfi_undefined xmm14	; nop
	.cfi_undefined xmm15	; nop

	.cfi_undefined fcw	; nop
	.cfi_undefined fsw	; nop
	.cfi_undefined st	; nop
	.cfi_undefined st(1)	; nop
	.cfi_undefined st(2)	; nop
	.cfi_undefined st(3)	; nop
	.cfi_undefined st(4)	; nop
	.cfi_undefined st(5)	; nop
	.cfi_undefined st(6)	; nop
	.cfi_undefined st(7)	; nop

	.cfi_undefined mm0	; nop
	.cfi_undefined mm1	; nop
	.cfi_undefined mm2	; nop
	.cfi_undefined mm3	; nop
	.cfi_undefined mm4	; nop
	.cfi_undefined mm5	; nop
	.cfi_undefined mm6	; nop
	.cfi_undefined mm7	; nop

	.cfi_undefined xmm16	; nop
	.cfi_undefined xmm17	; nop
	.cfi_undefined xmm18	; nop
	.cfi_undefined xmm19	; nop
	.cfi_undefined xmm20	; nop
	.cfi_undefined xmm21	; nop
	.cfi_undefined xmm22	; nop
	.cfi_undefined xmm23	; nop
	.cfi_undefined xmm24	; nop
	.cfi_undefined xmm25	; nop
	.cfi_undefined xmm26	; nop
	.cfi_undefined xmm27	; nop
	.cfi_undefined xmm28	; nop
	.cfi_undefined xmm29	; nop
	.cfi_undefined xmm30	; nop
	.cfi_undefined xmm31	; nop

	.cfi_undefined k0	; nop
	.cfi_undefined k1	; nop
	.cfi_undefined k2	; nop
	.cfi_undefined k3	; nop
	.cfi_undefined k4	; nop
	.cfi_undefined k5	; nop
	.cfi_undefined k6	; nop
	.cfi_undefined k7	; nop

	.cfi_endproc