[JITLink][RISCV] Handle R_RISCV_CALL_PLT fixups
authorJob Noorman <jnoorman@igalia.com>
Fri, 14 Apr 2023 07:11:08 +0000 (09:11 +0200)
committerJob Noorman <jnoorman@igalia.com>
Fri, 14 Apr 2023 07:11:19 +0000 (09:11 +0200)
In the default link configuration, PLT stubs are created automatically
for R_RISCV_CALL_PLT relocations and the relocation itself is
transformed to R_RISCV_CALL (PerGraphGOTAndPLTStubsBuilder_ELF_riscv).
Only the latter is later handled when applying fixups and the former is
simply ignored.

This patch proposes to handle R_RISCV_CALL_PLT anyway when applying
fixups to support custom configurations that do not need automatic PLT
creation. An example of this is BOLT where PLT entries from the input
binary are reused (D147544).

Reviewed By: StephenFan

Differential Revision: https://reviews.llvm.org/D148238

llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp

index 0622b6e..b636e87 100644 (file)
@@ -229,6 +229,7 @@ private:
           (RawInstr & 0xFFF) | Imm20 | Imm10_1 | Imm11 | Imm19_12;
       break;
     }
+    case R_RISCV_CALL_PLT:
     case R_RISCV_CALL: {
       int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress;
       int64_t Hi = Value + 0x800;