[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:35:21 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:

With further debugging, I found that the difference comes from the timing of when `isRangeRelaxable()` is called.

After `DwarfCompileUnit::attachLowHighPC()`, `layoutSection->relaxAlign()` is executed. During this step, fragments may be marked as `linker-relaxable` based on alignment requirements.

Therefore, when calling `isRangeRelaxable()` from `attachLowHighPC()`, some fragments have not been marked as linker-relaxable yet.

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


More information about the llvm-branch-commits mailing list