[lld] 32a4ad3 - [LLD] Set alignment as part of Characteristics in TLS table.

Luqman Aden via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 19:41:39 PDT 2020


Author: Luqman Aden
Date: 2020-10-14T19:41:03-07:00
New Revision: 32a4ad3b6ce6028a371b028cf06fa5feff9534bf

URL: https://github.com/llvm/llvm-project/commit/32a4ad3b6ce6028a371b028cf06fa5feff9534bf
DIFF: https://github.com/llvm/llvm-project/commit/32a4ad3b6ce6028a371b028cf06fa5feff9534bf.diff

LOG: [LLD] Set alignment as part of Characteristics in TLS table.

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

Added: 
    

Modified: 
    lld/COFF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index a40ff42683ee..534ea82dc3c2 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -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 =


        


More information about the llvm-commits mailing list