mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 03:56:16 +08:00
[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:
@@ -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
12
lld/test/ELF/file-sym.s
Normal 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 ""
|
||||
Reference in New Issue
Block a user