61 lines · plain
1# REQUIRES: loongarch2# RUN: rm -rf %t && split-file %s %t3 4# RUN: llvm-mc --filetype=obj --triple=loongarch32-unknown-elf %t/a.s -o %t/a.la32.o5# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-elf %t/a.s -o %t/a.la64.o6 7# RUN: ld.lld %t/a.la32.o -shared -T %t/a.t -o %t/a.la32.so8# RUN: ld.lld %t/a.la64.o -shared -T %t/a.t -o %t/a.la64.so9 10# RUN: llvm-objdump -d --no-show-raw-insn %t/a.la32.so | FileCheck --check-prefixes=DIS,DIS32 %s11# RUN: llvm-objdump -d --no-show-raw-insn %t/a.la64.so | FileCheck --check-prefixes=DIS,DIS64 %s12 13## PLT should be present in this case.14# DIS: Disassembly of section .plt:15# DIS: <.plt>:16# DIS: 234020: pcaddu12i $t3, 51017# DIS32-NEXT: ld.w $t3, $t3, 8418# DIS64-NEXT: ld.d $t3, $t3, 18419# DIS-NEXT: jirl $t1, $t3, 020# DIS-NEXT: nop21 22# DIS: Disassembly of section .text:23# DIS: <foo>:24# DIS-NEXT: nop25# DIS-NEXT: nop26# DIS-NEXT: nop27# DIS-NEXT: pcalau12i $t0, -51028# DIS-NEXT: jirl $zero, $t0, 3229 30# RUN: llvm-mc --filetype=obj --triple=loongarch32-unknown-elf %t/error.s -o %t/error.la32.o31# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-elf %t/error.s -o %t/error.la64.o32# RUN: not ld.lld %t/error.la32.o -shared -o %t/error.la32.so 2>&1 | FileCheck --check-prefix=ERR %s33# RUN: not ld.lld %t/error.la64.o -shared -o %t/error.la64.so 2>&1 | FileCheck --check-prefix=ERR %s34# ERR: error: relocation R_LARCH_PCALA_LO12 cannot be used against symbol 'bar'; recompile with -fPIC35 36#--- a.t37SECTIONS {38 .plt 0x234000: { *(.plt) }39 .text 0x432000: { *(.text) }40}41 42#--- a.s43.p2align 1244.global foo45foo:46## The nops are for pushing the relocs off page boundary, to better see the47## page-aligned semantics in action.48 nop49 nop50 nop51 ## 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)55 56#--- error.s57.global foo58foo:59 pcalau12i $t0, %pc_hi20(bar)60 ld.w $t0, $t0, %pc_lo12(bar)61