[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.

llvm-svn: 258331
This commit is contained in:
Simon Atanasyan
2016-01-20 18:59:45 +00:00
parent 545a456235
commit 0d5e1b753e
2 changed files with 13 additions and 1 deletions

View File

@@ -1411,7 +1411,7 @@ template <class ELFT> void StringTableSection<ELFT>::writeTo(uint8_t *Buf) {
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);

12
lld/test/ELF/file-sym.s Normal file
View File

@@ -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 ""