2 // RUN
: llvm-mc
-filetype
=obj
-triple
=powerpc64le-unknown-linux
%s
-o
%t.o
3 // RUN
: ld.lld
%t.o
-o
%t
4 // RUN
: llvm-readelf
-r
%t.o | FileCheck
--check-prefix
=InputRelocs
%s
5 // RUN
: llvm-objdump
-d
%t | FileCheck
--check-prefix
=Dis
%s
7 // RUN
: not ld.lld
-shared
%t.o
-o
/dev
/null
2>&1 | FileCheck
%s
--check-prefix
=ERR
9 /// Reject local-exec TLS relocations for
-shared.
10 // ERR
: error
: relocation R_PPC64_TPREL16_HA against
a cannot
be used with
-shared
11 // ERR
: error
: relocation R_PPC64_TPREL16_LO against
a cannot
be used with
-shared
12 // ERR
: error
: relocation R_PPC64_TPREL16 against
b cannot
be used with
-shared
13 // ERR
: error
: relocation R_PPC64_TPREL16_HI against
b cannot
be used with
-shared
14 // ERR
: error
: relocation R_PPC64_TPREL16_DS against
b cannot
be used with
-shared
15 // ERR
: error
: relocation R_PPC64_TPREL16_LO_DS against
b cannot
be used with
-shared
16 // ERR
: error
: relocation R_PPC64_TPREL16_HIGHESTA against
b cannot
be used with
-shared
17 // ERR
: error
: relocation R_PPC64_TPREL16_HIGHERA against
b cannot
be used with
-shared
21 .globl test_local_exec # -- Begin function test_local_exec
23 .type test_local_exec,@function
24 test_local_exec
: # @test_local_exec
29 addis 3, 13, a@tprel@ha
38 .size test_local_exec, .Lfunc_end0-.Lfunc_begin0
42 addis 2, 12, .TOC.-.Lfunc_gep1@ha
43 addi 2, 2, .TOC.-.Lfunc_gep1@l
45 .localentry test_tprel, .Lfunc_lep1-.Lfunc_gep1
52 addis 2, 12, .TOC.-.Lfunc_gep2@ha
53 addi 2, 2, .TOC.-.Lfunc_gep2@l
55 .localentry test_hi, .Lfunc_lep2-.Lfunc_gep2
56 addis 3, 13, b@tprel@h
61 addis 2, 12, .TOC.-.Lfunc_gep3@ha
62 addi 2, 2, .TOC.-.Lfunc_gep3@l
64 .localentry test_ds, .Lfunc_lep3-.Lfunc_gep3
70 addis 2, 12, .TOC.-.Lfunc_gep4@ha
71 addi 2, 2, .TOC.-.Lfunc_gep4@l
73 .localentry test_lo_ds, .Lfunc_lep4-.Lfunc_gep4
79 addis 2, 12, .TOC.-.Lfunc_gep5@ha
80 addi 2, 2, .TOC.-.Lfunc_gep5@l
82 .localentry test_highest_a, .Lfunc_lep5-.Lfunc_gep5
83 lis 4, b@tprel@highesta
84 ori 4, 4, b@tprel@highera
94 addis 2, 12, .TOC.-.Lfunc_gep6@ha
95 addi 2, 2, .TOC.-.Lfunc_gep6@l
97 .localentry test_highest, .Lfunc_lep6-.Lfunc_gep6
98 lis 4, b@tprel@highest
99 ori 4, 4, b@tprel@higher
108 .section .tdata,"awT",@progbits
118 // Verify that the input has every initial-exec tls relocation type.
119 // InputRelocs
: Relocation section
'.rela.text'
120 // InputRelocs
: R_PPC64_TPREL16_HA
{{0+}} a + 0
121 // InputRelocs
: R_PPC64_TPREL16_LO
{{0+}} a + 0
122 // InputRelocs
: R_PPC64_TPREL16
{{0+8}} b + 0
123 // InputRelocs
: R_PPC64_TPREL16_HI
{{0+8}} b + 0
124 // InputRelocs
: R_PPC64_TPREL16_DS
{{0+8}} b + 0
125 // InputRelocs
: R_PPC64_TPREL16_LO_DS
{{0+8}} b + 0
126 // InputRelocs
: R_PPC64_TPREL16_HIGHESTA
{{0+8}} b + 0
127 // InputRelocs
: R_PPC64_TPREL16_HIGHERA
{{0+8}} b + 0
128 // InputRelocs
: R_PPC64_TPREL16_HIGHEST
{{0+8}} b + 0
129 // InputRelocs
: R_PPC64_TPREL16_HIGHER
{{0+8}} b + 0
131 // The start of the TLS storage area is
0x7000 bytes before the thread pointer
(r13).
132 // We are building the address of the first TLS variable
, relative to the thread pointer.
133 // #ha(a@tprel) --> (0 - 0x7000 + 0x8000) >> 16 = 0
134 // #lo(a@tprel)) --> (0 - 0x7000) & 0xFFFF = -0x7000 = -28672
135 // Dis
: <test_local_exec
>:
136 // Dis
: addis 3, 13, 0
137 // Dis
: addi 3, 3, -28672
139 // We are building the offset for the second TLS variable
140 // Offset within tls storage
- 0x7000
141 // b@tprel
= 8 - 0x7000 = 28664
142 // Dis
: <test_tprel
>:
143 // Dis
: addi 3, 13, -28664
145 // #hi(b@tprel) --> (8 - 0x7000) >> 16 = -1
147 // Dis
: addis 3, 13, -1
149 // b@tprel
= 8 - 0x7000 = -28664
151 // Dis
: ld 3, -28664(13)
153 // #lo(b@tprel) --> (8 - 0x7000) & 0xFFFF = -28664
154 // Dis
: <test_lo_ds
>:
155 // Dis
: ld 3, -28664(13)
157 // #highesta(b@tprel) --> ((0x8 - 0x7000 + 0x8000) >> 48) & 0xFFFF = 0
158 // #highera(b@tprel) --> ((0x8 - 0x7000 + 0x8000) >> 32) & 0xFFFF = 0
159 // #ha(k@dtprel) --> ((0x8 - 0x7000 + 0x8000) >> 16) & 0xFFFF = 0
160 // #lo(k@dtprel) --> ((0x8 - 0x7000) & 0xFFFF = -28664
161 // Dis
: <test_highest_a
>:
165 // Dis
: addi 5, 5, -28664
167 // #highest(b@tprel) --> ((0x8 - 0x7000) >> 48) & 0xFFFF = 0xFFFF = -1
168 // #higher(b@tprel) --> ((0x8 - 0x7000) >> 32) & 0xFFFF = 0xFFFF = 65535
169 // #hi(k@dtprel) --> ((0x8 - 0x7000) >> 16) & 0xFFFF = 0xFFFF = 65535
170 // #lo(k@dtprel) --> ((0x8 - 0x7000) & 0xFFFF = 33796
171 // Dis
: <test_highest
>:
173 // Dis
: ori 4, 4, 65535
174 // Dis
: oris 4, 4, 65535
175 // Dis
: ori 4, 4, 36872