diff options
-rw-r--r-- | lld/ELF/OutputSections.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/file-sym.s | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index b885601e1ed..62ad8e24752 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -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); diff --git a/lld/test/ELF/file-sym.s b/lld/test/ELF/file-sym.s new file mode 100644 index 00000000000..eddb461490c --- /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 "" |