[LLD][PATCH] Do not keep STT_FILE symbols in the symbol table

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 20 06:25:20 PST 2016


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stt-file.patch
Type: application/octet-stream
Size: 1155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160120/da969149/attachment.obj>


More information about the llvm-commits mailing list