1# REQUIRES: aarch64
2# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %tmain.o
3# RUN: ld.lld %tmain.o -o %tout
4# RUN: llvm-objdump -d %tout | FileCheck %s
5# RUN: llvm-readobj -S -r %tout | FileCheck -check-prefix=RELOC %s
6
7#Local-Dynamic to Local-Exec relax creates no
8#RELOC:      Relocations [
9#RELOC-NEXT: ]
10
11## Reject local-exec TLS relocations for -shared.
12# RUN: not ld.lld -shared %tmain.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
13
14# ERR: error: relocation R_AARCH64_TLSLE_ADD_TPREL_HI12 against v1 cannot be used with -shared
15# ERR: error: relocation R_AARCH64_TLSLE_ADD_TPREL_LO12_NC against v1 cannot be used with -shared
16# ERR: error: relocation R_AARCH64_TLSLE_ADD_TPREL_HI12 against v2 cannot be used with -shared
17# ERR: error: relocation R_AARCH64_TLSLE_ADD_TPREL_LO12_NC against v2 cannot be used with -shared
18
19.globl _start
20_start:
21 mrs x0, TPIDR_EL0
22 add x0, x0, :tprel_hi12:v1
23 add x0, x0, :tprel_lo12_nc:v1
24 mrs x0, TPIDR_EL0
25 add x0, x0, :tprel_hi12:v2
26 add x0, x0, :tprel_lo12_nc:v2
27
28# TCB size = 0x16 and foo is first element from TLS register.
29#CHECK: Disassembly of section .text:
30#CHECK: <_start>:
31#CHECK:  210158: 40 d0 3b d5     mrs     x0, TPIDR_EL0
32#CHECK:  21015c: 00 00 40 91     add     x0, x0, #0, lsl #12
33#CHECK:  210160: 00 40 00 91     add     x0, x0, #16
34#CHECK:  210164: 40 d0 3b d5     mrs     x0, TPIDR_EL0
35#CHECK:  210168: 00 fc 7f 91     add     x0, x0, #4095, lsl #12
36#CHECK:  21016c: 00 e0 3f 91     add     x0, x0, #4088
37
38.section        .tbss,"awT",@nobits
39
40.type   v1,@object
41.globl  v1
42.p2align 2
43v1:
44.word  0
45.size  v1, 4
46
47# The current offset from the thread pointer is 20. Raise it to just below the
48# 24-bit limit.
49.space (0xfffff8 - 20)
50
51.type   v2,@object
52.globl  v2
53.p2align 2
54v2:
55.word  0
56.size  v2, 4
57