1// RUN: %clang -c -o %t %s
2// RUN: %llvm_jitlink %t
3//
4// Test that basic ELF TLS work by adding together TLSs with values
5// 0, 1, and -1, and returning the result (0 for success). This setup
6// tests both zero-initialized (.tbss) and non-zero-initialized
7// (.tdata) sections.
8
9 .text
10 .file "tlstest.cpp"
11 .globl main
12 .p2align 2
13 .type main,@function
14main:
15 stp x29, x30, [sp, #-16]!
16 mov x29, sp
17 adrp x0, :tlsdesc:x
18 ldr x1, [x0, :tlsdesc_lo12:x]
19 add x0, x0, :tlsdesc_lo12:x
20 .tlsdesccall x
21 blr x1
22 mrs x8, TPIDR_EL0
23 ldr w9, [x8, x0]
24 adrp x0, :tlsdesc:y
25 ldr x1, [x0, :tlsdesc_lo12:y]
26 add x0, x0, :tlsdesc_lo12:y
27 .tlsdesccall y
28 blr x1
29 ldr w10, [x8, x0]
30 add w9, w10, w9
31 adrp x0, :tlsdesc:z
32 ldr x1, [x0, :tlsdesc_lo12:z]
33 add x0, x0, :tlsdesc_lo12:z
34 .tlsdesccall z
35 blr x1
36 ldr w8, [x8, x0]
37 add w0, w9, w8
38 ldp x29, x30, [sp], #16
39 ret
40.Lfunc_end0:
41 .size main, .Lfunc_end0-main
42
43 .type x,@object
44 .section .tdata,"awT",@progbits
45 .globl x
46 .p2align 2
47x:
48 .word 4294967295
49 .size x, 4
50
51 .type y,@object
52 .section .tbss,"awT",@nobits
53 .globl y
54 .p2align 2
55y:
56 .word 0
57 .size y, 4
58
59 .type z,@object
60 .section .tdata,"awT",@progbits
61 .globl z
62 .p2align 2
63z:
64 .word 1
65 .size z, 4
66

source code of compiler-rt/test/orc/TestCases/Linux/aarch64/trivial-tls.S