[ELF] - Do not keep undefined locals in .symtab
gold and bfd do not include the undefined locals in symtab.
We have no reasons to support that either.
That fixes PR27016
Differential revision: http://reviews.llvm.org/D18554
llvm-svn: 264843
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 4e24588..b9df7cd 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -511,6 +511,10 @@
if (Sym.getType() == STT_SECTION)
return Config->Relocatable;
+ // No reason to keep local undefined symbol in symtab.
+ if (Sym.st_shndx == SHN_UNDEF)
+ return false;
+
InputSectionBase<ELFT> *Sec = File.getSection(Sym);
// If sym references a section in a discarded group, don't keep it.
if (Sec == InputSection<ELFT>::Discarded)