[PATCH] D32731: ELF: Set symbol binding to STB_GLOBAL when undefining symbols during LTO.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 21:34:58 PDT 2017


pcc created this revision.
Herald added a subscriber: inglorion.

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.


https://reviews.llvm.org/D32731

Files:
  lld/ELF/LTO.cpp


Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -105,6 +105,7 @@
 static void undefine(Symbol *S) {
   replaceBody<Undefined>(S, S->body()->getName(), /*IsLocal=*/false,
                          STV_DEFAULT, S->body()->Type, nullptr);
+  S->Binding = STB_GLOBAL;
 }
 
 void BitcodeCompiler::add(BitcodeFile &F) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32731.97387.patch
Type: text/x-patch
Size: 400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170502/4d7b14b1/attachment.bin>


More information about the llvm-commits mailing list