| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target hwaddress_exec } */ |
| 3 |
|
| 4 |
/* Basic tests for stack tagging. |
| 5 |
|
| 6 |
0) Valid accesses work. |
| 7 |
1) Accesses outside of a variable crash. |
| 8 |
*/ |
| 9 |
int __attribute__ ((noinline)) |
| 10 |
accessing_pointers (int *left, int *right) |
| 11 |
{ |
| 12 |
int x = right[2]; |
| 13 |
left[3] = right[1]; |
| 14 |
return right[1] + left[2]; |
| 15 |
} |
| 16 |
|
| 17 |
int __attribute__ ((noinline)) |
| 18 |
using_stack (int num) |
| 19 |
{ |
| 20 |
int big_array[10]; |
| 21 |
int other_array[20]; |
| 22 |
accessing_pointers(other_array, big_array); |
| 23 |
return big_array[num]; |
| 24 |
} |
| 25 |
|
| 26 |
#ifndef ARG |
| 27 |
#define ARG 0 |
| 28 |
#endif |
| 29 |
|
| 30 |
int global; |
| 31 |
|
| 32 |
int __attribute__ ((noinline)) |
| 33 |
main () |
| 34 |
{ |
| 35 |
global += using_stack (ARG); |
| 36 |
return 0; |
| 37 |
} |