Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/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 *Sec = File.getSection(Sym); // If sym references a section in a discarded group, don't keep it. if (Sec == InputSection::Discarded) Index: lld/trunk/test/ELF/local-undefined-symbol.s =================================================================== --- lld/trunk/test/ELF/local-undefined-symbol.s +++ lld/trunk/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