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.globl _start
12_start:
13 mrs x0, TPIDR_EL0
14 add x0, x0, :tprel_hi12:v1
15 add x0, x0, :tprel_lo12_nc:v1
16 mrs x0, TPIDR_EL0
17 add x0, x0, :tprel_hi12:v2
18 add x0, x0, :tprel_lo12_nc:v2
19
20# TCB size = 0x16 and foo is first element from TLS register.
21#CHECK: Disassembly of section .text:
22#CHECK: <_start>:
23#CHECK:  210158: 40 d0 3b d5     mrs     x0, TPIDR_EL0
24#CHECK:  21015c: 00 00 40 91     add     x0, x0, #0, lsl #12
25#CHECK:  210160: 00 40 00 91     add     x0, x0, #16
26#CHECK:  210164: 40 d0 3b d5     mrs     x0, TPIDR_EL0
27#CHECK:  210168: 00 fc 7f 91     add     x0, x0, #4095, lsl #12
28#CHECK:  21016c: 00 e0 3f 91     add     x0, x0, #4088
29
30.section        .tbss,"awT",@nobits
31
32.type   v1,@object
33.globl  v1
34.p2align 2
35v1:
36.word  0
37.size  v1, 4
38
39# The current offset from the thread pointer is 20. Raise it to just below the
40# 24-bit limit.
41.space (0xfffff8 - 20)
42
43.type   v2,@object
44.globl  v2
45.p2align 2
46v2:
47.word  0
48.size  v2, 4
49