diff options
author | Fangrui Song <maskray@google.com> | 2020-08-03 13:35:59 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-08-03 13:43:48 -0700 |
commit | 11bb7c220ccdff1ffec4780ff92fb5acec8f6f0b (patch) | |
tree | 22e238b0944d1c64941b9980beb310b7e70ac25a /llvm/lib/MC/MCSectionELF.cpp | |
parent | 41b1e97b12c1407e40d8e5081bf1f9cf183934b0 (diff) | |
download | llvm-11bb7c220ccdff1ffec4780ff92fb5acec8f6f0b.zip llvm-11bb7c220ccdff1ffec4780ff92fb5acec8f6f0b.tar.gz llvm-11bb7c220ccdff1ffec4780ff92fb5acec8f6f0b.tar.bz2 |
[MC] Set sh_link to 0 if the associated symbol is undefined
Part of https://bugs.llvm.org/show_bug.cgi?id=41734
LTO can drop externally available definitions. Such AssociatedSymbol is
not associated with a symbol. ELFWriter::writeSection() will assert.
Allow a SHF_LINK_ORDER section to have sh_link=0.
We need to give sh_link a syntax, a literal zero in the linked-to symbol
position, e.g. `.section name,"ao",@progbits,0`
Reviewed By: pcc
Differential Revision: https://reviews.llvm.org/D72899
Diffstat (limited to 'llvm/lib/MC/MCSectionELF.cpp')
-rw-r--r-- | llvm/lib/MC/MCSectionELF.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index 77c259c..7a15556 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -172,9 +172,11 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, } if (Flags & ELF::SHF_LINK_ORDER) { - assert(LinkedToSym); OS << ","; - printName(OS, LinkedToSym->getName()); + if (LinkedToSym) + printName(OS, LinkedToSym->getName()); + else + OS << '0'; } if (isUnique()) |