2020-04-19 07:05:49 +08:00
|
|
|
# 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
|
2017-04-01 07:40:21 +08:00
|
|
|
|
2020-04-19 07:05:49 +08:00
|
|
|
## 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
|
2015-10-09 17:58:39 +08:00
|
|
|
|
2020-04-19 06:04:44 +08:00
|
|
|
## We fail to flag the STT_NOTYPE reference. This usually happens with hand-written
|
|
|
|
## assembly because compiler-generated code properly sets symbol types.
|
2020-04-19 07:05:49 +08:00
|
|
|
# RUN: echo 'movq tls1,%rax' | llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o
|
2020-04-19 06:04:44 +08:00
|
|
|
# RUN: ld.lld %t3.o %t.o -o /dev/null
|
2020-04-19 07:05:49 +08:00
|
|
|
|
|
|
|
## 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
|
|
|
|
|
2020-04-19 06:04:44 +08:00
|
|
|
## An undefined symbol in module-level inline assembly of a bitcode file
|
|
|
|
## is considered STT_NOTYPE. We should not error.
|
2020-04-19 07:05:49 +08:00
|
|
|
# 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
|
2020-04-19 06:04:44 +08:00
|
|
|
# RUN: ld.lld %t.bc %t.o -o /dev/null
|
2020-04-19 07:05:49 +08:00
|
|
|
|
|
|
|
# CHECK: error: TLS attribute mismatch: tls1
|
|
|
|
|
|
|
|
.globl _start
|
2015-10-09 17:58:39 +08:00
|
|
|
_start:
|
2020-04-19 07:05:49 +08:00
|
|
|
addl $1, %fs:tls1@TPOFF
|
|
|
|
addl $2, %fs:tls2@TPOFF
|
|
|
|
|
|
|
|
.tbss
|
|
|
|
.globl tls1, tls2
|
|
|
|
.space 8
|
|
|
|
tls1:
|
|
|
|
.space 4
|
|
|
|
tls2:
|
|
|
|
.space 4
|