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

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 20 11:42:20 PST 2016


I just noticed that gold and bfd actually keep these symbols, I was
under the impression that was not the case.

I don't think we need to change this back until we actually find why
they do it, and the test helps ensure we don't go back to crashing.

Sorry about that.

Cheers,
Rafael


On 20 January 2016 at 13:59, Simon Atanasyan via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> 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 ""
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list