From 6e1fe7856970f468e1c8ffdbd62ba4aeff4d47e1 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 18 Apr 2020 16:05:49 -0700 Subject: [PATCH] [ELF][test] Reorganize "TLS attribute mismatch" tests --- lld/test/ELF/Inputs/tls-mismatch.s | 4 --- lld/test/ELF/tls-archive.s | 10 ------ lld/test/ELF/tls-mismatch.s | 49 ++++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 23 deletions(-) delete mode 100644 lld/test/ELF/Inputs/tls-mismatch.s delete mode 100644 lld/test/ELF/tls-archive.s diff --git a/lld/test/ELF/Inputs/tls-mismatch.s b/lld/test/ELF/Inputs/tls-mismatch.s deleted file mode 100644 index 8c14f58a742f..000000000000 --- a/lld/test/ELF/Inputs/tls-mismatch.s +++ /dev/null @@ -1,4 +0,0 @@ -.tbss -.globl tlsvar -tlsvar: - .space 4 diff --git a/lld/test/ELF/tls-archive.s b/lld/test/ELF/tls-archive.s deleted file mode 100644 index 640e68ac3a7f..000000000000 --- a/lld/test/ELF/tls-archive.s +++ /dev/null @@ -1,10 +0,0 @@ -// REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-mismatch.s -o %t2 -// RUN: rm -f %t.a -// RUN: llvm-ar cru %t.a %t2 -// RUN: ld.lld %t.a %t -o /dev/null - -.globl _start,tlsvar -_start: - movq tlsvar@GOTTPOFF(%rip),%rdx diff --git a/lld/test/ELF/tls-mismatch.s b/lld/test/ELF/tls-mismatch.s index d7ce224c1fbb..4b4234aa0d18 100644 --- a/lld/test/ELF/tls-mismatch.s +++ b/lld/test/ELF/tls-mismatch.s @@ -1,12 +1,43 @@ -// REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-mismatch.s -o %t2 -// RUN: not ld.lld %t %t2 -o /dev/null 2>&1 | FileCheck %s +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +# RUN: echo 'movq tls1@GOTTPOFF(%rip), %rax' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o +# RUN: ld.lld %t1.o %t.o -o /dev/null +# RUN: ld.lld %t.o %t1.o -o /dev/null +# RUN: ld.lld --start-lib %t.o --end-lib %t1.o -o /dev/null +# RUN: ld.lld %t1.o --start-lib %t.o --end-lib -o /dev/null -// CHECK: TLS attribute mismatch: tlsvar -// CHECK: >>> defined in -// CHECK: >>> defined in +## The TLS definition mismatches a non-TLS reference. +# RUN: echo '.type tls1,@object; movq tls1,%rax' | 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 +## We fail to flag the swapped case. +# RUN: ld.lld %t.o %t2.o -o /dev/null -.globl _start,tlsvar +# 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 + +## Overriding a TLS definition with a non-TLS definition does not make sense. +# RUN: not ld.lld --defsym tls1=42 %t.o -o /dev/null 2>&1 | FileCheck %s + +## Part of PR36049: This should probably be allowed. +# RUN: not ld.lld --defsym tls1=tls2 %t.o -o /dev/null 2>&1 | FileCheck %s + +# 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@GOTTPOFF(%rip), %rax"' | llvm-as - -o %t.bc +# RUN: ld.lld %t.o %t.bc -o /dev/null +# RUN: not ld.lld %t.bc %t.o -o /dev/null 2>&1 | FileCheck %s + +# CHECK: error: TLS attribute mismatch: tls1 + +.globl _start _start: - movl tlsvar,%edx + addl $1, %fs:tls1@TPOFF + addl $2, %fs:tls2@TPOFF + +.tbss +.globl tls1, tls2 + .space 8 +tls1: + .space 4 +tls2: + .space 4