diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp --- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp @@ -322,63 +322,52 @@ case R_RISCV_ADD8: { int64_t Value = (E.getTarget().getAddress() + - *(reinterpret_cast(FixupAddress.getValue())) + - E.getAddend()) + *(reinterpret_cast(FixupPtr)) + E.getAddend()) .getValue(); *FixupPtr = static_cast(Value); break; } case R_RISCV_ADD16: { int64_t Value = (E.getTarget().getAddress() + - support::endian::read16le(reinterpret_cast( - FixupAddress.getValue())) + - E.getAddend()) + support::endian::read16le(FixupPtr) + E.getAddend()) .getValue(); *(little16_t *)FixupPtr = static_cast(Value); break; } case R_RISCV_ADD32: { int64_t Value = (E.getTarget().getAddress() + - support::endian::read32le(reinterpret_cast( - FixupAddress.getValue())) + - E.getAddend()) + support::endian::read32le(FixupPtr) + E.getAddend()) .getValue(); *(little32_t *)FixupPtr = static_cast(Value); break; } case R_RISCV_ADD64: { int64_t Value = (E.getTarget().getAddress() + - support::endian::read64le(reinterpret_cast( - FixupAddress.getValue())) + - E.getAddend()) + support::endian::read64le(FixupPtr) + E.getAddend()) .getValue(); *(little64_t *)FixupPtr = static_cast(Value); break; } case R_RISCV_SUB8: { - int64_t Value = - *(reinterpret_cast(FixupAddress.getValue())) - - E.getTarget().getAddress().getValue() - E.getAddend(); + int64_t Value = *(reinterpret_cast(FixupPtr)) - + E.getTarget().getAddress().getValue() - E.getAddend(); *FixupPtr = static_cast(Value); break; } case R_RISCV_SUB16: { - int64_t Value = support::endian::read16le(reinterpret_cast( - FixupAddress.getValue())) - + int64_t Value = support::endian::read16le(FixupPtr) - E.getTarget().getAddress().getValue() - E.getAddend(); *(little16_t *)FixupPtr = static_cast(Value); break; } case R_RISCV_SUB32: { - int64_t Value = support::endian::read32le(reinterpret_cast( - FixupAddress.getValue())) - + int64_t Value = support::endian::read32le(FixupPtr) - E.getTarget().getAddress().getValue() - E.getAddend(); *(little32_t *)FixupPtr = static_cast(Value); break; } case R_RISCV_SUB64: { - int64_t Value = support::endian::read64le(reinterpret_cast( - FixupAddress.getValue())) - + int64_t Value = support::endian::read64le(FixupPtr) - E.getTarget().getAddress().getValue() - E.getAddend(); *(little64_t *)FixupPtr = static_cast(Value); break; @@ -419,8 +408,7 @@ break; } case R_RISCV_SUB6: { - int64_t Value = - *(reinterpret_cast(FixupAddress.getValue())) & 0x3f; + int64_t Value = *(reinterpret_cast(FixupPtr)) & 0x3f; Value -= E.getTarget().getAddress().getValue() - E.getAddend(); *FixupPtr = (*FixupPtr & 0xc0) | (static_cast(Value) & 0x3f); break; diff --git a/llvm/test/ExecutionEngine/JITLink/RISCV/riscv_reloc_add.s b/llvm/test/ExecutionEngine/JITLink/RISCV/riscv_reloc_add.s --- a/llvm/test/ExecutionEngine/JITLink/RISCV/riscv_reloc_add.s +++ b/llvm/test/ExecutionEngine/JITLink/RISCV/riscv_reloc_add.s @@ -1,8 +1,10 @@ # RUN: rm -rf %t && mkdir -p %t # RUN: llvm-mc -triple=riscv64 -filetype=obj -o %t/riscv64_reloc_add.o %s # RUN: llvm-mc -triple=riscv32 -filetype=obj -o %t/riscv32_reloc_add.o %s -# RUN: llvm-jitlink -noexec -check %s %t/riscv64_reloc_add.o -# RUN: llvm-jitlink -noexec -check %s %t/riscv32_reloc_add.o +# RUN: llvm-jitlink -noexec -check %s %t/riscv64_reloc_add.o \ +# RUN: -slab-allocate=1Mb -slab-address=0x1000 -slab-page-size=0x1000 +# RUN: llvm-jitlink -noexec -check %s %t/riscv32_reloc_add.o \ +# RUN: -slab-allocate=1Mb -slab-address=0x1000 -slab-page-size=0x1000 # jitlink-check: *{8}(named_data) = 0x8 # jitlink-check: *{4}(named_data+8) = 0x8