[llvm] [BOLT][RISCV] Handle static IFUNC calls through .iplt (PR #207733)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 00:09:14 PDT 2026


================
@@ -1886,11 +1949,16 @@ void RewriteInstance::createPLTBinaryFunction(uint64_t TargetAddress,
 
   MCSymbol *Symbol = Rel->Symbol;
   if (!Symbol) {
-    if (BC->isRISCV() || !Rel->Addend || !Rel->isIRelative())
+    if (!Rel->Addend || !Rel->isIRelative())
       return;
 
-    // IFUNC trampoline without symbol
+    // IFUNC trampoline without symbol. The existing x86 and AArch64 paths
+    // require the resolver to start a BinaryFunction. For RISC-V, deferred
+    // .iplt processing also permits the exact secondary entry registered
+    // above, which getBinaryFunctionAtAddress() does not return.
     BinaryFunction *TargetBF = BC->getBinaryFunctionAtAddress(Rel->Addend);
+    if (!TargetBF && BC->isRISCV())
+      TargetBF = BC->getBinaryFunctionContainingAddress(Rel->Addend);
----------------
kito-cheng wrote:

Do we still need this if we already create BinaryFunction for ifunc resolver correctly? 

https://github.com/llvm/llvm-project/pull/207733


More information about the llvm-commits mailing list