[llvm] [ARM] Use .reloc for weak symbols in PIC mode instead of GOT indirection (PR #208372)

dong jianqiang via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 06:13:38 PDT 2026


================
@@ -1016,6 +1016,35 @@ void ARMAsmPrinter::emitMachineConstantPoolValue(
     unsigned char TF =
         TM.getTargetTriple().isOSBinFormatMachO() ? ARMII::MO_NONLAZY : 0;
     MCSym = GetARMGVSymbol(GV, TF);
+
+    // For weak symbols in ELF PIC mode, the assembler would eagerly resolve a
+    // PC-relative expression like sym-(LPC+8) when the symbol and reference are
+    // in the same section, preventing the linker from overriding a weak
+    // definition with a strong one. Use a .reloc directive to force a proper
----------------
dongjianqiang2 wrote:

Good suggestion, thanks. Updated the comment

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


More information about the llvm-commits mailing list