[llvm] [RISCV] Vendor Relocations for Xqci extension (PR #135400)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat May 17 10:24:06 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,
----------------
MaskRay wrote:
Cc @jrtc27 who introduced `evaluateTargetFixup`
Currently, the MCFixupKindInfo::FKF_IsTarget code path in MCAssembler.cpp skips the common code paths (getAddSym/getSubSym), because PCREL_LO12[IS] don't need them.
Now evaluateTargetFixup is reused by QUIC relocations, leading to some duplication. I think we can make evaluateTargetFixup return more information so that QUIC relocations keep reusing the common code path.
```cpp
if (FixupFlags & MCFixupKindInfo::FKF_IsTarget) {
IsResolved =
getBackend().evaluateTargetFixup(*this, Fixup, DF, Target, STI, Value);
} else {
const MCSymbol *Add = Target.getAddSym(); 7 refs
const MCSymbol *Sub = Target.getSubSym();
```
The latter half of the duplication that adds a R_RISCV_VENDOR relocation can probably be refactored to reuse `Type = TargetObjectWriter->getRelocType(Ctx, Target, Fixup, IsPCRel);`
https://github.com/llvm/llvm-project/pull/135400
More information about the llvm-commits
mailing list