3 // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4 // RUN: ld.lld -shared %t.o -o %t.so
5 // RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
6 // RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
7 // RUN: llvm-objdump --section-headers %t.so | FileCheck --check-prefix=CheckGot %s
8 // RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
10 // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
11 // RUN: ld.lld -shared %t.o -o %t.so
12 // RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
13 // RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
14 // RUN: llvm-objdump --section-headers %t.so | FileCheck --check-prefix=CheckGot %s
15 // RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
24 addis 2, 12, .TOC.-.Lfunc_gep0@ha
25 addi 2, 2, .TOC.-.Lfunc_gep0@l
27 .localentry test, .Lfunc_lep0-.Lfunc_gep0
34 addis 3, 2, i@got@tlsgd@ha
35 addi 3, 3, i@got@tlsgd@l
36 bl __tls_get_addr(i@tlsgd)
50 addis 2, 12, .TOC.-.Lfunc_gep1@ha
51 addi 2, 2, .TOC.-.Lfunc_gep1@l
53 .localentry test2, .Lfunc_lep1-.Lfunc_gep1
54 addis 3, 0, j@got@tlsgd@h
59 addis 2, 12, .TOC.-.Lfunc_gep2@ha
60 addi 2, 2, .TOC.-.Lfunc_gep2@l
62 .localentry test16, .Lfunc_lep2-.Lfunc_gep2
63 addi 3, 0, k@got@tlsgd
66 // Verify that the input has every general-dynamic tls relocation type.
67 // InputRelocs: Relocation section '.rela.text'
68 // InputRelocs: R_PPC64_GOT_TLSGD16_HA {{0+}} i + 0
69 // InputRelocs: R_PPC64_GOT_TLSGD16_LO {{0+}} i + 0
70 // InputRelocs: R_PPC64_TLSGD {{0+}} i + 0
71 // InputRelocs: R_PPC64_GOT_TLSGD16_HI {{0+}} j + 0
72 // InputRelocs: R_PPC64_GOT_TLSGD16 {{0+}} k + 0
74 // There is 2 got entries for each tls variable that is accessed with the
75 // general-dynamic model. The entries can be though of as a structure to be
76 // filled in by the dynamic linker:
78 // unsigned long int ti_module; --> R_PPC64_DTPMOD64
79 // unsigned long int ti_offset; --> R_PPC64_DTPREL64
81 // OutputRelocs: Relocation section '.rela.dyn' at offset 0x{{[0-9a-f]+}} contains 6 entries:
82 // OutputRelocs: R_PPC64_DTPMOD64 {{0+}} i + 0
83 // OutputRelocs: R_PPC64_DTPREL64 {{0+}} i + 0
84 // OutputRelocs: R_PPC64_DTPMOD64 {{0+}} j + 0
85 // OutputRelocs: R_PPC64_DTPREL64 {{0+}} j + 0
86 // OutputRelocs: R_PPC64_DTPMOD64 {{0+}} k + 0
87 // OutputRelocs: R_PPC64_DTPREL64 {{0+}} k + 0
89 // Check that the got has 7 entires. (1 for the TOC and 3 structures of
90 // 2 entries for the tls variables). Also verify the address so we can check
91 // the offsets we calculated for each relocation type.
92 // CheckGot: got 00000038 00000000000200f0
94 // got starts at 0x200f0, so .TOC. will be 0x280f0.
96 // We are building the address of the first tls_index in the got which starts at
98 // #ha(i@got@tlsgd) --> (0x200f8 - 0x280f0 + 0x8000) >> 16 = 0
99 // #lo(i@got@tlsgd) --> (0x200f8 - 0x280f0) & 0xFFFF = -7ff8 = -32760
101 // Dis: addis 3, 2, 0
102 // Dis: addi 3, 3, -32760
104 // Second tls_index starts at got[3].
105 // #hi(j@got@tlsgd) --> (0x20108 - 0x280f0) >> 16 = -1
109 // Third tls index is at got[5].
110 // k@got@tlsgd --> (0x20118 - 0x280f0) = -0x7fd8 = -32728