[PATCH] Windows TLS: Section name prefix to ensure correct order.

David Nadlinger code at klickverbot.at
Wed Feb 20 10:20:31 PST 2013


The linker sorts the .tls$<xyz> sections by name, and we need to make sure any extra sections we produce (e.g. for weak globals) always end up between .tls$AAA and .tls$ZZZ, even if the name starts with e.g. an underscore.

http://llvm-reviews.chandlerc.com/D430

Files:
  lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -743,8 +743,11 @@
     return ".text$";
   if (Kind.isBSS ())
     return ".bss$";
-  if (Kind.isThreadLocal())
-    return ".tls$";
+  if (Kind.isThreadLocal()) {
+    // 'LLVM' is just an arbitary string to ensure that the section name gets
+    // sorted in between '.tls$AAA' and '.tls$ZZZ' by the linker.
+    return ".tls$LLVM";
+  }
   if (Kind.isWriteable())
     return ".data$";
   return ".rdata$";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D430.1.patch
Type: text/x-patch
Size: 631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130220/88d36c3e/attachment.bin>


More information about the llvm-commits mailing list