summaryrefslogtreecommitdiff
path: root/src/util/fipstools/delocate/testdata/x86_64-GOTRewrite/out.s
blob: ae47e4117776aea900db699bd392bbd107dfdb50 (plain)
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
.text
.file 1 "inserted_by_delocate.c"
.loc 1 1 0
BORINGSSL_bcm_text_start:
	.text
.Lfoo_local_target:
foo:
.Lbar_local_target:
bar:
	# leaq of OPENSSL_ia32cap_P is supported.
# WAS leaq OPENSSL_ia32cap_P(%rip), %r11
	leaq -128(%rsp), %rsp
	pushfq
	leaq	OPENSSL_ia32cap_addr_delta(%rip), %r11
	addq	(%r11), %r11
	popfq
	leaq 128(%rsp), %rsp

	# As is the equivalent GOTPCREL movq.
# WAS movq OPENSSL_ia32cap_P@GOTPCREL(%rip), %r12
	leaq -128(%rsp), %rsp
	pushfq
	leaq	OPENSSL_ia32cap_addr_delta(%rip), %r12
	addq	(%r12), %r12
	popfq
	leaq 128(%rsp), %rsp

	# And a non-movq instruction via the GOT.
# WAS orq OPENSSL_ia32cap_P@GOTPCREL(%rip), %r12
	leaq -128(%rsp), %rsp
	pushq %rax
	pushfq
	leaq	OPENSSL_ia32cap_addr_delta(%rip), %rax
	addq	(%rax), %rax
	popfq
	orq %rax, %r12
	popq %rax
	leaq 128(%rsp), %rsp

	# ... which targets the default temp register
# WAS orq OPENSSL_ia32cap_P@GOTPCREL(%rip), %rax
	leaq -128(%rsp), %rsp
	pushq %rbx
	pushfq
	leaq	OPENSSL_ia32cap_addr_delta(%rip), %rbx
	addq	(%rbx), %rbx
	popfq
	orq %rbx, %rax
	popq %rbx
	leaq 128(%rsp), %rsp

	# Test that GOTPCREL accesses get translated. They are handled
	# differently for local and external symbols.

# WAS pushq stderr@GOTPCREL(%rip)
	pushq %rax
	leaq -128(%rsp), %rsp
	pushf
	leaq stderr_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	leaq	128(%rsp), %rsp
	xchg %rax, (%rsp)
# WAS pushq foo@GOTPCREL(%rip)
	pushq %rax
	leaq	.Lfoo_local_target(%rip), %rax
	xchg %rax, (%rsp)

# WAS movq stderr@GOTPCREL(%rip), %r11
	leaq -128(%rsp), %rsp
	pushf
	leaq stderr_GOTPCREL_external(%rip), %r11
	addq (%r11), %r11
	movq (%r11), %r11
	popf
	leaq	128(%rsp), %rsp
# WAS movq foo@GOTPCREL(%rip), %r11
	leaq	.Lfoo_local_target(%rip), %r11

# WAS vmovq stderr@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	pushf
	leaq stderr_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	vmovq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp
# WAS vmovq foo@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	leaq	.Lfoo_local_target(%rip), %rax
	vmovq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp

# WAS cmoveq stderr@GOTPCREL(%rip), %r11
	jne 999f
	leaq -128(%rsp), %rsp
	pushf
	leaq stderr_GOTPCREL_external(%rip), %r11
	addq (%r11), %r11
	movq (%r11), %r11
	popf
	leaq	128(%rsp), %rsp
999:
# WAS cmoveq foo@GOTPCREL(%rip), %r11
	jne 999f
	leaq	.Lfoo_local_target(%rip), %r11
999:
# WAS cmovneq stderr@GOTPCREL(%rip), %r11
	je 999f
	leaq -128(%rsp), %rsp
	pushf
	leaq stderr_GOTPCREL_external(%rip), %r11
	addq (%r11), %r11
	movq (%r11), %r11
	popf
	leaq	128(%rsp), %rsp
999:
# WAS cmovneq foo@GOTPCREL(%rip), %r11
	je 999f
	leaq	.Lfoo_local_target(%rip), %r11
999:

# WAS movsd foo@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	leaq	.Lfoo_local_target(%rip), %rax
	movq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp
# WAS vmovsd foo@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	leaq	.Lfoo_local_target(%rip), %rax
	vmovq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp

	# movsd without arguments should be left as-is.
	movsd

	# Synthesized symbols do not use the GOT.
# WAS movq BORINGSSL_bcm_text_start@GOTPCREL(%rip), %r11
	leaq	BORINGSSL_bcm_text_start(%rip), %r11
# WAS movq foobar_bss_get@GOTPCREL(%rip), %r11
	leaq	foobar_bss_get(%rip), %r11
# WAS movq OPENSSL_ia32cap_get@GOTPCREL(%rip), %r11
	leaq	.LOPENSSL_ia32cap_get_local_target(%rip), %r11

	# Transforming moves run the transform in-place after the load.
# WAS vpbroadcastq stderr@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	pushf
	leaq stderr_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	vmovq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp
	vpbroadcastq %xmm0, %xmm0
