[lld] [lld] Add infrastructure for handling RISCV vendor-specific relocations. (PR #159987)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 21:21:45 PDT 2025


================
@@ -1510,13 +1511,25 @@ void RelocationScanner::scanOne(typename Relocs<RelTy>::const_iterator &i) {
       ++i;
     }
   }
+
+  // Stash the RISCV vendor namespace for the subsequent relocation.
+  if (LLVM_UNLIKELY(ctx.arg.emachine == EM_RISCV && type == R_RISCV_VENDOR)) {
+    rv_vendor = sym.getName();
+    return;
+  }
+
   // Get an offset in an output section this relocation is applied to.
   uint64_t offset = getter.get(ctx, rel.r_offset);
   if (offset == uint64_t(-1))
     return;
 
-  RelExpr expr =
-      ctx.target->getRelExpr(type, sym, sec->content().data() + offset);
+  RelExpr expr;
+  if (rv_vendor.empty()) {
----------------
lenary wrote:

Maybe you want `LLVM_LIKELY` on this condition? Like you have an `LLVM_UNLIKELY` on the related one. I don't know if LLVM will spot the correlation.

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


More information about the llvm-commits mailing list