126 lines · plain
1# REQUIRES: loongarch2# RUN: rm -rf %t && split-file %s %t3 4## LoongArch psABI doesn't specify TLS relaxation. It can be handled the same way as gcc:5## (a) code sequence can be converted from `pcalau12i+addi.[wd]` to `pcaddi`.6## (b) dynamic relocations can be omitted for LD->LE relaxation.7 8# RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent %t/a.s -o %t/a.32.o9# RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent -mattr=+relax %t/a.s -o %t/a.32.relax.o10# RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/tga.s -o %t/tga.32.o11# RUN: llvm-mc --filetype=obj --triple=loongarch64 --position-independent %t/a.s -o %t/a.64.o12# RUN: llvm-mc --filetype=obj --triple=loongarch64 --position-independent -mattr=+relax %t/a.s -o %t/a.64.relax.o13# RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/tga.s -o %t/tga.64.o14 15## LA32 LD16# RUN: ld.lld -shared %t/a.32.o -o %t/ld.32.so17# RUN: llvm-readobj -r %t/ld.32.so | FileCheck --check-prefix=LD32-REL %s18# RUN: llvm-readelf -x .got %t/ld.32.so | FileCheck --check-prefix=LD32-GOT %s19# RUN: llvm-objdump -d --no-show-raw-insn %t/ld.32.so | FileCheck --check-prefixes=LD32 %s20# RUN: ld.lld -shared %t/a.32.relax.o -o %t/ld.32.relax.so21# RUN: llvm-objdump -d --no-show-raw-insn %t/ld.32.relax.so | FileCheck --check-prefixes=LD32-RELAX %s22 23## LA32 LD -> LE24# RUN: ld.lld %t/a.32.o %t/tga.32.o -o %t/le.3225# RUN: llvm-readelf -r %t/le.32 | FileCheck --check-prefix=NOREL %s26# RUN: llvm-readelf -x .got %t/le.32 | FileCheck --check-prefix=LE32-GOT %s27# RUN: llvm-objdump -d --no-show-raw-insn %t/le.32 | FileCheck --check-prefixes=LE32 %s28# RUN: ld.lld %t/a.32.relax.o %t/tga.32.o -o %t/le.32.relax29# RUN: llvm-readelf -x .got %t/le.32.relax | FileCheck --check-prefix=LE32-GOT-RELAX %s30# RUN: llvm-objdump -d --no-show-raw-insn %t/le.32.relax | FileCheck --check-prefixes=LE32-RELAX %s31 32## LA64 LD33# RUN: ld.lld -shared %t/a.64.o -o %t/ld.64.so34# RUN: llvm-readobj -r %t/ld.64.so | FileCheck --check-prefix=LD64-REL %s35# RUN: llvm-readelf -x .got %t/ld.64.so | FileCheck --check-prefix=LD64-GOT %s36# RUN: llvm-objdump -d --no-show-raw-insn %t/ld.64.so | FileCheck --check-prefixes=LD64 %s37# RUN: ld.lld -shared %t/a.64.relax.o -o %t/ld.64.relax.so38# RUN: llvm-objdump -d --no-show-raw-insn %t/ld.64.relax.so | FileCheck --check-prefixes=LD64-RELAX %s39 40## LA64 LD -> LE41# RUN: ld.lld %t/a.64.o %t/tga.64.o -o %t/le.6442# RUN: llvm-readelf -r %t/le.64 | FileCheck --check-prefix=NOREL %s43# RUN: llvm-readelf -x .got %t/le.64 | FileCheck --check-prefix=LE64-GOT %s44# RUN: llvm-objdump -d --no-show-raw-insn %t/le.64 | FileCheck --check-prefixes=LE64 %s45# RUN: ld.lld %t/a.64.relax.o %t/tga.64.o -o %t/le.64.relax46# RUN: llvm-readelf -x .got %t/le.64.relax | FileCheck --check-prefix=LE64-GOT-RELAX %s47# RUN: llvm-objdump -d --no-show-raw-insn %t/le.64.relax | FileCheck --check-prefixes=LE64-RELAX %s48 49## a@dtprel = st_value(a) = 0 is a link-time constant.50# LD32-REL: .rela.dyn {51# LD32-REL-NEXT: 0x20280 R_LARCH_TLS_DTPMOD32 - 0x052# LD32-REL-NEXT: }53# LD32-GOT: section '.got':54# LD32-GOT-NEXT: 0x00020280 00000000 0000000055 56# LD64-REL: .rela.dyn {57# LD64-REL-NEXT: 0x20400 R_LARCH_TLS_DTPMOD64 - 0x058# LD64-REL-NEXT: }59# LD64-GOT: section '.got':60# LD64-GOT-NEXT: 0x00020400 00000000 00000000 00000000 0000000061 62## LA32: &DTPMOD(a) - . = 0x20280 - 0x101cc: 0x10 pages, page offset 0x28063# LD32: 101cc: pcalau12i $a0, 1664# LD32-NEXT: addi.w $a0, $a0, 64065# LD32-NEXT: bl 4466 67## LA64: &DTPMOD(a) - . = 0x20400 - 0x102e0: 0x10 pages, page offset 0x40068# LD64: 102e0: pcalau12i $a0, 1669# LD64-NEXT: addi.d $a0, $a0, 102470# LD64-NEXT: bl 4071 72## LA32: &DTPMOD(a) - . = 0x20280 - 0x101cc = 16429<<273# LD32-RELAX: 101cc: pcaddi $a0, 1642974# LD32-RELAX-NEXT: bl 4875 76## LA64: &DTPMOD(a) - . = 0x20400 - 0x102e0 = 16456<<277# LD64-RELAX: 102e0: pcaddi $a0, 1645678# LD64-RELAX-NEXT: bl 4479 80# NOREL: no relocations81 82## a is local - its DTPMOD/DTPREL slots are link-time constants.83## a@dtpmod = 1 (main module)84# LE32-GOT: section '.got':85# LE32-GOT-NEXT: 0x00030120 01000000 0000000086 87# LE64-GOT: section '.got':88# LE64-GOT-NEXT: 0x000301d8 01000000 00000000 00000000 0000000089 90# LE32-GOT-RELAX: section '.got':91# LE32-GOT-RELAX-NEXT: 0x0003011c 01000000 0000000092 93# LE64-GOT-RELAX: section '.got':94# LE64-GOT-RELAX-NEXT: 0x000301d0 01000000 00000000 00000000 0000000095 96## LA32: DTPMOD(.LANCHOR0) - . = 0x30120 - 0x20114: 0x10 pages, page offset 0x12097# LE32: 20114: pcalau12i $a0, 1698# LE32-NEXT: addi.w $a0, $a0, 28899# LE32-NEXT: bl 4100 101## LA64: DTPMOD(.LANCHOR0) - . = 0x301d8 - 0x201c8: 0x10 pages, page offset 0x1d8102# LE64: 201c8: pcalau12i $a0, 16103# LE64-NEXT: addi.d $a0, $a0, 472104# LE64-NEXT: bl 4105 106## LA32: DTPMOD(.LANCHOR0) - . = 0x3011c - 0x20114 = 16386<<2107# LE32-RELAX: 20114: pcaddi $a0, 16386108# LE32-RELAX-NEXT: bl 4109 110## LA64: DTPMOD(.LANCHOR0) - . = 0x301d0 - 0x201c8 = 16386<<2111# LE64-RELAX: 201c8: pcaddi $a0, 16386112# LE64-RELAX-NEXT: bl 4113 114 115#--- a.s116la.tls.ld $a0, .LANCHOR0117bl %plt(__tls_get_addr)118 119.section .tbss,"awT",@nobits120.set .LANCHOR0, . + 0121.zero 8122 123#--- tga.s124.globl __tls_get_addr125__tls_get_addr:126