[lld] [lld][LoongArch] Fix relaxation for R_LARCH_GOT_PC_{HI20, LO12} (PR #151264)

Lu Weining via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 19:19:00 PDT 2025


================
@@ -57,6 +74,11 @@ _start:
   la.pcrel  $a0, sym
   la.got    $a0, sym
 
+  pcalau12i $a0, %got_pc_hi20(sym+4)
+    .reloc .-4, R_LARCH_RELAX, 0
+  ld        $a0, $a0, %got_pc_lo12(sym+4)
+    .reloc .-4, R_LARCH_RELAX, 0
+
----------------
SixWeining wrote:

Seems we can use `la.global $a0, sym+4`?

It's better to split this case into a separate `.s`.

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


More information about the llvm-commits mailing list