[Frontend] Remove unused includes (NFC) (#116927)
[llvm-project.git] / llvm / test / MC / AArch64 / elf-reloc-ptrauth.s
blob057b298a0a0df842a135272eaea869383a13c9c4
1 // RUN: llvm-mc -triple=aarch64 %s --defsym=ASMONLY=1 | FileCheck %s --check-prefix=ASM
3 // RUN: llvm-mc -triple=aarch64 -filetype=obj %s | \
4 // RUN: llvm-readelf -S -r -x .test - | FileCheck %s --check-prefix=RELOC
6 // RELOC: Relocation section '.rela.test' at offset {{.*}} contains 8 entries:
7 // RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
8 // RELOC-NEXT: 0000000000000000 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 .helper + 0
9 // RELOC-NEXT: 0000000000000010 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g1 + 0
10 // RELOC-NEXT: 0000000000000020 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g2 + 0
11 // RELOC-NEXT: 0000000000000030 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g3 + 0
12 // RELOC-NEXT: 0000000000000040 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g4 + 7
13 // RELOC-NEXT: 0000000000000050 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g5 - 3
14 // RELOC-NEXT: 0000000000000060 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g 6 + 0
15 // RELOC-NEXT: 0000000000000070 {{.*}} R_AARCH64_AUTH_ABS64 0000000000000000 _g 7 + 7
17 // RELOC: Hex dump of section '.test':
18 // VVVVVVVV addend, not needed for rela
19 // VV reserved
20 // RELOC-NEXT: 00 00000000 2a000000
21 // ^^^^ discriminator
22 // ^^ 0 no addr diversity 0 reserved 00 ia key 0000 reserved
23 // RELOC-NEXT: 10 00000000 00000010
24 // ^^^^ discriminator
25 // ^^ 0 no addr diversity 0 reserved 01 ib key 0000 reserved
26 // RELOC-NEXT: 20 00000000 050000a0
27 // ^^^^ discriminator
28 // ^^ 1 addr diversity 0 reserved 10 da key 0000 reserved
29 // RELOC-NEXT: 30 00000000 ffff00b0
30 // ^^^^ discriminator
31 // ^^ 1 addr diversity 0 reserved 11 db key 0000 reserved
32 // RELOC-NEXT: 40 00000000 00000000
33 // ^^^^ discriminator
34 // ^^ 0 no addr diversity 0 reserved 00 ia key 0000 reserved
35 // RELOC-NEXT: 50 00000000 00de0010
36 // ^^^^ discriminator
37 // ^^ 0 no addr diversity 0 reserved 01 ib key 0000 reserved
38 // RELOC-NEXT: 60 00000000 ff0000b0
39 // ^^^^ discriminator
40 // ^^ 1 addr diversity 0 reserved 11 db key 0000 reserved
41 // RELOC-NEXT: 70 00000000 10000000
42 // ^^^^ discriminator
43 // ^^ 0 no addr diversity 0 reserved 00 ia key 0000 reserved
44 // RELOC-NEXT: 80 04000000 00000000
45 // Folded to constant 4 bytes difference between _g9 and _g8
47 .section .helper
48 .local "_g 6"
49 .type _g0, @function
50 _g0:
51 ret
52 .type _g8, @function
53 _g8:
54 ret
55 .type _g9, @function
56 _g9:
57 ret
59 .section .test
60 .p2align 3
62 // ASM: .xword _g0@AUTH(ia,42)
63 .quad _g0@AUTH(ia,42)
64 .quad 0
66 // ASM: .xword _g1@AUTH(ib,0)
67 .quad _g1@AUTH(ib,0)
68 .quad 0
70 // ASM: .xword _g2@AUTH(da,5,addr)
71 .quad _g2@AUTH(da,5,addr)
72 .quad 0
74 // ASM: .xword _g3@AUTH(db,65535,addr)
75 .quad _g3@AUTH(db,0xffff,addr)
76 .quad 0
78 // ASM: .xword (_g4+7)@AUTH(ia,0)
79 .quad (_g4 + 7)@AUTH(ia,0)
80 .quad 0
82 // ASM: .xword (_g5-3)@AUTH(ib,56832)
83 .quad (_g5 - 3)@AUTH(ib,0xde00)
84 .quad 0
86 // ASM: .xword "_g 6"@AUTH(db,255,addr)
87 .quad "_g 6"@AUTH(db,0xff,addr)
88 .quad 0
90 // ASM: .xword ("_g 7"+7)@AUTH(ia,16)
91 .quad ("_g 7" + 7)@AUTH(ia,16)
92 .quad 0
94 // ASM: .xword (_g9@AUTH(ia,42))-(_g8@AUTH(ia,42))
95 .quad _g9@AUTH(ia,42) - _g8@AUTH(ia,42)
96 .quad 0
98 .ifdef ASMONLY
100 // ASM: .xword (_g10@AUTH(ia,42))+1
101 .quad _g10@AUTH(ia,42) + 1
103 // ASM: .xword 1+(_g11@AUTH(ia,42))
104 .quad 1 + _g11@AUTH(ia,42)
106 // ASM: .xword (1+(_g12@AUTH(ia,42)))+1
107 .quad 1 + _g12@AUTH(ia,42) + 1
109 // ASM: .xword (_g13@AUTH(ia,42))+(_g14@AUTH(ia,42))
110 .quad _g13@AUTH(ia,42) + _g14@AUTH(ia,42)
112 // ASM: .xword (_g9@AUTH(ia,42))-_g8
113 .quad _g9@AUTH(ia,42) - _g8
114 .quad 0
116 .endif // ASMONLY
118 .ifdef ERR
119 // RUN: not llvm-mc -triple=aarch64 --defsym=ERR=1 %s 2>&1 | \
120 // RUN: FileCheck %s --check-prefix=ERR
122 // ERR: :[[#@LINE+1]]:15: error: expected '('
123 .quad sym@AUTH)ia,42)
125 // ERR: :[[#@LINE+1]]:16: error: expected key name
126 .quad sym@AUTH(42,42)
128 // ERR: :[[#@LINE+1]]:16: error: invalid key 'ic'
129 .quad sym@AUTH(ic,42)
131 // ERR: :[[#@LINE+1]]:19: error: expected ','
132 .quad sym@AUTH(ia 42)
134 // ERR: :[[#@LINE+1]]:19: error: expected integer discriminator
135 .quad sym@AUTH(ia,xxx)
137 // ERR: :[[#@LINE+1]]:19: error: integer discriminator 65536 out of range [0, 0xFFFF]
138 .quad sym@AUTH(ia,65536)
140 // ERR: :[[#@LINE+1]]:22: error: expected 'addr'
141 .quad sym@AUTH(ia,42,add)
143 // ERR: :[[#@LINE+1]]:21: error: expected ')'
144 .quad sym@AUTH(ia,42(
146 // ERR: :[[#@LINE+1]]:7: error: combination of @AUTH with other modifiers not supported
147 .quad sym@PLT@AUTH(ia,42)
149 // ERR: :[[#@LINE+1]]:11: error: invalid variant 'AUTH@GOT'
150 .quad sym@AUTH@GOT(ia,42)
152 // ERR: :[[#@LINE+1]]:18: error: invalid variant 'TLSDESC@AUTH'
153 .quad "long sym"@TLSDESC@AUTH(ia,42)
155 // ERR: :[[#@LINE+1]]:18: error: invalid variant 'AUTH@PLT'
156 .quad "long sym"@AUTH@PLT(ia,42)
158 // ERR: :[[#@LINE+1]]:17: error: invalid variant 'GOT@AUTH'
159 .quad (sym - 5)@GOT@AUTH(ia,42)
161 // ERR: :[[#@LINE+1]]:17: error: invalid variant 'AUTH@TLSDESC'
162 .quad (sym + 5)@AUTH@TLSDESC(ia,42)
164 // ERR: :[[#@LINE+1]]:12: error: invalid variant 'AUTH'
165 .quad +sym@AUTH(ia,42)
167 .endif // ERR
169 .ifdef ERROBJ
170 // RUN: not llvm-mc -triple=aarch64 -filetype=obj --defsym=ERROBJ=1 %s -o /dev/null 2>&1 | \
171 // RUN: FileCheck %s --check-prefix=ERROBJ
173 // ERROBJ: :[[#@LINE+1]]:7: error: expected relocatable expression
174 .quad sym@AUTH(ia,42) + 1
176 // ERROBJ: :[[#@LINE+1]]:7: error: expected relocatable expression
177 .quad 1 + sym@AUTH(ia,42)
179 // ERROBJ: :[[#@LINE+1]]:7: error: expected relocatable expression
180 .quad 1 + sym@AUTH(ia,42) + 1
182 // ERROBJ: :[[#@LINE+1]]:7: error: expected relocatable expression
183 .quad sym@AUTH(ia,42) + sym@AUTH(ia,42)
185 // TODO: do we really want to emit an error here? It might not be important
186 // whether a symbol has an AUTH modifier or not since the compile-time computed
187 // distance remains the same. Leave it in such state as for now since it
188 // makes code simpler: subtraction of a non-AUTH symbol and of a constant
189 // are handled identically.
190 // ERROBJ: :[[#@LINE+1]]:7: error: expected relocatable expression
191 .quad _g9@AUTH(ia,42) - _g8
193 .endif // ERROBJ