[lld] r258331 - [ELF] Do not keep STT_FILE symbols in the symbol table

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 20 10:59:45 PST 2016


Author: atanasyan
Date: Wed Jan 20 12:59:45 2016
New Revision: 258331

URL: http://llvm.org/viewvc/llvm-project?rev=258331&view=rev
Log:
[ELF] Do not keep STT_FILE symbols in the symbol table

STT_FILE symbols usually contain source file names. It is redundant
to keep this information in the output file.

Added:
    lld/trunk/test/ELF/file-sym.s
Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=258331&r1=258330&r2=258331&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Jan 20 12:59:45 2016
@@ -1411,7 +1411,7 @@ template <class ELFT> void StringTableSe
 template <class ELFT>
 bool elf2::shouldKeepInSymtab(const ObjectFile<ELFT> &File, StringRef SymName,
                               const typename ELFFile<ELFT>::Elf_Sym &Sym) {
-  if (Sym.getType() == STT_SECTION)
+  if (Sym.getType() == STT_SECTION || Sym.getType() == STT_FILE)
     return false;
 
   InputSectionBase<ELFT> *Sec = File.getSection(Sym);

Added: lld/trunk/test/ELF/file-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/file-sym.s?rev=258331&view=auto
==============================================================================
--- lld/trunk/test/ELF/file-sym.s (added)
+++ lld/trunk/test/ELF/file-sym.s Wed Jan 20 12:59:45 2016
@@ -0,0 +1,12 @@
+# Check that we do not keep STT_FILE symbols in the symbol table
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -shared -o %t.so
+# RUN: llvm-readobj -symbols %t.so | FileCheck %s
+
+# REQUIRES: x86
+
+# CHECK-NOT: xxx
+
+.file "xxx"
+.file ""




More information about the llvm-commits mailing list