2 # RUN: rm -rf %t && split-file %s %t
4 # RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent %t/a.s -o %t/a.32.o
5 # RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/tga.s -o %t/tga.32.o
6 # RUN: llvm-mc --filetype=obj --triple=loongarch64 --position-independent %t/a.s -o %t/a.64.o
7 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/tga.s -o %t/tga.64.o
10 # RUN: ld.lld -shared %t/a.32.o -o %t/ld.32.so
11 # RUN: llvm-readobj -r %t/ld.32.so | FileCheck --check-prefix=LD32-REL %s
12 # RUN: llvm-readelf -x .got %t/ld.32.so | FileCheck --check-prefix=LD32-GOT %s
13 # RUN: llvm-objdump -d --no-show-raw-insn %t/ld.32.so | FileCheck --check-prefixes=LD32 %s
16 # RUN: ld.lld %t/a.32.o %t/tga.32.o -o %t/le.32
17 # RUN: llvm-readelf -r %t/le.32 | FileCheck --check-prefix=NOREL %s
18 # RUN: llvm-readelf -x .got %t/le.32 | FileCheck --check-prefix=LE32-GOT %s
19 # RUN: llvm-objdump -d --no-show-raw-insn %t/le.32 | FileCheck --check-prefixes=LE32 %s
22 # RUN: ld.lld -shared %t/a.64.o -o %t/ld.64.so
23 # RUN: llvm-readobj -r %t/ld.64.so | FileCheck --check-prefix=LD64-REL %s
24 # RUN: llvm-readelf -x .got %t/ld.64.so | FileCheck --check-prefix=LD64-GOT %s
25 # RUN: llvm-objdump -d --no-show-raw-insn %t/ld.64.so | FileCheck --check-prefixes=LD64 %s
28 # RUN: ld.lld %t/a.64.o %t/tga.64.o -o %t/le.64
29 # RUN: llvm-readelf -r %t/le.64 | FileCheck --check-prefix=NOREL %s
30 # RUN: llvm-readelf -x .got %t/le.64 | FileCheck --check-prefix=LE64-GOT %s
31 # RUN: llvm-objdump -d --no-show-raw-insn %t/le.64 | FileCheck --check-prefixes=LE64 %s
33 ## a@dtprel = st_value(a) = 0 is a link-time constant.
34 # LD32-REL: .rela.dyn {
35 # LD32-REL-NEXT: 0x20280 R_LARCH_TLS_DTPMOD32 - 0x0
37 # LD32-GOT: section '.got':
38 # LD32-GOT-NEXT: 0x00020280 00000000 00000000
40 # LD64-REL: .rela.dyn {
41 # LD64-REL-NEXT: 0x20400 R_LARCH_TLS_DTPMOD64 - 0x0
43 # LD64-GOT: section '.got':
44 # LD64-GOT-NEXT: 0x00020400 00000000 00000000 00000000 00000000
46 ## LA32: &DTPMOD(a) - . = 0x20280 - 0x101cc = 16429<<2
47 # LD32: 101cc: pcaddi $a0, 16429
50 ## LA64: &DTPMOD(a) - . = 0x20400 - 0x102e0 = 16456<<2
51 # LD64: 102e0: pcaddi $a0, 16456
54 # NOREL: no relocations
56 ## a is local - its DTPMOD/DTPREL slots are link-time constants.
57 ## a@dtpmod = 1 (main module)
58 # LE32-GOT: section '.got':
59 # LE32-GOT-NEXT: 0x0003011c 01000000 00000000
61 # LE64-GOT: section '.got':
62 # LE64-GOT-NEXT: 0x000301d0 01000000 00000000 00000000 00000000
64 ## LA32: DTPMOD(.LANCHOR0) - . = 0x3011c - 0x20114 = 16386<<2
65 # LE32: 20114: pcaddi $a0, 16386
68 ## LA64: DTPMOD(.LANCHOR0) - . = 0x301d0 - 0x201c8 = 16386<<2
69 # LE64: 201c8: pcaddi $a0, 16386
73 pcaddi $a0
, %ld_pcrel_20
(.LANCHOR0)
74 bl %plt
(__tls_get_addr
)
76 .section .tbss,"awT",@nobits