[llvm] 4752787 - [JITLink][RISCV] Handle R_RISCV_CALL_PLT fixups

Job Noorman via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 14 00:11:59 PDT 2023


Author: Job Noorman
Date: 2023-04-14T09:11:19+02:00
New Revision: 4752787cc3d9c0e4ffb9ed6962aeccc5486137cc

URL: https://github.com/llvm/llvm-project/commit/4752787cc3d9c0e4ffb9ed6962aeccc5486137cc
DIFF: https://github.com/llvm/llvm-project/commit/4752787cc3d9c0e4ffb9ed6962aeccc5486137cc.diff

LOG: [JITLink][RISCV] Handle R_RISCV_CALL_PLT fixups

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

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
index 0622b6e307a9d..b636e87423425 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -229,6 +229,7 @@ class ELFJITLinker_riscv : public JITLinker<ELFJITLinker_riscv> {
           (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;


        


More information about the llvm-commits mailing list