[PATCH] D25083: [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 02:01:48 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283198: [ELF] - Do not crash if symbol type set to TLS when there is no tls sections. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D25083?vs=73258&id=73429#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25083
Files:
lld/trunk/ELF/Symbols.cpp
lld/trunk/test/ELF/invalid/Inputs/tls-symbol.elf
lld/trunk/test/ELF/invalid/tls-symbol.s
Index: lld/trunk/test/ELF/invalid/tls-symbol.s
===================================================================
--- lld/trunk/test/ELF/invalid/tls-symbol.s
+++ lld/trunk/test/ELF/invalid/tls-symbol.s
@@ -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
Index: lld/trunk/ELF/Symbols.cpp
===================================================================
--- lld/trunk/ELF/Symbols.cpp
+++ lld/trunk/ELF/Symbols.cpp
@@ -59,8 +59,12 @@
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25083.73429.patch
Type: text/x-patch
Size: 1078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161004/ea0ca521/attachment.bin>
More information about the llvm-commits
mailing list