85 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_sm_pic_reloc.o %s4# RUN: llvm-mc -triple=riscv32 -position-independent -filetype=obj \5# RUN: -o %t/elf_riscv32_sm_pic_reloc.o %s6# RUN: llvm-jitlink -noexec \7# RUN: -slab-allocate 100Kb -slab-address 0x1ff00000 -slab-page-size 4096 \8# RUN: -abs external_data=0x2 \9# RUN: -check %s %t/elf_riscv64_sm_pic_reloc.o10# RUN: llvm-jitlink -noexec \11# RUN: -slab-allocate 100Kb -slab-address 0x1ff00000 -slab-page-size 4096 \12# RUN: -abs external_data=0x2 \13# RUN: -check %s %t/elf_riscv32_sm_pic_reloc.o14#15# Test ELF small/PIC relocations16 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 29# Test R_RISCV_PCREL_HI20 and R_RISCV_PCREL_LO30# jitlink-check: decode_operand(test_pcrel32, 1) = ((external_data - test_pcrel32) + 0x800)[31:12]31# jitlink-check: decode_operand(test_pcrel32+4, 2)[11:0] = (external_data - test_pcrel32)[11:0]32 .globl test_pcrel3233 .p2align 134 .type test_pcrel32,@function35test_pcrel32:36 auipc a0, %pcrel_hi(external_data)37 lw a0, %pcrel_lo(test_pcrel32)(a0)38 39 .size test_pcrel32, .-test_pcrel3240 41# Test R_RISCV_PCREL_HI20 and R_RISCV_PCREL_LO12_S42# jitlink-check: decode_operand(test_pcrel32_s, 1) = ((external_data - test_pcrel32_s) + 0x800)[31:12]43# jitlink-check: decode_operand(test_pcrel32_s+4, 2)[11:0] = (external_data - test_pcrel32_s)[11:0]44 .globl test_pcrel32_s45 .p2align 146 .type test_pcrel32_s,@function47test_pcrel32_s:48 auipc a0, %pcrel_hi(external_data)49 sw a0, %pcrel_lo(test_pcrel32_s)(a0)50 51 .size test_pcrel32_s, .-test_pcrel32_s52 53# Test R_RISCV_CALL54# jitlink-check: decode_operand(test_call, 1) = ((internal_func - test_call) + 0x800)[31:12]55# jitlink-check: decode_operand(test_call+4, 2)[11:0] = (internal_func - test_call)[11:0]56 .globl test_call57 .p2align 158 .type test_call,@function59test_call:60 .reloc ., R_RISCV_CALL, internal_func61 auipc ra, 062 jalr ra63 ret64 .size test_call, .-test_call65 66# Test R_RISCV_CALL_PLT67# jitlink-check: decode_operand(test_call_plt, 1) = ((internal_func - test_call_plt) + 0x800)[31:12]68# jitlink-check: decode_operand(test_call_plt+4, 2)[11:0] = (internal_func - test_call_plt)[11:0]69 .globl test_call_plt70 .p2align 171 .type test_call_plt,@function72test_call_plt:73 .reloc ., R_RISCV_CALL_PLT, internal_func74 auipc ra, 075 jalr ra76 ret77 .size test_call_plt, .-test_call_plt78 79 .globl internal_func80 .p2align 181 .type internal_func,@function82internal_func:83 ret84 .size internal_func, .-internal_func85