[PATCH] D18554: [ELF, PR27016] - Do not keep undefined locals in .symtab

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 01:21:38 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL264843: [ELF] - Do not keep undefined locals in .symtab (authored by grimar).

Changed prior to commit:
  http://reviews.llvm.org/D18554?vs=51916&id=52027#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18554

Files:
  lld/trunk/ELF/Writer.cpp
  lld/trunk/test/ELF/local-undefined-symbol.s

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<ELFT> *Sec = File.getSection(Sym);
   // If sym references a section in a discarded group, don't keep it.
   if (Sec == InputSection<ELFT>::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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18554.52027.patch
Type: text/x-patch
Size: 1022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160330/b45b0c42/attachment.bin>


More information about the llvm-commits mailing list