1# RUN: rm -rf %t && mkdir -p %t 2# RUN: llvm-mc -triple=riscv32 -position-independent -filetype=obj \ 3# RUN: -o %t/elf_riscv32_got_plt_reloc.o %s 4# 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_riscv32_got_plt_reloc.o 8 9 .text 10 .file "testcase.c" 11 12# Empty main entry point. 13 .globl main 14 .p2align 1 15 .type main,@function 16main: 17 ret 18 19 .size main, .-main 20# Test R_RISCV_GOT_HI20. The low 12 relocation is R_RISCV_PC_REL_LO12. This test case will 21# check both the offset to the GOT entry and its content. 22# jitlink-check: decode_operand(test_got, 1) = (got_addr(elf_riscv32_got_plt_reloc.o, external_data) - test_got + 0x800)[31:12] 23# jitlink-check: decode_operand(test_got+4, 2)[11:0] = (got_addr(elf_riscv32_got_plt_reloc.o, external_data) - test_got)[11:0] 24# jitlink-check: *{4}(got_addr(elf_riscv32_got_plt_reloc.o, external_data)) = external_data 25 .globl test_got 26 .p2align 1 27 .type test_got,@function 28test_got: 29 auipc a0, %got_pcrel_hi(external_data) 30 lw a0, %pcrel_lo(test_got)(a0) 31 32 .size test_got, .-test_got 33 34# Test R_RISCV_CALL_PLT. 35# jitlink-check: decode_operand(test_plt, 1) = (stub_addr(elf_riscv32_got_plt_reloc.o, external_func) - test_plt + 0x800)[31:12] 36# jitlink-check: decode_operand(test_plt+4, 2) = (stub_addr(elf_riscv32_got_plt_reloc.o, external_func) - test_plt)[11:0] 37# jitlink-check: *{4}(got_addr(elf_riscv32_got_plt_reloc.o, external_func)) = external_func 38 .globl test_plt 39 .p2align 1 40 .type test_got,@function 41test_plt: 42 call external_func@plt 43 44 .size test_plt, .-test_plt 45