diff options
| author | Davide Italiano <davide@freebsd.org> | 2016-03-22 22:31:34 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2016-03-22 22:31:34 +0000 |
| commit | d4c2a03c32ad52b55c4eb2d620b3e706fba43bf4 (patch) | |
| tree | 24b859555484ece34925d1cbe3e445fffe882af9 /lld/ELF/LTO.cpp | |
| parent | 772bb5b65d6c4dfb3278bea6626c4946fad63bfc (diff) | |
| download | bcm5719-llvm-d4c2a03c32ad52b55c4eb2d620b3e706fba43bf4.tar.gz bcm5719-llvm-d4c2a03c32ad52b55c4eb2d620b3e706fba43bf4.zip | |
[LTO] Keep linkonce_odr symbols when appropriate.
Ensure we keep the symbol we need to before it reaches
the Writer (and hit an assertion), changing its linkage
from linkonce_odr to weak. For a more detailed description
of the problem, see PR19901 where a similar problem was
fixed for the gold plugin. Thanks to Rafael for providing
a testcase.
llvm-svn: 264111
Diffstat (limited to 'lld/ELF/LTO.cpp')
| -rw-r--r-- | lld/ELF/LTO.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index cc570f1f82e..6d2be054813 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -82,10 +82,15 @@ void BitcodeCompiler::add(BitcodeFile &F) { Keep.push_back(GV); continue; } - if (!BitcodeFile::shouldSkip(Sym)) + if (!BitcodeFile::shouldSkip(Sym)) { + + if (GV->getLinkage() == llvm::GlobalValue::LinkOnceODRLinkage) + GV->setLinkage(GlobalValue::WeakODRLinkage); + if (SymbolBody *B = Bodies[BodyIndex++]) if (&B->repl() == B && isa<DefinedBitcode>(B)) Keep.push_back(GV); + } } Mover.move(Obj->takeModule(), Keep, |

