2 # RUN: rm -rf %t && split-file %s %t
4 # RUN: llvm-mc --filetype=obj --triple=loongarch32-unknown-elf %t/a.s -o %t/a.la32.o
5 # RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-elf %t/a.s -o %t/a.la64.o
7 # RUN: ld.lld %t/a.la32.o -shared -T %t/a.t -o %t/a.la32.so
8 # RUN: ld.lld %t/a.la64.o -shared -T %t/a.t -o %t/a.la64.so
10 # RUN: llvm-objdump -d --no-show-raw-insn %t/a.la32.so | FileCheck --check-prefixes=DIS,DIS32 %s
11 # RUN: llvm-objdump -d --no-show-raw-insn %t/a.la64.so | FileCheck --check-prefixes=DIS,DIS64 %s
13 ## PLT should be present in this case.
14 # DIS: Disassembly of section .plt:
16 # DIS: 234020: pcaddu12i $t3, 510
17 # DIS32-NEXT: ld.w $t3, $t3, 84
18 # DIS64-NEXT: ld.d $t3, $t3, 184
19 # DIS-NEXT: jirl $t1, $t3, 0
22 # DIS: Disassembly of section .text:
27 # DIS-NEXT: pcalau12i $t0, -510
28 # DIS-NEXT: jirl $zero, $t0, 32
30 # RUN: llvm-mc --filetype=obj --triple=loongarch32-unknown-elf %t/error.s -o %t/error.la32.o
31 # RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-elf %t/error.s -o %t/error.la64.o
32 # RUN: not ld.lld %t/error.la32.o -shared -o %t/error.la32.so 2>&1 | FileCheck --check-prefix=ERR %s
33 # RUN: not ld.lld %t/error.la64.o -shared -o %t/error.la64.so 2>&1 | FileCheck --check-prefix=ERR %s
34 # ERR: error: relocation R_LARCH_PCALA_LO12 cannot be used against symbol 'bar'; recompile with -fPIC
38 .plt 0x234000: { *(.plt) }
39 .text 0x432000: { *(.text) }
46 ## The nops are for pushing the relocs off page boundary, to better see the
47 ## page-aligned semantics in action.
51 ## The offsets should be -510 (0x234 - 0x432) and 32 (PLT header size + 0)
53 pcalau12i $t0
, %pc_hi20
(bar
)
54 jirl $zero
, $t0
, %pc_lo12
(bar
)
59 pcalau12i $t0
, %pc_hi20
(bar
)
60 ld.w $t0
, $t0
, %pc_lo12
(bar
)