[PATCH] D78438: [ELF] Temporarily delete "TLS attribute mismatch" diagnostics

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 20 11:21:38 PDT 2020


MaskRay updated this revision to Diff 258800.
MaskRay edited the summary of this revision.
MaskRay removed a subscriber: dexonsmith.
MaskRay added a comment.

Edit description


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78438/new/

https://reviews.llvm.org/D78438

Files:
  lld/ELF/Symbols.h
  lld/test/ELF/tls-mismatch.s


Index: lld/test/ELF/tls-mismatch.s
===================================================================
--- lld/test/ELF/tls-mismatch.s
+++ lld/test/ELF/tls-mismatch.s
@@ -4,21 +4,28 @@
 # RUN: ld.lld %t1.o %t.o -o /dev/null
 
 # RUN: echo '.globl tls1' | llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o
-# RUN: not ld.lld %t2.o %t.o -o /dev/null 2>&1 | FileCheck %s
+# RUN: ld.lld %t2.o %t.o -o /dev/null
 
+## Likely runtime bug: a non-TLS relocation references a TLS symbol.
 # RUN: echo 'movq tls1,%rax' | llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o
-# RUN: not ld.lld %t3.o %t.o -o /dev/null 2>&1 | FileCheck %s
+# RUN: ld.lld %t3.o %t.o -o /dev/null
 
-# RUN: not ld.lld --defsym tls1=42 %t.o -o /dev/null 2>&1 | FileCheck %s
+# RUN: ld.lld --defsym tls1=42 %t.o -o - | llvm-readelf -s - | FileCheck --check-prefix=ABS %s
+# ABS:    Value         Size Type   Bind   Vis     Ndx Name
+# ABS: 000000000000002a    0 NOTYPE GLOBAL DEFAULT ABS tls1
+# ABS: 000000000000000c    0 TLS    GLOBAL DEFAULT   2 tls2
 
-# RUN: not ld.lld --defsym tls1=tls2 %t.o -o /dev/null 2>&1 | FileCheck %s
+## PR36049 this does not work.
+# RUN: ld.lld --defsym tls2=tls1 %t.o -o %t.same
+# RUN: llvm-readelf -s %t.same | FileCheck --check-prefix=SAME %s
+# SAME:    Value         Size Type   Bind   Vis     Ndx Name
+# SAME: 0000000000000008    0 TLS    GLOBAL DEFAULT   2 tls1
+# SAME: 000000000020{{.*}}  0 NOTYPE GLOBAL DEFAULT   2 tls2
 
 # RUN: echo 'target triple = "x86_64-pc-linux-gnu" \
 # RUN:   target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" \
 # RUN:   module asm "movq tls1 at GOTTPOFF(%rip), %rax"' | llvm-as - -o %t.bc
-# RUN: not ld.lld %t.bc %t.o -o /dev/null 2>&1 | FileCheck %s
-
-# CHECK: error: TLS attribute mismatch: tls1
+# RUN: ld.lld %t.bc %t.o -o /dev/null
 
 .globl _start
 _start:
Index: lld/ELF/Symbols.h
===================================================================
--- lld/ELF/Symbols.h
+++ lld/ELF/Symbols.h
@@ -515,18 +515,6 @@
 // it over to "this". This function is called as a result of name
 // resolution, e.g. to replace an undefind symbol with a defined symbol.
 void Symbol::replace(const Symbol &newSym) {
-  using llvm::ELF::STT_TLS;
-
-  // Symbols representing thread-local variables must be referenced by
-  // TLS-aware relocations, and non-TLS symbols must be reference by
-  // non-TLS relocations, so there's a clear distinction between TLS
-  // and non-TLS symbols. It is an error if the same symbol is defined
-  // as a TLS symbol in one file and as a non-TLS symbol in other file.
-  if (symbolKind != PlaceholderKind && !isLazy() && !newSym.isLazy() &&
-      (type == STT_TLS) != (newSym.type == STT_TLS))
-    error("TLS attribute mismatch: " + toString(*this) + "\n>>> defined in " +
-          toString(newSym.file) + "\n>>> defined in " + toString(file));
-
   Symbol old = *this;
   memcpy(this, &newSym, newSym.getSymbolSize());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78438.258800.patch
Type: text/x-patch
Size: 2898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200420/180ab81f/attachment.bin>


More information about the llvm-commits mailing list