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/CodeGen/TargetLoweringObjectFileImpl.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/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 4859919..8ef9125 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -680,7 +680,7 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal( // MD_associated in a unique section. unsigned UniqueID = MCContext::GenericSectionID; const MCSymbolELF *LinkedToSym = getLinkedToSymbol(GO, TM); - if (LinkedToSym) { + if (GO->getMetadata(LLVMContext::MD_associated)) { UniqueID = NextUniqueID++; Flags |= ELF::SHF_LINK_ORDER; } else { |