[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

llvm-svn: 283198
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 4819bb17..7457224 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/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: