54 lines · plain
1# RUN: rm -rf %t && mkdir -p %t2# RUN: llvm-mc -triple=riscv64 -position-independent -filetype=obj \3# RUN: -o %t/elf_riscv64_got_plt_reloc.o %s4# RUN: llvm-jitlink -noexec \5# RUN: -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \6# RUN: -abs external_func=0x1 -abs external_data=0x2 \7# RUN: -check %s %t/elf_riscv64_got_plt_reloc.o8 9## Run the same tests with relaxation enabled.10# RUN: llvm-mc -triple=riscv64 -position-independent -filetype=obj \11# RUN: -mattr=+relax -o %t/elf_riscv64_got_plt_reloc.o %s12# RUN: llvm-jitlink -noexec \13# RUN: -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \14# RUN: -abs external_func=0x1 -abs external_data=0x2 \15# RUN: -check %s %t/elf_riscv64_got_plt_reloc.o16 17 .text18 .file "testcase.c"19 20# Empty main entry point.21 .globl main22 .p2align 123 .type main,@function24main:25 ret26 27 .size main, .-main28# Test R_RISCV_GOT_HI20. The low 12 relocation is R_RISCV_PC_REL_LO12. This test case will29# check both the offset to the GOT entry and its content.30# jitlink-check: decode_operand(test_got, 1) = (got_addr(elf_riscv64_got_plt_reloc.o, external_data) - test_got + 0x800)[31:12]31# jitlink-check: decode_operand(test_got+4, 2)[11:0] = (got_addr(elf_riscv64_got_plt_reloc.o, external_data) - test_got)[11:0]32# jitlink-check: *{8}(got_addr(elf_riscv64_got_plt_reloc.o, external_data)) = external_data33 .globl test_got34 .p2align 135 .type test_got,@function36test_got:37 auipc a0, %got_pcrel_hi(external_data)38 ld a0, %pcrel_lo(test_got)(a0)39 40 .size test_got, .-test_got41 42# Test R_RISCV_CALL_PLT.43# jitlink-check: decode_operand(test_plt, 1) = (stub_addr(elf_riscv64_got_plt_reloc.o, external_func) - test_plt + 0x800)[31:12]44# jitlink-check: decode_operand(test_plt+4, 2) = (stub_addr(elf_riscv64_got_plt_reloc.o, external_func) - test_plt)[11:0]45# jitlink-check: *{8}(got_addr(elf_riscv64_got_plt_reloc.o, external_func)) = external_func46 .globl test_plt47 .p2align 148 .type test_got,@function49test_plt:50 call external_func@plt51 52 .size test_plt, .-test_plt53 54