[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 22:20:46 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL301897: ELF: Set symbol binding to STB_GLOBAL when undefining symbols during LTO. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D32731?vs=97387&id=97390#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32731

Files:
  lld/trunk/ELF/LTO.cpp


Index: lld/trunk/ELF/LTO.cpp
===================================================================
--- lld/trunk/ELF/LTO.cpp
+++ lld/trunk/ELF/LTO.cpp
@@ -105,6 +105,11 @@
 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) {


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


More information about the llvm-commits mailing list