[lld] r271403 - [LTO] Fix (incorrect) TLS attribute mismatch.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 09:38:18 PDT 2016


Author: davide
Date: Wed Jun  1 11:38:13 2016
New Revision: 271403

URL: http://llvm.org/viewvc/llvm-project?rev=271403&view=rev
Log:
[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

Added:
    lld/trunk/test/ELF/lto/tls-preserve.ll
Modified:
    lld/trunk/ELF/LTO.cpp

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=271403&r1=271402&r2=271403&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Wed Jun  1 11:38:13 2016
@@ -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) {

Added: lld/trunk/test/ELF/lto/tls-preserve.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/tls-preserve.ll?rev=271403&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/tls-preserve.ll (added)
+++ lld/trunk/test/ELF/lto/tls-preserve.ll Wed Jun  1 11:38:13 2016
@@ -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"
+
+ at 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: }




More information about the llvm-commits mailing list