[llvm-branch-commits] [LoongArch] Generate more PCRel relocations for resolvable sub-symbols (PR #211754)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 31 02:01:01 PDT 2026


================
@@ -401,51 +401,31 @@ bool LoongArchAsmBackend::isPCRelFixupResolved(const MCSymbol *SymA,
 void LoongArchAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
                                    const MCValue &Target, uint64_t &FixedValue,
                                    bool IsResolved) {
-  auto Fallback = [&]() {
-    MCAsmBackend::maybeAddReloc(F, Fixup, Target, FixedValue, IsResolved);
+  // If the fixup is in a .dwo section (where relocations are forbidden), we
+  // must resolve the difference directly. The computed Value in evaluateFixup
+  // is correct based on the current layout.
+  if (F.getParent()->getName().ends_with(".dwo"))
----------------
wangleiat wrote:

One more observation: I tried calling `isRangeRelaxable()` from `LoongArchAsmBackend::addReloc()`, but it returns a different result compared with the call from `DwarfCompileUnit::attachLowHighPC()`.

I am not sure whether this is because the fragment information is different at these two stages or because the linker relaxation state is not finalized yet at the point where `attachLowHighPC()` is called.

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


More information about the llvm-branch-commits mailing list