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

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 20:23:18 PDT 2026


================
@@ -2778,7 +2854,13 @@ bool RewriteInstance::analyzeRelocation(
     // Section symbols are marked as ST_Debug.
     IsSectionRelocation = (cantFail(Symbol.getType()) == SymbolRef::ST_Debug);
     // Check for PLT entry registered with symbol name
-    if (!SymbolAddress && !IsWeakReference(Symbol) &&
+    // LLD may give a defined RISC-V IFUNC symbol the .iplt entry address.
+    // R_RISCV_CALL_PLT must still resolve it through the registered @PLT
+    // BinaryData instead of treating that symbol value as a normal function.
+    const bool IsRISCVIFuncPLT =
+        BC->isRISCV() && RType == ELF::R_RISCV_CALL_PLT &&
+        ELFSymbolRef(Symbol).getELFType() == ELF::STT_GNU_IFUNC;
+    if ((!SymbolAddress || IsRISCVIFuncPLT) && !IsWeakReference(Symbol) &&
         (IsAArch64 || BC->isRISCV())) {
----------------
kito-cheng wrote:


declare `bool IsRISCV = BC->isRISCV();` and then

```suggestion
    const bool IsRISCVIFuncPLT =
        IsRISCV && RType == ELF::R_RISCV_CALL_PLT &&
        ELFSymbolRef(Symbol).getELFType() == ELF::STT_GNU_IFUNC;
    if ((!SymbolAddress || IsRISCVIFuncPLT) && !IsWeakReference(Symbol) &&
(IsAArch64 || IsRISCV)) {
```

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


More information about the llvm-commits mailing list