[llvm] [RISCV] Add support for vendor relocations on Xqci extensions (PR #135400)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 13 10:18:07 PDT 2025


================
@@ -1435,6 +1435,21 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
                         : C;
   FixedValue = usesRela(TO, FixupSection) ? 0 : Addend;
 
+  // Some RISC-V relocations need a marker relocation that appears before the
+  // relocation in question.
+  unsigned PreRelocType;
+  MCSymbol *PreRelocSymbol;
+  uint64_t PreRelocAddend;
+  if (Backend.fixupNeedsMarkerELFRelocation(Asm, *Fragment, Fixup, PreRelocType,
----------------
lenary wrote:

> I think we should refrain from adding new hooks.

I do too, but "refrain from" doesn't mean "never". We could not find another way to accomplish this.

> Or the hook is here because in some scenarios the fixup can be resolved and you don't want to add a redundant marker?

This. For instance, branches can be evaluated when not relaxing.

>From my comment, above:
> We didn't want a separate fixup (as for Relaxation) because we didn't want to emit the R_RISCV_VENDOR relocation if the fixup could be evaluated/applied by the compiler, and that kind of "evaluating one fixup deletes another fixup" seemed complex and error-prone.

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


More information about the llvm-commits mailing list