[LLD][PATCH] 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 07:09:41 PST 2016


LGTM, just trim the test a bit please. You don't need a body for
_start and if the bug reproduced with -shared you don't even need
_start.


Thanks,
Rafael


On 20 January 2016 at 09:25, Simon Atanasyan <simon at atanasyan.com> wrote:
> Hi,
>
> Now LLD keeps STT_FILE symbols in the symbol table because
> `elf2::shouldKeepInSymtab` returns true for them. But if such symbol
> has an empty name, the LLD crashes.
>
> % cat test.s
>  .file ""
>  .globl _start;
>  _start:
>    mov $60, %rax
>    mov $42, %rdi
>    syscall
> % llvm-mc -filetype=obj -triple=x86_64-unknown-linux test.s -o test.o
> % lld -flavor gnu test.o
>
> The problem is in the `elf2::shouldKeepInSymtab`. STT_FILE symbol has
> no associated section so the `File.getSection(Sym)` returns null and
> the LLD crashes on the `Sec->getSectionHdr()->sh_flags` call.
>
> The most simple fix is to ignore STT_FILE symbols at all. Attached
> patch implements that.
>
> But maybe we want to keep them for some reasons?
>
> --
> Simon Atanasyan


More information about the llvm-commits mailing list