summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-05-02 05:07:41 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-05-02 05:07:41 +0000
commit99c8fa3bef04901f34e8bdb1d2b5261a99a648a9 (patch)
tree08c62b139ee7a65dbe1cc28ac68096c9f141498a
parentdfb1e2a1a148c3d269e2d03e572747425b2dbb53 (diff)
downloadbcm5719-llvm-99c8fa3bef04901f34e8bdb1d2b5261a99a648a9.tar.gz
bcm5719-llvm-99c8fa3bef04901f34e8bdb1d2b5261a99a648a9.zip
ELF: Set symbol binding to STB_GLOBAL when undefining symbols during LTO.
If there is a bug in the LTO implementation that causes it to fail to provide an expected symbol definition, the linker should report an undefined symbol error. Unfortunately, we were failing to do so if the symbol definition was weak, as the undefine() function was turning the definition into a weak undefined symbol, which resolves to zero if the symbol remains undefined. This patch causes us to set the binding to STB_GLOBAL when we undefine a symbol. I can't see a good way to test this. The behaviour should only be observable if there is a bug in the LTO implementation. Differential Revision: https://reviews.llvm.org/D32731 llvm-svn: 301897
-rw-r--r--lld/ELF/LTO.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index dd435173101..de0d45bea1c 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -105,6 +105,11 @@ BitcodeCompiler::~BitcodeCompiler() = default;
static void undefine(Symbol *S) {
replaceBody<Undefined>(S, S->body()->getName(), /*IsLocal=*/false,
STV_DEFAULT, S->body()->Type, nullptr);
+ // It shouldn't normally matter what the binding is, but if a bug in the LTO
+ // implementation causes it to fail to provide a definition for a symbol,
+ // setting the binding to STB_GLOBAL will cause the linker to report an
+ // undefined symbol error, even if the definition was weak.
+ S->Binding = STB_GLOBAL;
}
void BitcodeCompiler::add(BitcodeFile &F) {
OpenPOWER on IntegriCloud