[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / loongarch-pcala-lo12-jirl-shared.s
blob991f8fbe974f45c86303c135572ddf94b2381cc9
1 # REQUIRES: loongarch
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:
15 # DIS: <.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
20 # DIS-NEXT: nop
22 # DIS: Disassembly of section .text:
23 # DIS: <foo>:
24 # DIS-NEXT: nop
25 # DIS-NEXT: nop
26 # DIS-NEXT: nop
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
36 #--- a.t
37 SECTIONS {
38 .plt 0x234000: { *(.plt) }
39 .text 0x432000: { *(.text) }
42 #--- a.s
43 .p2align 12
44 .global foo
45 foo:
46 ## The nops are for pushing the relocs off page boundary, to better see the
47 ## page-aligned semantics in action.
48 nop
49 nop
50 nop
51 ## The offsets should be -510 (0x234 - 0x432) and 32 (PLT header size + 0)
52 ## respectively.
53 pcalau12i $t0, %pc_hi20(bar)
54 jirl $zero, $t0, %pc_lo12(bar)
56 #--- error.s
57 .global foo
58 foo:
59 pcalau12i $t0, %pc_hi20(bar)
60 ld.w $t0, $t0, %pc_lo12(bar)