aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-06-01 16:38:13 +0000
committerDavide Italiano <davide@freebsd.org>2016-06-01 16:38:13 +0000
commit71293352ba75e3656d16172ebbe4261881051b2a (patch)
treeceeba9649e4bd4136c695c24e0f6ed5775ff63e8
parentfe7db877675e98bcb16ee399d8b094ac7621fc1d (diff)
[LTO] Fix (incorrect) TLS attribute mismatch.
When we undefine, we also preserve type of symbol so that we get it right in the combined LTO object. Differential Revision: http://reviews.llvm.org/D20851 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@271403 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/LTO.cpp2
-rw-r--r--test/ELF/lto/tls-preserve.ll25
2 files changed, 26 insertions, 1 deletions
diff --git a/ELF/LTO.cpp b/ELF/LTO.cpp
index 1539d05dd..dc087bb44 100644
--- a/ELF/LTO.cpp
+++ b/ELF/LTO.cpp
@@ -147,7 +147,7 @@ BitcodeCompiler::BitcodeCompiler()
Mover(*Combined) {}
static void undefine(Symbol *S) {
- replaceBody<Undefined>(S, S->body()->getName(), STV_DEFAULT, 0);
+ replaceBody<Undefined>(S, S->body()->getName(), STV_DEFAULT, S->body()->Type);
}
void BitcodeCompiler::add(BitcodeFile &F) {
diff --git a/test/ELF/lto/tls-preserve.ll b/test/ELF/lto/tls-preserve.ll
new file mode 100644
index 000000000..8aebcb783
--- /dev/null
+++ b/test/ELF/lto/tls-preserve.ll
@@ -0,0 +1,25 @@
+; TLS attribute needs to be preserved.
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t1.o
+; RUN: ld.lld -shared %t1.o -m elf_x86_64 -o %t1
+; RUN: llvm-readobj -t %t1 | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@tsp_int = thread_local global i32 1
+
+define void @_start() {
+ %val = load i32, i32* @tsp_int
+ ret void
+}
+
+; CHECK: Symbol {
+; CHECK: Name: tsp_int
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 4
+; CHECK-NEXT: Binding: Global
+; CHECK-NEXT: Type: TLS
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: .tdata
+; CHECK-NEXT: }