[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
Thu Apr 10 09:02:31 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:
I was referring to the logic in this [function](https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/ELFObjectWriter.cpp#L1365), where if it is PREL32 and the target symbol is dso_local, we may update relocation target from "func + vtable_slot_offset" to "section + offset". So if the dso_local function is not referenced elsewhere, we can omit its emission in local symtab.
https://github.com/llvm/llvm-project/pull/134781
More information about the llvm-commits
mailing list