[LLD] Set alignment as part of Characteristics in TLS table.
authorLuqman Aden <me@luqman.ca>
Thu, 15 Oct 2020 02:39:08 +0000 (19:39 -0700)
committerLuqman Aden <me@luqman.ca>
Thu, 15 Oct 2020 02:41:03 +0000 (19:41 -0700)
Fixes https://bugs.llvm.org/show_bug.cgi?id=46473

LLD wasn't previously specifying any specific alignment in the TLS table's Characteristics field so the loader would just assume the default value (16 bytes). This works most of the time except if you have thread locals that want specific higher alignments (e.g. 32 as in the bug) *even* if they specify an alignment on the thread local. This change updates LLD to take the max alignment from tls section.

Reviewed By: rnk

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

lld/COFF/Writer.cpp

index a40ff42..534ea82 100644 (file)
@@ -2067,7 +2067,7 @@ void Writer::fixTlsAlignment() {
                                : sizeof(object::coff_tls_directory32);
 
   if (tlsOffset + directorySize > sec->getRawSize())
-    fatal("_tls_used is malformed");
+    fatal("_tls_used sym is malformed");
 
   if (config->is64()) {
     object::coff_tls_directory64 *tlsDir =