# WAS vpbroadcastq foo@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	leaq	.Lfoo_local_target(%rip), %rax
	vmovq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp
	vpbroadcastq %xmm0, %xmm0

	# GCC sometimes loads a pair of pointers into an XMM register and
	# writes them together.
# WAS movq gcm_gmult_clmul@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	pushf
	leaq gcm_gmult_clmul_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	movq %rax, %xmm0
	popq %rax
	leaq 128(%rsp), %rsp
# WAS movhps gcm_ghash_clmul@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	pushf
	leaq gcm_ghash_clmul_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	pushq %rax
	movhps (%rsp), %xmm0
	leaq 8(%rsp), %rsp
	popq %rax
	leaq 128(%rsp), %rsp
	movaps %xmm0, (%rsp)

	# We've yet to observe this, but the above could also have been written
	# with movlps.
# WAS movhps gcm_ghash_clmul@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	pushf
	leaq gcm_ghash_clmul_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	pushq %rax
	movhps (%rsp), %xmm0
	leaq 8(%rsp), %rsp
	popq %rax
	leaq 128(%rsp), %rsp
# WAS movlps gcm_gmult_clmul@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	pushf
	leaq gcm_gmult_clmul_GOTPCREL_external(%rip), %rax
	addq (%rax), %rax
	movq (%rax), %rax
	popf
	pushq %rax
	movlps (%rsp), %xmm0
	leaq 8(%rsp), %rsp
	popq %rax
	leaq 128(%rsp), %rsp
	movaps %xmm0, (%rsp)

	# Same as above, but with a local symbol.
# WAS movhps foo@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	leaq	.Lfoo_local_target(%rip), %rax
	pushq %rax
	movhps (%rsp), %xmm0
	leaq 8(%rsp), %rsp
	popq %rax
	leaq 128(%rsp), %rsp
# WAS movlps bar@GOTPCREL(%rip), %xmm0
	leaq -128(%rsp), %rsp
	pushq %rax
	leaq	.Lbar_local_target(%rip), %rax
	pushq %rax
	movlps (%rsp), %xmm0
	leaq 8(%rsp), %rsp
	popq %rax
	leaq 128(%rsp), %rsp
	movaps %xmm0, (%rsp)

# WAS cmpq foo@GOTPCREL(%rip), %rax
	leaq -128(%rsp), %rsp
	pushq %rbx
	leaq	.Lfoo_local_target(%rip), %rbx
	cmpq %rbx, %rax
	popq %rbx
	leaq 128(%rsp), %rsp
# WAS cmpq %rax, foo@GOTPCREL(%rip)
	leaq -128(%rsp), %rsp
	pushq %rbx
	leaq	.Lfoo_local_target(%rip), %rbx
	cmpq %rax, %rbx
	popq %rbx
	leaq 128(%rsp), %rsp

	# With -mcmodel=medium, the code may load the address of the GOT directly.
# WAS leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
	leaq	.Lboringssl_got_delta(%rip), %rcx
	addq .Lboringssl_got_delta(%rip), %rcx

.comm foobar,64,32
.text
.loc 1 2 0
BORINGSSL_bcm_text_end:
.type foobar_bss_get, @function
foobar_bss_get:
	leaq	foobar(%rip), %rax
	ret
.type gcm_ghash_clmul_GOTPCREL_external, @object
.size gcm_ghash_clmul_GOTPCREL_external, 8
gcm_ghash_clmul_GOTPCREL_external:
	.long gcm_ghash_clmul@GOTPCREL
	.long 0
.type gcm_gmult_clmul_GOTPCREL_external, @object
.size gcm_gmult_clmul_GOTPCREL_external, 8
gcm_gmult_clmul_GOTPCREL_external:
	.long gcm_gmult_clmul@GOTPCREL
	.long 0
.type stderr_GOTPCREL_external, @object
.size stderr_GOTPCREL_external, 8
stderr_GOTPCREL_external:
	.long stderr@GOTPCREL
	.long 0
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
	leaq OPENSSL_ia32cap_P(%rip), %rax
	ret
.extern OPENSSL_ia32cap_P
.type OPENSSL_ia32cap_addr_delta, @object
.size OPENSSL_ia32cap_addr_delta, 8
OPENSSL_ia32cap_addr_delta:
.quad OPENSSL_ia32cap_P-OPENSSL_ia32cap_addr_delta
.Lboringssl_got_delta:
	.quad _GLOBAL_OFFSET_TABLE_-.Lboringssl_got_delta
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
.byte 0xae
.byte 0x2c
.byte 0xea
.byte 0x2a
.byte 0xbd
.byte 0xa6
.byte 0xf3
.byte 0xec
.byte 0x97
.byte 0x7f
.byte 0x9b
.byte 0xf6
.byte 0x94
.byte 0x9a
.byte 0xfc
.byte 0x83
.byte 0x68
.byte 0x27
.byte 0xcb
.byte 0xa0
.byte 0xa0
.byte 0x9f
.byte 0x6b
.byte 0x6f
.byte 0xde
.byte 0x52
.byte 0xcd
.byte 0xe2
.byte 0xcd
.byte 0xff
.byte 0x31
.byte 0x80