diff options
| author | George Rimar <grimar@accesssoftek.com> | 2016-03-30 08:16:11 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2016-03-30 08:16:11 +0000 |
| commit | f1c0bf5b4087c6cb7aa4939b4be738fa5f9f80b4 (patch) | |
| tree | 0add497750bdea15c66f995e3e738bdd0af2ee00 | |
| parent | 17d7d145717cc9eedee5f9650f5188a0bf32a65f (diff) | |
| download | bcm5719-llvm-f1c0bf5b4087c6cb7aa4939b4be738fa5f9f80b4.tar.gz bcm5719-llvm-f1c0bf5b4087c6cb7aa4939b4be738fa5f9f80b4.zip | |
[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
| -rw-r--r-- | lld/ELF/Writer.cpp | 4 | ||||
| -rw-r--r-- | lld/test/ELF/local-undefined-symbol.s | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 4e24588c4b9..b9df7cdbd00 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -511,6 +511,10 @@ static bool shouldKeepInSymtab(const elf::ObjectFile<ELFT> &File, 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) diff --git a/lld/test/ELF/local-undefined-symbol.s b/lld/test/ELF/local-undefined-symbol.s new file mode 100644 index 00000000000..34ef847180a --- /dev/null +++ b/lld/test/ELF/local-undefined-symbol.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t1 +# RUN: llvm-readobj -t %t1 | FileCheck %s + +# CHECK: Symbols [ +# CHECK-NOT: Name: foo + +.global _start +_start: + jmp foo + +.local foo |

