Handle multiple .tbss sections.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 22 Sep 2016 12:00:08 +0000 (12:00 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 22 Sep 2016 12:00:08 +0000 (12:00 +0000)
llvm-svn: 282147

lld/ELF/LinkerScript.cpp
lld/test/ELF/linkerscript/multiple-tbss.s [new file with mode: 0644]

index a8ed925..7edfaca 100644 (file)
@@ -373,7 +373,9 @@ template <class ELFT> void LinkerScript<ELFT>::output(InputSection<ELFT> *S) {
   // .foo { *(.aaa) a = SIZEOF(.foo); *(.bbb) }
   CurOutSec->setSize(Pos - CurOutSec->getVA());
 
-  if (!IsTbss)
+  if (IsTbss)
+    ThreadBssOffset = Pos - Dot;
+  else
     Dot = Pos;
 }
 
diff --git a/lld/test/ELF/linkerscript/multiple-tbss.s b/lld/test/ELF/linkerscript/multiple-tbss.s
new file mode 100644 (file)
index 0000000..d30ac05
--- /dev/null
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "SECTIONS { }" > %t.script
+# RUN: ld.lld -T %t.script %t.o -o %t
+# RUN: llvm-readobj -l %t | FileCheck %s
+
+# CHECK:      Type: PT_TLS
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: VirtualAddress:
+# CHECK-NEXT: PhysicalAddress:
+# CHECK-NEXT: FileSize: 0
+# CHECK-NEXT: MemSize: 9
+
+.section        .tbss,"awT",@nobits
+.quad   0
+.section        foo,"awT",@nobits
+.byte 0