xref: /llvm-project/lld/test/ELF/systemz-tls-ie.s (revision 6f907733e65d24edad65f763fb14402464bd578b)
1# REQUIRES: systemz
2# RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %s -o %t.o
3
4# RUN: ld.lld -shared %t.o -o %t.so
5# RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=IE-REL %s
6# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=IE %s
7# RUN: llvm-objdump --section .data --full-contents %t.so | FileCheck --check-prefix=IE-DATA %s
8
9# RUN: ld.lld %t.o -o %t
10# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
11# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
12# RUN: llvm-objdump --section .data --full-contents %t | FileCheck --check-prefix=LE-DATA %s
13# RUN: llvm-objdump --section .got --full-contents %t | FileCheck --check-prefix=LE-GOT %s
14
15## With -pie we still have the R_390_RELATIVE for the data element, but all GOT
16## entries should be fully resolved without any remaining R_390_TLS_TPOFF.
17# RUN: ld.lld -pie %t.o -o %t.pie
18# RUN: llvm-readelf -r %t.pie | FileCheck --check-prefix=PIE-REL %s
19# RUN: llvm-objdump -d --no-show-raw-insn %t.pie | FileCheck --check-prefix=PIE %s
20# RUN: llvm-objdump --section .data --full-contents %t.pie | FileCheck --check-prefix=PIE-DATA %s
21# RUN: llvm-objdump --section .got --full-contents %t.pie | FileCheck --check-prefix=PIE-GOT %s
22
23# IE-REL: Relocation section '.rela.dyn' at offset {{.*}} contains 4 entries:
24# IE-REL: 0000000000003478 000000000000000c R_390_RELATIVE 2460
25# IE-REL: 0000000000002460 0000000100000038 R_390_TLS_TPOFF 0000000000000008 a + 0
26# IE-REL: 0000000000002468 0000000200000038 R_390_TLS_TPOFF 000000000000000c b + 0
27# IE-REL: 0000000000002470 0000000300000038 R_390_TLS_TPOFF 0000000000000010 c + 0
28
29## TP offset for a is at 0x2460
30# IE:      lgrl    %r1, 0x2460
31# IE-NEXT: lgf     %r1, 0(%r1,%r7)
32
33## TP offset for b is at 0x2468
34# IE-NEXT: lgrl    %r1, 0x2468
35# IE-NEXT: lgf     %r1, 0(%r1,%r7)
36
37## TP offset for c is at 0x2470
38# IE-NEXT: lgrl    %r1, 0x2470
39# IE-NEXT: lgf     %r1, 0(%r1,%r7)
40
41## Data element: TP offset for a is at 0x2460 (relocated via R_390_RELATIVE above)
42# IE-DATA: 3478 00000000 00000000
43
44# NOREL: no relocations
45
46## TP offset for a is at 0x1002250
47# LE:      lgrl    %r1, 0x1002250
48# LE-NEXT: lgf     %r1, 0(%r1,%r7)
49
50## TP offset for b is at 0x1002258
51# LE-NEXT: lgrl    %r1, 0x1002258
52# LE-NEXT: lgf     %r1, 0(%r1,%r7)
53
54## TP offset for c is at 0x1002260
55# LE-NEXT: lgrl    %r1, 0x1002260
56# LE-NEXT: lgf     %r1, 0(%r1,%r7)
57
58## Data element: TP offset for a is at 0x1002250
59# LE-DATA: 00000000 01002250
60
61## TP offsets in GOT:
62# a: -8
63# b: -4
64# c: 0
65# LE-GOT: 1002238 00000000 00000000 00000000 00000000
66# LE-GOT: 1002248 00000000 00000000 ffffffff fffffff8
67# LE-GOT: 1002258 ffffffff fffffffc 00000000 00000000
68
69# PIE-REL: Relocation section '.rela.dyn' at offset {{.*}} contains 1 entries:
70# PIE-REL: 00000000000033d0 000000000000000c R_390_RELATIVE 23b8
71
72## TP offset for a is at 0x23b8
73# PIE:      lgrl    %r1, 0x23b8
74# PIE-NEXT: lgf     %r1, 0(%r1,%r7)
75
76## TP offset for b is at 0x23c0
77# PIE-NEXT: lgrl    %r1, 0x23c0
78# PIE-NEXT: lgf     %r1, 0(%r1,%r7)
79
80## TP offset for c is at 0x23c8
81# PIE-NEXT: lgrl    %r1, 0x23c8
82# PIE-NEXT: lgf     %r1, 0(%r1,%r7)
83
84## Data element: TP offset for a is at 0x23b8 (relocated via R_390_RELATIVE above)
85# PIE-DATA: 33d0 00000000 00000000
86
87## TP offsets in GOT:
88# a: -8
89# b: -4
90# c: 0
91# PIE-GOT: 23a0 00000000 000022d0 00000000 00000000
92# PIE-GOT: 23b0 00000000 00000000 ffffffff fffffff8
93# PIE-GOT: 23c0 ffffffff fffffffc 00000000 00000000
94
95ear     %r7,%a0
96sllg    %r7,%r1,32
97ear     %r7,%a1
98
99lgrl    %r1, a@indntpoff
100lgf     %r1,0(%r1,%r7)
101
102lgrl    %r1, b@indntpoff
103lgf     %r1,0(%r1,%r7)
104
105lgrl    %r1, c@indntpoff
106lgf     %r1,0(%r1,%r7)
107
108	.data
109	.reloc .,R_390_TLS_IE64,a
110	.space 8
111
112	.section .tbss
113	.globl a
114	.globl b
115	.globl c
116	.zero 8
117a:
118	.zero 4
119b:
120	.zero 4
121c:
122