2 # RUN: rm -rf %t && split-file %s %t
4 ## LoongArch psABI doesn't specify TLS relaxation. Though the code sequences are not
5 ## relaxed, dynamic relocations can be omitted for LD->LE relaxation.
7 # RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent %t/a.s -o %t/a.32.o
8 # RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/tga.s -o %t/tga.32.o
9 # RUN: llvm-mc --filetype=obj --triple=loongarch64 --position-independent %t/a.s -o %t/a.64.o
10 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/tga.s -o %t/tga.64.o
13 # RUN: ld.lld -shared %t/a.32.o -o %t/ld.32.so
14 # RUN: llvm-readobj -r %t/ld.32.so | FileCheck --check-prefix=LD32-REL %s
15 # RUN: llvm-readelf -x .got %t/ld.32.so | FileCheck --check-prefix=LD32-GOT %s
16 # RUN: llvm-objdump -d --no-show-raw-insn %t/ld.32.so | FileCheck --check-prefixes=LD32 %s
19 # RUN: ld.lld %t/a.32.o %t/tga.32.o -o %t/le.32
20 # RUN: llvm-readelf -r %t/le.32 | FileCheck --check-prefix=NOREL %s
21 # RUN: llvm-readelf -x .got %t/le.32 | FileCheck --check-prefix=LE32-GOT %s
22 # RUN: llvm-objdump -d --no-show-raw-insn %t/le.32 | FileCheck --check-prefixes=LE32 %s
25 # RUN: ld.lld -shared %t/a.64.o -o %t/ld.64.so
26 # RUN: llvm-readobj -r %t/ld.64.so | FileCheck --check-prefix=LD64-REL %s
27 # RUN: llvm-readelf -x .got %t/ld.64.so | FileCheck --check-prefix=LD64-GOT %s
28 # RUN: llvm-objdump -d --no-show-raw-insn %t/ld.64.so | FileCheck --check-prefixes=LD64 %s
31 # RUN: ld.lld %t/a.64.o %t/tga.64.o -o %t/le.64
32 # RUN: llvm-readelf -r %t/le.64 | FileCheck --check-prefix=NOREL %s
33 # RUN: llvm-readelf -x .got %t/le.64 | FileCheck --check-prefix=LE64-GOT %s
34 # RUN: llvm-objdump -d --no-show-raw-insn %t/le.64 | FileCheck --check-prefixes=LE64 %s
36 ## a@dtprel = st_value(a) = 0 is a link-time constant.
37 # LD32-REL: .rela.dyn {
38 # LD32-REL-NEXT: 0x20280 R_LARCH_TLS_DTPMOD32 - 0x0
40 # LD32-GOT: section '.got':
41 # LD32-GOT-NEXT: 0x00020280 00000000 00000000
43 # LD64-REL: .rela.dyn {
44 # LD64-REL-NEXT: 0x20400 R_LARCH_TLS_DTPMOD64 - 0x0
46 # LD64-GOT: section '.got':
47 # LD64-GOT-NEXT: 0x00020400 00000000 00000000 00000000 00000000
49 ## LA32: &DTPMOD(a) - . = 0x20280 - 0x101cc: 0x10 pages, page offset 0x280
50 # LD32: 101cc: pcalau12i $a0, 16
51 # LD32-NEXT: addi.w $a0, $a0, 640
54 ## LA64: &DTPMOD(a) - . = 0x20400 - 0x102e0: 0x10 pages, page offset 0x400
55 # LD64: 102e0: pcalau12i $a0, 16
56 # LD64-NEXT: addi.d $a0, $a0, 1024
59 # NOREL: no relocations
61 ## a is local - its DTPMOD/DTPREL slots are link-time constants.
62 ## a@dtpmod = 1 (main module)
63 # LE32-GOT: section '.got':
64 # LE32-GOT-NEXT: 0x00030120 01000000 00000000
66 # LE64-GOT: section '.got':
67 # LE64-GOT-NEXT: 0x000301d8 01000000 00000000 00000000 00000000
69 ## LA32: DTPMOD(.LANCHOR0) - . = 0x30120 - 0x20114: 0x10 pages, page offset 0x120
70 # LE32: 20114: pcalau12i $a0, 16
71 # LE32-NEXT: addi.w $a0, $a0, 288
74 ## LA64: DTPMOD(.LANCHOR0) - . = 0x301d8 - 0x201c8: 0x10 pages, page offset 0x1d8
75 # LE64: 201c8: pcalau12i $a0, 16
76 # LE64-NEXT: addi.d $a0, $a0, 472
80 la.tls.
ld $a0
, .LANCHOR0
81 bl %plt
(__tls_get_addr
)
83 .section .tbss,"awT",@nobits