[llvm] AsmPrinter: Remove ELF's special lowerRelativeReference for unnamed_addr function; use lowerDSOLocalEquivalent in more cases (PR #134781)

YongKang Zhu via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 21:32:11 PDT 2025


================
@@ -3496,10 +3496,12 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV,
           LHSGV, RHSGV, Addend, PCRelativeOffset, TM);
 
       // (ELF-specific) If the generic symbol difference does not apply, and
-      // LHS is a dso_local_equivalent of a dso_preemptable function,
-      // reference the PLT entry instead.
-      if (DSOEquiv && TM.getTargetTriple().isOSBinFormatELF() &&
-          !(LHSGV->isDSOLocal() || LHSGV->isImplicitDSOLocal()))
+      // LHS is a dso_local_equivalent of a function, reference the PLT entry
+      // instead. Note: A default visibility symbol is by default preemptible
+      // during linking, and should not be referenced with PC-relative
+      // relocations. Therefore, use a PLT relocation even if the function is
+      // dso_local.
----------------
yozhu wrote:

For AArch64, this change makes relocations for relative vtable entries always be PLT32, though PREL32 relocation also works (for dso_local) and its target symbol could get changed from function to section-plus-offset (in hope to omit the function symbol in local symbol table).

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


More information about the llvm-commits mailing list