From 0d5e1b753e49f993832844eb2954cf62f1df1444 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Wed, 20 Jan 2016 18:59:45 +0000 Subject: [PATCH] [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 --- lld/ELF/OutputSections.cpp | 2 +- lld/test/ELF/file-sym.s | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/file-sym.s diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index b885601e1ed0..62ad8e24752c 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1411,7 +1411,7 @@ template void StringTableSection::writeTo(uint8_t *Buf) { template bool elf2::shouldKeepInSymtab(const ObjectFile &File, StringRef SymName, const typename ELFFile::Elf_Sym &Sym) { - if (Sym.getType() == STT_SECTION) + if (Sym.getType() == STT_SECTION || Sym.getType() == STT_FILE) return false; InputSectionBase *Sec = File.getSection(Sym); diff --git a/lld/test/ELF/file-sym.s b/lld/test/ELF/file-sym.s new file mode 100644 index 000000000000..eddb461490c6 --- /dev/null +++ b/lld/test/ELF/file-sym.s @@ -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 ""