[llvm] [LoongArch] Allow difference across sections (PR #141722)

Jinyang He via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 02:26:10 PDT 2025


================
@@ -447,19 +447,16 @@ bool LoongArchAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
     if (!force) {
       const MCSection &SecA = SA.getSection();
       const MCSection &SecB = SB.getSection();
+      const MCSection &SecCur = *F.getParent();
 
-      // We need record relocation if SecA != SecB. Usually SecB is same as the
-      // section of Fixup, which will be record the relocation as PCRel. If SecB
-      // is not same as the section of Fixup, it will report error. Just return
-      // false and then this work can be finished by handleFixup.
-      if (&SecA != &SecB)
+      // Fallback for PCRel relocations.
----------------
MQ-mengqing wrote:

I process the case A-B when B is same section with the current to generate PCRel relocations, by resolve it as `A-PC+PC-B`. The `A-PC` will be resolved as a PCRel relocation. The `PC-B` should be a constant. Then I use a copy of RISCV::isPCRelFixupResolved to evaluate whether `PC-B` is a constant.

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


More information about the llvm-commits mailing list