[Xtensa] Implement Windowed Register Option. (#124656)
[llvm-project.git] / lld / test / ELF / aarch64-tlsdesc-pauth.s
blobbf0ae4a87f322c9b94f2a0c1972a42b2c93a373c
1 // REQUIRES: aarch64
2 // RUN: rm -rf %t && split-file %s %t && cd %t
4 //--- a.s
5 .section .tbss,"awT",@nobits
6 .global a
7 a:
8 .xword 0
10 //--- ok.s
11 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth ok.s -o ok.o
12 // RUN: ld.lld -shared ok.o -o ok.so
13 // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn ok.so | \
14 // RUN: FileCheck -DP=20 -DA=896 -DB=912 -DC=928 %s
15 // RUN: llvm-readobj -r -x .got ok.so | FileCheck --check-prefix=REL \
16 // RUN: -DP1=20 -DA1=380 -DB1=390 -DC1=3A0 -DP2=020 -DA2=380 -DB2=390 -DC2=3a0 %s
18 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth a.s -o a.so.o
19 // RUN: ld.lld -shared a.so.o -soname=so -o a.so
20 // RUN: ld.lld ok.o a.so -o ok
21 // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn ok | \
22 // RUN: FileCheck -DP=220 -DA=936 -DB=952 -DC=968 %s
23 // RUN: llvm-readobj -r -x .got ok | FileCheck --check-prefix=REL \
24 // RUN: -DP1=220 -DA1=3A8 -DB1=3B8 -DC1=3C8 -DP2=220 -DA2=3a8 -DB2=3b8 -DC2=3c8 %s
26 .text
27 adrp x0, :tlsdesc_auth:a
28 ldr x16, [x0, :tlsdesc_auth_lo12:a]
29 add x0, x0, :tlsdesc_auth_lo12:a
30 blraa x16, x0
32 // CHECK: adrp x0, 0x[[P]]000
33 // CHECK-NEXT: ldr x16, [x0, #[[A]]]
34 // CHECK-NEXT: add x0, x0, #[[A]]
35 // CHECK-NEXT: blraa x16, x0
37 /// Create relocation against local TLS symbols where linker should
38 /// create target specific dynamic TLSDESC relocation where addend is
39 /// the symbol VMA in tls block.
41 adrp x0, :tlsdesc_auth:local1
42 ldr x16, [x0, :tlsdesc_auth_lo12:local1]
43 add x0, x0, :tlsdesc_auth_lo12:local1
44 blraa x16, x0
46 // CHECK: adrp x0, 0x[[P]]000
47 // CHECK-NEXT: ldr x16, [x0, #[[B]]]
48 // CHECK-NEXT: add x0, x0, #[[B]]
49 // CHECK-NEXT: blraa x16, x0
51 adrp x0, :tlsdesc_auth:local2
52 ldr x16, [x0, :tlsdesc_auth_lo12:local2]
53 add x0, x0, :tlsdesc_auth_lo12:local2
54 blraa x16, x0
56 // CHECK: adrp x0, 0x[[P]]000
57 // CHECK-NEXT: ldr x16, [x0, #[[C]]]
58 // CHECK-NEXT: add x0, x0, #[[C]]
59 // CHECK-NEXT: blraa x16, x0
61 .section .tbss,"awT",@nobits
62 .type local1,@object
63 .p2align 2
64 local1:
65 .word 0
66 .size local1, 4
68 .type local2,@object
69 .p2align 3
70 local2:
71 .xword 0
72 .size local2, 8
75 // R_AARCH64_AUTH_TLSDESC - 0x0 -> start of tls block
76 // R_AARCH64_AUTH_TLSDESC - 0x8 -> align (sizeof (local1), 8)
78 // REL: Relocations [
79 // REL-NEXT: Section (5) .rela.dyn {
80 // REL-NEXT: 0x[[P1]][[B1]] R_AARCH64_AUTH_TLSDESC - 0x0
81 // REL-NEXT: 0x[[P1]][[C1]] R_AARCH64_AUTH_TLSDESC - 0x8
82 // REL-NEXT: 0x[[P1]][[A1]] R_AARCH64_AUTH_TLSDESC a 0x0
83 // REL-NEXT: }
84 // REL-NEXT: ]
86 // REL: Hex dump of section '.got':
87 // REL-NEXT: 0x00[[P2]][[A2]] 00000000 00000080 00000000 000000a0
88 // REL-NEXT: 0x00[[P2]][[B2]] 00000000 00000080 00000000 000000a0
89 // REL-NEXT: 0x00[[P2]][[C2]] 00000000 00000080 00000000 000000a0
90 /// ^^
91 /// 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
92 /// ^^
93 /// 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
95 //--- err1.s
96 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err1.s -o err1.o
97 // RUN: not ld.lld -shared err1.o 2>&1 | FileCheck --check-prefix=ERR1 --implicit-check-not=error: %s
98 // ERR1: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
99 .text
100 adrp x0, :tlsdesc_auth:a
101 ldr x16, [x0, :tlsdesc_auth_lo12:a]
102 add x0, x0, :tlsdesc_auth_lo12:a
103 blraa x16, x0
105 adrp x0, :tlsdesc:a
106 ldr x1, [x0, :tlsdesc_lo12:a]
107 add x0, x0, :tlsdesc_lo12:a
108 blr x1
110 //--- err2.s
111 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err2.s -o err2.o
112 // RUN: not ld.lld -shared err2.o 2>&1 | FileCheck --check-prefix=ERR2 --implicit-check-not=error: %s
113 // ERR2: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
114 .text
115 adrp x0, :tlsdesc:a
116 ldr x1, [x0, :tlsdesc_lo12:a]
117 add x0, x0, :tlsdesc_lo12:a
118 blr x1
120 adrp x0, :tlsdesc_auth:a
121 ldr x16, [x0, :tlsdesc_auth_lo12:a]
122 add x0, x0, :tlsdesc_auth_lo12:a
123 blraa x16, x0
125 //--- err3.s
126 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err3.s -o err3.o
127 // RUN: not ld.lld -shared err3.o 2>&1 | FileCheck --check-prefix=ERR3 --implicit-check-not=error: %s
128 // ERR3: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
129 .text
130 adrp x0, :tlsdesc_auth:a
131 ldr x16, [x0, :tlsdesc_auth_lo12:a]
132 add x0, x0, :tlsdesc_auth_lo12:a
133 .tlsdesccall a
134 blraa x16, x0