| 1 |
/* { dg-do run { target fstack_protector } } */ |
| 2 |
/* { dg-options "-O2 -fstack-protector-all -mstack-protector-guard=global" } */ |
| 3 |
|
| 4 |
#include <stdlib.h> |
| 5 |
|
| 6 |
#ifdef __LP64__ |
| 7 |
const unsigned long int __stack_chk_guard = 0x2d853605a4d9a09cUL; |
| 8 |
#else |
| 9 |
const unsigned long int __stack_chk_guard = 0xdd2cc927UL; |
| 10 |
#endif |
| 11 |
|
| 12 |
void |
| 13 |
__stack_chk_fail (void) |
| 14 |
{ |
| 15 |
exit (0); /* pass */ |
| 16 |
} |
| 17 |
|
| 18 |
__attribute__ ((noipa)) |
| 19 |
void |
| 20 |
smash (char *p, int i) |
| 21 |
{ |
| 22 |
p[i] = 42; |
| 23 |
} |
| 24 |
|
| 25 |
int |
| 26 |
main (void) |
| 27 |
{ |
| 28 |
char foo[255]; |
| 29 |
|
| 30 |
/* smash stack */ |
| 31 |
for (int i = 0; i <= 400; i++) |
| 32 |
smash (foo, i); |
| 33 |
|
| 34 |
return 1; |
| 35 |
} |