[lld] r283198 - [ELF] - Do not crash if symbol type set to TLS when there is no tls sections.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 01:52:52 PDT 2016
Author: grimar
Date: Tue Oct 4 03:52:51 2016
New Revision: 283198
URL: http://llvm.org/viewvc/llvm-project?rev=283198&view=rev
Log:
[ELF] - Do not crash if symbol type set to TLS when there is no tls sections.
id_000021,sig_11,src_000002,op_flip1,pos_92 from PR30540
does not have TLS sections, but type
of one of the symbol is broken and set to STT_TLS,
what resulted in a crash. Patch fixes crash.
DIfferential revision: https://reviews.llvm.org/D25083
Added:
lld/trunk/test/ELF/invalid/Inputs/tls-symbol.elf (with props)
lld/trunk/test/ELF/invalid/tls-symbol.s
Modified:
lld/trunk/ELF/Symbols.cpp
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=283198&r1=283197&r2=283198&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Oct 4 03:52:51 2016
@@ -59,8 +59,12 @@ static typename ELFT::uint getSymVA(cons
Addend = 0;
}
uintX_t VA = (SC->OutSec ? SC->OutSec->getVA() : 0) + SC->getOffset(Offset);
- if (D.isTls() && !Config->Relocatable)
+ if (D.isTls() && !Config->Relocatable) {
+ if (!Out<ELFT>::TlsPhdr)
+ fatal(getFilename(D.File) +
+ " has a STT_TLS symbol but doesn't have a PT_TLS section");
return VA - Out<ELFT>::TlsPhdr->p_vaddr;
+ }
return VA;
}
case SymbolBody::DefinedCommonKind:
Added: lld/trunk/test/ELF/invalid/Inputs/tls-symbol.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/tls-symbol.elf?rev=283198&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/ELF/invalid/Inputs/tls-symbol.elf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: lld/trunk/test/ELF/invalid/tls-symbol.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/tls-symbol.s?rev=283198&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid/tls-symbol.s (added)
+++ lld/trunk/test/ELF/invalid/tls-symbol.s Tue Oct 4 03:52:51 2016
@@ -0,0 +1,5 @@
+# REQUIRES: x86
+
+## The test file contains a STT_TLS symbol but has no TLS section.
+# RUN: not ld.lld %S/Inputs/tls-symbol.elf -o %t 2>&1 | FileCheck %s
+# CHECK: has a STT_TLS symbol but doesn't have a PT_TLS section
More information about the llvm-commits
mailing list