diff options
author | dyung <douglas.yung@sony.com> | 2025-07-25 23:21:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-25 20:21:59 -0700 |
commit | cb37916a2596e0936c76bbd9927f8353faac9fa8 (patch) | |
tree | 8b4dce8ecf8199bfe52f9625b6062d10e1a7d38c /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 3f8a05893f98989630b6f498c6c5f382afe24561 (diff) | |
download | llvm-cb37916a2596e0936c76bbd9927f8353faac9fa8.zip llvm-cb37916a2596e0936c76bbd9927f8353faac9fa8.tar.gz llvm-cb37916a2596e0936c76bbd9927f8353faac9fa8.tar.bz2 |
Revert "MC: Allocate initial fragment and define section symbol in changeSection" (#150736)
Reverts llvm/llvm-project#150574
This is causing a test failure on AArch64 MacOS bots:
https://lab.llvm.org/buildbot/#/builders/190/builds/24187
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index ae8dffc..6099bb8 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -559,7 +559,20 @@ void ELFWriter::computeSymbolTable(const RevGroupMapTy &RevGroupMap) { } else { const MCSectionELF &Section = static_cast<const MCSectionELF &>(Symbol.getSection()); - assert(Section.isRegistered()); + + // We may end up with a situation when section symbol is technically + // defined, but should not be. That happens because we explicitly + // pre-create few .debug_* sections to have accessors. + // And if these sections were not really defined in the code, but were + // referenced, we simply error out. + if (!Section.isRegistered()) { + assert(static_cast<const MCSymbolELF &>(Symbol).getType() == + ELF::STT_SECTION); + Ctx.reportError(SMLoc(), + "Undefined section reference: " + Symbol.getName()); + continue; + } + if (Mode == NonDwoOnly && isDwoSection(Section)) continue; MSD.SectionIndex = Section.getOrdinal(); |