[ELF] Resolve weak undefined TLS symbols when no phdr is available.
authorDavide Italiano <davide@freebsd.org>
Fri, 23 Sep 2016 18:47:50 +0000 (18:47 +0000)
committerDavide Italiano <davide@freebsd.org>
Fri, 23 Sep 2016 18:47:50 +0000 (18:47 +0000)
commit03f7005375c2624538af42e8d6e8a8b7e13b6000
treeb8bdf37fc98b40870968b5ffbdad7aea8401ec2f
parent04949faf69ad46ed97d7276a3a7d7e762f5b8f77
[ELF] Resolve weak undefined TLS symbols when no phdr is available.

If we pass --gc-sections to lld and .tbss is not referenced,
the section is reclaimed and lld doesn't create a TLS program header.
R_TLS tries to access the program header -> lld crashes.
Mimic what bfd/gold do in this case and resolve a weak undefined
TLS symbol to the base of the TLS block, i.e. give it a value of zero.

Differential Revision:  https://reviews.llvm.org/D24832

llvm-svn: 282279
lld/ELF/InputSection.cpp
lld/test/ELF/tls-weak-undef.s [new file with mode: 0644]