2 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o
3 # RUN: ld.lld %t.o -o %t
4 # RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t | FileCheck %s
5 # RUN: llvm-readobj --symbols %t | FileCheck --check-prefix=CHECK-SYM %s
7 ## Test the local exec relocations that map to:
8 ## R_AARCH64_TLSLE_MOVW_TPREL_G2
9 ## R_AARCH64_TLSLE_MOVW_TPREL_G1
10 ## R_AARCH64_TLSLE_MOVW_TPREL_G1_NC
11 ## R_AARCH64_TLSLE_MOVW_TPREL_G0
12 ## R_AARCH64_TLSLE_MOVW_TPREL_G0_NC
13 ## They calculate the same value as the other TPREL relocations, namely the
14 ## offset from the thread pointer TP. The G0, G1 and G2 refer to partitions
15 ## of the result with G2 bits [47:32], G1 bits [31:16] and G0 bits [15:0]
16 ## the NC variant does not check for overflow.
17 ## In AArch64 the structure of the TLS at runtime is:
18 ## | TCB | Alignment Padding | TLS Block |
19 ## With TP pointing to the start of the TCB. All offsets will be positive.
22 ## Access variable in first partition
23 movz x0
, #:tprel_g0:v0
28 # CHECK-SYM-NEXT: Value: 0x0
30 ## Access variable in second partition
31 movz x0
, #:tprel_g1:v1
32 movk x0
, #:tprel_g0_nc:v1
34 ## TCB + 65536 across movz and movk
35 # CHECK-NEXT: mov x0, #65536
36 # CHECK-NEXT: movk x0, #16
39 # CHECK-SYM-NEXT: Value: 0x10000
41 ## Access variable in third partition
42 movz x0
, #:tprel_g2:v2
43 movk x0
, #:tprel_g1_nc:v2
44 movk x0
, #:tprel_g0_nc:v2
46 ## TCB + 65536 + 4294967296 across movz and 2 movk instructions
47 # CHECK-NEXT: mov x0, #4294967296
48 # CHECK-NEXT: movk x0, #1, lsl #16
49 # CHECK-NEXT: movk x0, #16
52 # CHECK-SYM-NEXT: Value: 0x100010000
54 .section .tbss,"awT",@nobits
61 .space 0x100000000 - 8