| 1 |
/* Test that stack protection is done on chosen functions. */ |
| 2 |
|
| 3 |
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ |
| 4 |
/* { dg-options "-O2 -fstack-protector-explicit" } */ |
| 5 |
/* { dg-additional-options "-fno-PIE" { target ia32 } } */ |
| 6 |
|
| 7 |
int A() |
| 8 |
{ |
| 9 |
int A[23]; |
| 10 |
char b[22]; |
| 11 |
return 0; |
| 12 |
} |
| 13 |
|
| 14 |
int __attribute__((stack_protect)) B() |
| 15 |
{ |
| 16 |
int a; |
| 17 |
int b; |
| 18 |
return a+b; |
| 19 |
} |
| 20 |
|
| 21 |
int __attribute__((stack_protect)) c() |
| 22 |
{ |
| 23 |
int a; |
| 24 |
char b[34]; |
| 25 |
return 0; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */ |