2 # RUN: split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
4 # RUN: ld.lld -T %t/lds --shared -soname=t-ld %t.o -o %t-ld.so
5 # RUN: ld.lld -T %t/lds %t.o -o %t-ldtole
7 # RUN: llvm-readelf -r %t-ld.so | FileCheck %s --check-prefix=LD-RELOC
8 # RUN: llvm-readelf -s %t-ld.so | FileCheck %s --check-prefix=LD-SYM
9 # RUN: llvm-readelf -x .got %t-ld.so | FileCheck %s --check-prefix=LD-GOT
10 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t-ld.so | FileCheck %s --check-prefix=LD
12 # RUN: llvm-readelf -r %t-ldtole | FileCheck %s --check-prefix=LDTOLE-RELOC
13 # RUN: llvm-readelf -s %t-ldtole | FileCheck %s --check-prefix=LDTOLE-SYM
14 # RUN: llvm-readelf -x .got %t-ldtole 2>&1 | FileCheck %s --check-prefix=LDTOLE-GOT
15 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t-ldtole | FileCheck %s --check-prefix=LDTOLE
17 ## This test checks the Local Dynamic PC Relative TLS implementation for lld.
18 ## LD - Local Dynamic with no relaxation possible
19 ## LDTOLE - Local Dynamic relaxed to Local Exec
21 # LD-RELOC: Relocation section '.rela.dyn' at offset 0x10080 contains 1 entries:
22 # LD-RELOC: 0000000001004168 0000000000000044 R_PPC64_DTPMOD64 0
24 # LD-SYM: Symbol table '.symtab' contains 11 entries:
25 # LD-SYM: 0000000000000000 0 TLS LOCAL DEFAULT 13 x
26 # LD-SYM: 0000000000000004 0 TLS LOCAL DEFAULT 13 y
28 # LD-GOT: section '.got':
29 # LD-GOT-NEXT: 0x01004160 60c10001 00000000 00000000 00000000
30 # LD-GOT-NEXT: 0x01004170 00000000 00000000
32 # LDTOLE-RELOC: There are no relocations in this file.
34 # LDTOLE-SYM: Symbol table '.symtab' contains 9 entries:
35 # LDTOLE-SYM: 0000000000000000 0 TLS LOCAL DEFAULT 6 x
36 # LDTOLE-SYM: 0000000000000004 0 TLS LOCAL DEFAULT 6 y
38 # LDTOLE-GOT: section '.got':
39 # LDTOLE-GOT-NEXT: 0x01004020 20c00001 00000000
43 .text_addr 0x1001000 : { *(.text_addr) }
44 .text_val 0x1002000 : { *(.text_val) }
45 .text_twoval 0x1003000 : { *(.text_twoval) }
46 .text_incrval 0x1004000 : { *(.text_incrval) }
51 # LD: paddi 3, 0, 12644, 1
52 # LD-NEXT: bl 0x1001020
53 # LD-NEXT: paddi 3, 3, -32768, 0
55 # LDTOLE-LABEL: <LDAddr>:
56 # LDTOLE: paddi 3, 13, 4096, 0
58 # LDTOLE-NEXT: paddi 3, 3, -32768, 0
60 .section .text_addr, "ax", %progbits
62 ## TODO: Adding a reference to .TOC. since LLD doesn't gracefully handle the
63 ## case where we define a .got section but have no references to the toc base
65 addis 2, 12, .TOC.-LDAddr@ha
66 paddi
3, 0, x@got@tlsld@pcrel
, 1
67 bl __tls_get_addr@notoc
(x@tlsld
)
68 paddi
3, 3, x@dtprel
, 0
72 # LD: paddi 3, 0, 8552, 1
73 # LD-NEXT: bl 0x1001020
74 # LD-NEXT: paddi 3, 3, -32768, 0
75 # LD-NEXT: lwz 3, 0(3)
77 # LDTOLE-LABEL: <LDVal>:
78 # LDTOLE: paddi 3, 13, 4096, 0
80 # LDTOLE-NEXT: paddi 3, 3, -32768, 0
81 # LDTOLE-NEXT: lwz 3, 0(3)
83 .section .text_val, "ax", %progbits
85 paddi
3, 0, x@got@tlsld@pcrel
, 1
86 bl __tls_get_addr@notoc
(x@tlsld
)
87 paddi
3, 3, x@dtprel
, 0
91 # LD-LABEL: <LDTwoVal>:
92 # LD: paddi 3, 0, 4456, 1
93 # LD-NEXT: bl 0x1001020
94 # LD-NEXT: paddi 3, 3, -32768, 0
95 # LD-NEXT: lwz 2, 0(3)
96 # LD-NEXT: paddi 3, 3, -32764, 0
97 # LD-NEXT: lwz 3, 0(3)
99 # LDTOLE-LABEL: <LDTwoVal>:
100 # LDTOLE: paddi 3, 13, 4096, 0
102 # LDTOLE-NEXT: paddi 3, 3, -32768, 0
103 # LDTOLE-NEXT: lwz 2, 0(3)
104 # LDTOLE-NEXT: paddi 3, 3, -32764, 0
105 # LDTOLE-NEXT: lwz 3, 0(3)
107 .section .text_twoval, "ax", %progbits
109 paddi
3, 0, x@got@tlsld@pcrel
, 1
110 bl __tls_get_addr@notoc
(x@tlsld
)
111 paddi
3, 3, x@dtprel
, 0
113 paddi
3, 3, y@dtprel
, 0
117 # LD-LABEL: <LDIncrementVal>:
118 # LD: paddi 3, 0, 360, 1
119 # LD-NEXT: bl 0x1001020
120 # LD-NEXT: paddi 9, 3, -32764, 0
121 # LD-NEXT: lwz 4, 0(9)
122 # LD-NEXT: stw 5, 0(9)
124 # LDTOLE-LABEL: <LDIncrementVal>:
125 # LDTOLE: paddi 3, 13, 4096, 0
127 # LDTOLE-NEXT: paddi 9, 3, -32764, 0
128 # LDTOLE-NEXT: lwz 4, 0(9)
129 # LDTOLE-NEXT: stw 5, 0(9)
131 .section .text_incrval, "ax", %progbits
133 paddi
3, 0, y@got@tlsld@pcrel
, 1
134 bl __tls_get_addr@notoc
(y@tlsld
)
135 paddi
9, 3, y@dtprel
, 0
140 .section .tbss,"awT",@nobits