summaryrefslogtreecommitdiff
path: root/src/util/fipstools/delocate/testdata/x86_64-GOTRewrite/in.s
blob: 3b7a1ed1567828e88b37d0a138b492a40a9b01e6 (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
	.text
foo:
bar:
	# leaq of OPENSSL_ia32cap_P is supported.
	leaq OPENSSL_ia32cap_P(%rip), %r11

	# As is the equivalent GOTPCREL movq.
	movq OPENSSL_ia32cap_P@GOTPCREL(%rip), %r12

	# And a non-movq instruction via the GOT.
	orq OPENSSL_ia32cap_P@GOTPCREL(%rip), %r12

	# ... which targets the default temp register
	orq OPENSSL_ia32cap_P@GOTPCREL(%rip), %rax

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

	pushq stderr@GOTPCREL(%rip)
	pushq foo@GOTPCREL(%rip)

	movq stderr@GOTPCREL(%rip), %r11
	movq foo@GOTPCREL(%rip), %r11

	vmovq stderr@GOTPCREL(%rip), %xmm0
	vmovq foo@GOTPCREL(%rip), %xmm0

	cmoveq stderr@GOTPCREL(%rip), %r11
	cmoveq foo@GOTPCREL(%rip), %r11
	cmovneq stderr@GOTPCREL(%rip), %r11
	cmovneq foo@GOTPCREL(%rip), %r11

	movsd foo@GOTPCREL(%rip), %xmm0
	vmovsd foo@GOTPCREL(%rip), %xmm0

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

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

	# Transforming moves run the transform in-place after the load.
	vpbroadcastq stderr@GOTPCREL(%rip), %xmm0
	vpbroadcastq foo@GOTPCREL(%rip), %xmm0

	# GCC sometimes loads a pair of pointers into an XMM register and
	# writes them together.
	movq gcm_gmult_clmul@GOTPCREL(%rip), %xmm0
	movhps gcm_ghash_clmul@GOTPCREL(%rip), %xmm0
	movaps %xmm0, (%rsp)

	# We've yet to observe this, but the above could also have been written
	# with movlps.
	movhps gcm_ghash_clmul@GOTPCREL(%rip), %xmm0
	movlps gcm_gmult_clmul@GOTPCREL(%rip), %xmm0
	movaps %xmm0, (%rsp)

	# Same as above, but with a local symbol.
	movhps foo@GOTPCREL(%rip), %xmm0
	movlps bar@GOTPCREL(%rip), %xmm0
	movaps %xmm0, (%rsp)

	cmpq foo@GOTPCREL(%rip), %rax
	cmpq %rax, foo@GOTPCREL(%rip)

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

.comm foobar,64,32