1 | // Tests that global tags wrap around successfully after tag 0xff on aarch64 or |
2 | // 0x3f on x86_64. |
3 | // RUN: %clang_hwasan %s -o %t |
4 | // RUN: %run %t 0 |
5 | |
6 | #include <stdlib.h> |
7 | |
8 | // Create >256 globals to ensure every tag is used. |
9 | int x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, |
10 | x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31, |
11 | x32, x33, x34, x35, x36, x37, x38, x39, x40, x41, x42, x43, x44, x45, x46, |
12 | x47, x48, x49, x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x60, x61, |
13 | x62, x63, x64, x65, x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, |
14 | x77, x78, x79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, |
15 | x92, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104, x105, |
16 | x106, x107, x108, x109, x110, x111, x112, x113, x114, x115, x116, x117, |
17 | x118, x119, x120, x121, x122, x123, x124, x125, x126, x127, x128, x129, |
18 | x130, x131, x132, x133, x134, x135, x136, x137, x138, x139, x140, x141, |
19 | x142, x143, x144, x145, x146, x147, x148, x149, x150, x151, x152, x153, |
20 | x154, x155, x156, x157, x158, x159, x160, x161, x162, x163, x164, x165, |
21 | x166, x167, x168, x169, x170, x171, x172, x173, x174, x175, x176, x177, |
22 | x178, x179, x180, x181, x182, x183, x184, x185, x186, x187, x188, x189, |
23 | x190, x191, x192, x193, x194, x195, x196, x197, x198, x199, x200, x201, |
24 | x202, x203, x204, x205, x206, x207, x208, x209, x210, x211, x212, x213, |
25 | x214, x215, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225, |
26 | x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236, x237, |
27 | x238, x239, x240, x241, x242, x243, x244, x245, x246, x247, x248, x249, |
28 | x250, x251, x252, x253, x254, x255, x256; |
29 | |
30 | int main(int argc, char **argv) { |
31 | int i = atoi(nptr: argv[1]); |
32 | |
33 | // Write to every global to make sure tags match even after wrapping around |
34 | // to 0. |
35 | (&x0)[i] = 1; |
36 | (&x1)[i] = 1; |
37 | (&x2)[i] = 1; |
38 | (&x3)[i] = 1; |
39 | (&x4)[i] = 1; |
40 | (&x5)[i] = 1; |
41 | (&x6)[i] = 1; |
42 | (&x7)[i] = 1; |
43 | (&x8)[i] = 1; |
44 | (&x9)[i] = 1; |
45 | (&x10)[i] = 1; |
46 | (&x11)[i] = 1; |
47 | (&x12)[i] = 1; |
48 | (&x13)[i] = 1; |
49 | (&x14)[i] = 1; |
50 | (&x15)[i] = 1; |
51 | (&x16)[i] = 1; |
52 | (&x17)[i] = 1; |
53 | (&x18)[i] = 1; |
54 | (&x19)[i] = 1; |
55 | (&x20)[i] = 1; |
56 | (&x21)[i] = 1; |
57 | (&x22)[i] = 1; |
58 | (&x23)[i] = 1; |
59 | (&x24)[i] = 1; |
60 | (&x25)[i] = 1; |
61 | (&x26)[i] = 1; |
62 | (&x27)[i] = 1; |
63 | (&x28)[i] = 1; |
64 | (&x29)[i] = 1; |
65 | (&x30)[i] = 1; |
66 | (&x31)[i] = 1; |
67 | (&x32)[i] = 1; |
68 | (&x33)[i] = 1; |
69 | (&x34)[i] = 1; |
70 | (&x35)[i] = 1; |
71 | (&x36)[i] = 1; |
72 | (&x37)[i] = 1; |
73 | (&x38)[i] = 1; |
74 | (&x39)[i] = 1; |
75 | (&x40)[i] = 1; |
76 | (&x41)[i] = 1; |
77 | (&x42)[i] = 1; |
78 | (&x43)[i] = 1; |
79 | (&x44)[i] = 1; |
80 | (&x45)[i] = 1; |
81 | (&x46)[i] = 1; |
82 | (&x47)[i] = 1; |
83 | (&x48)[i] = 1; |
84 | (&x49)[i] = 1; |
85 | (&x50)[i] = 1; |
86 | (&x51)[i] = 1; |
87 | (&x52)[i] = 1; |
88 | (&x53)[i] = 1; |
89 | (&x54)[i] = 1; |
90 | (&x55)[i] = 1; |
91 | (&x56)[i] = 1; |
92 | (&x57)[i] = 1; |
93 | (&x58)[i] = 1; |
94 | (&x59)[i] = 1; |
95 | (&x60)[i] = 1; |
96 | (&x61)[i] = 1; |
97 | (&x62)[i] = 1; |
98 | (&x63)[i] = 1; |
99 | (&x64)[i] = 1; |
100 | (&x65)[i] = 1; |
101 | (&x66)[i] = 1; |
102 | (&x67)[i] = 1; |
103 | (&x68)[i] = 1; |
104 | (&x69)[i] = 1; |
105 | (&x70)[i] = 1; |
106 | (&x71)[i] = 1; |
107 | (&x72)[i] = 1; |
108 | (&x73)[i] = 1; |
109 | (&x74)[i] = 1; |
110 | (&x75)[i] = 1; |
111 | (&x76)[i] = 1; |
112 | (&x77)[i] = 1; |
113 | (&x78)[i] = 1; |
114 | (&x79)[i] = 1; |
115 | (&x80)[i] = 1; |
116 | (&x81)[i] = 1; |
117 | (&x82)[i] = 1; |
118 | (&x83)[i] = 1; |
119 | (&x84)[i] = 1; |
120 | (&x85)[i] = 1; |
121 | (&x86)[i] = 1; |
122 | (&x87)[i] = 1; |
123 | (&x88)[i] = 1; |
124 | (&x89)[i] = 1; |
125 | (&x90)[i] = 1; |
126 | (&x91)[i] = 1; |
127 | (&x92)[i] = 1; |
128 | (&x93)[i] = 1; |
129 | (&x94)[i] = 1; |
130 | (&x95)[i] = 1; |
131 | (&x96)[i] = 1; |
132 | (&x97)[i] = 1; |
133 | (&x98)[i] = 1; |
134 | (&x99)[i] = 1; |
135 | (&x100)[i] = 1; |
136 | (&x101)[i] = 1; |
137 | (&x102)[i] = 1; |
138 | (&x103)[i] = 1; |
139 | (&x104)[i] = 1; |
140 | (&x105)[i] = 1; |
141 | (&x106)[i] = 1; |
142 | (&x107)[i] = 1; |
143 | (&x108)[i] = 1; |
144 | (&x109)[i] = 1; |
145 | (&x110)[i] = 1; |
146 | (&x111)[i] = 1; |
147 | (&x112)[i] = 1; |
148 | (&x113)[i] = 1; |
149 | (&x114)[i] = 1; |
150 | (&x115)[i] = 1; |
151 | (&x116)[i] = 1; |
152 | (&x117)[i] = 1; |
153 | (&x118)[i] = 1; |
154 | (&x119)[i] = 1; |
155 | (&x120)[i] = 1; |
156 | (&x121)[i] = 1; |
157 | (&x122)[i] = 1; |
158 | (&x123)[i] = 1; |
159 | (&x124)[i] = 1; |
160 | (&x125)[i] = 1; |
161 | (&x126)[i] = 1; |
162 | (&x127)[i] = 1; |
163 | (&x128)[i] = 1; |
164 | (&x129)[i] = 1; |
165 | (&x130)[i] = 1; |
166 | (&x131)[i] = 1; |
167 | (&x132)[i] = 1; |
168 | (&x133)[i] = 1; |
169 | (&x134)[i] = 1; |
170 | (&x135)[i] = 1; |
171 | (&x136)[i] = 1; |
172 | (&x137)[i] = 1; |
173 | (&x138)[i] = 1; |
174 | (&x139)[i] = 1; |
175 | (&x140)[i] = 1; |
176 | (&x141)[i] = 1; |
177 | (&x142)[i] = 1; |
178 | (&x143)[i] = 1; |
179 | (&x144)[i] = 1; |
180 | (&x145)[i] = 1; |
181 | (&x146)[i] = 1; |
182 | (&x147)[i] = 1; |
183 | (&x148)[i] = 1; |
184 | (&x149)[i] = 1; |
185 | (&x150)[i] = 1; |
186 | (&x151)[i] = 1; |
187 | (&x152)[i] = 1; |
188 | (&x153)[i] = 1; |
189 | (&x154)[i] = 1; |
190 | (&x155)[i] = 1; |
191 | (&x156)[i] = 1; |
192 | (&x157)[i] = 1; |
193 | (&x158)[i] = 1; |
194 | (&x159)[i] = 1; |
195 | (&x160)[i] = 1; |
196 | (&x161)[i] = 1; |
197 | (&x162)[i] = 1; |
198 | (&x163)[i] = 1; |
199 | (&x164)[i] = 1; |
200 | (&x165)[i] = 1; |
201 | (&x166)[i] = 1; |
202 | (&x167)[i] = 1; |
203 | (&x168)[i] = 1; |
204 | (&x169)[i] = 1; |
205 | (&x170)[i] = 1; |
206 | (&x171)[i] = 1; |
207 | (&x172)[i] = 1; |
208 | (&x173)[i] = 1; |
209 | (&x174)[i] = 1; |
210 | (&x175)[i] = 1; |
211 | (&x176)[i] = 1; |
212 | (&x177)[i] = 1; |
213 | (&x178)[i] = 1; |
214 | (&x179)[i] = 1; |
215 | (&x180)[i] = 1; |
216 | (&x181)[i] = 1; |
217 | (&x182)[i] = 1; |
218 | (&x183)[i] = 1; |
219 | (&x184)[i] = 1; |
220 | (&x185)[i] = 1; |
221 | (&x186)[i] = 1; |
222 | (&x187)[i] = 1; |
223 | (&x188)[i] = 1; |
224 | (&x189)[i] = 1; |
225 | (&x190)[i] = 1; |
226 | (&x191)[i] = 1; |
227 | (&x192)[i] = 1; |
228 | (&x193)[i] = 1; |
229 | (&x194)[i] = 1; |
230 | (&x195)[i] = 1; |
231 | (&x196)[i] = 1; |
232 | (&x197)[i] = 1; |
233 | (&x198)[i] = 1; |
234 | (&x199)[i] = 1; |
235 | (&x200)[i] = 1; |
236 | (&x201)[i] = 1; |
237 | (&x202)[i] = 1; |
238 | (&x203)[i] = 1; |
239 | (&x204)[i] = 1; |
240 | (&x205)[i] = 1; |
241 | (&x206)[i] = 1; |
242 | (&x207)[i] = 1; |
243 | (&x208)[i] = 1; |
244 | (&x209)[i] = 1; |
245 | (&x210)[i] = 1; |
246 | (&x211)[i] = 1; |
247 | (&x212)[i] = 1; |
248 | (&x213)[i] = 1; |
249 | (&x214)[i] = 1; |
250 | (&x215)[i] = 1; |
251 | (&x216)[i] = 1; |
252 | (&x217)[i] = 1; |
253 | (&x218)[i] = 1; |
254 | (&x219)[i] = 1; |
255 | (&x220)[i] = 1; |
256 | (&x221)[i] = 1; |
257 | (&x222)[i] = 1; |
258 | (&x223)[i] = 1; |
259 | (&x224)[i] = 1; |
260 | (&x225)[i] = 1; |
261 | (&x226)[i] = 1; |
262 | (&x227)[i] = 1; |
263 | (&x228)[i] = 1; |
264 | (&x229)[i] = 1; |
265 | (&x230)[i] = 1; |
266 | (&x231)[i] = 1; |
267 | (&x232)[i] = 1; |
268 | (&x233)[i] = 1; |
269 | (&x234)[i] = 1; |
270 | (&x235)[i] = 1; |
271 | (&x236)[i] = 1; |
272 | (&x237)[i] = 1; |
273 | (&x238)[i] = 1; |
274 | (&x239)[i] = 1; |
275 | (&x240)[i] = 1; |
276 | (&x241)[i] = 1; |
277 | (&x242)[i] = 1; |
278 | (&x243)[i] = 1; |
279 | (&x244)[i] = 1; |
280 | (&x245)[i] = 1; |
281 | (&x246)[i] = 1; |
282 | (&x247)[i] = 1; |
283 | (&x248)[i] = 1; |
284 | (&x249)[i] = 1; |
285 | (&x250)[i] = 1; |
286 | (&x251)[i] = 1; |
287 | (&x252)[i] = 1; |
288 | (&x253)[i] = 1; |
289 | (&x254)[i] = 1; |
290 | (&x255)[i] = 1; |
291 | (&x256)[i] = 1; |
292 | |
293 | return 0; |
294 | } |
295 | |