diff options
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/fstack-protector-strong.C | 50 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fstack-protector-strong.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/ssp-strong-reg.c | 19 |
4 files changed, 93 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8918976..9092cba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-05-09 Florian Weimer <fweimer@redhat.com> + + * gcc.dg/fstack-protector-strong.c: Add coverage for return slots. + * g++.dg/fstack-protector-strong.C: Likewise. + * gcc.target/i386/ssp-strong-reg.c: New file. + 2014-05-09 Georg-Johann Lay <avr@gjlay.de> PR target/61055 diff --git a/gcc/testsuite/g++.dg/fstack-protector-strong.C b/gcc/testsuite/g++.dg/fstack-protector-strong.C index a4f0f81..5a820ed 100644 --- a/gcc/testsuite/g++.dg/fstack-protector-strong.C +++ b/gcc/testsuite/g++.dg/fstack-protector-strong.C @@ -32,4 +32,52 @@ int foo2 () return global_func (a); } -/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */ +/* Frame addressed exposed through return slot. */ + +struct B +{ + /* Discourage passing this struct in registers. */ + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; + int method (); + B return_slot(); +}; + +B global_func (); +void noop (); + +int foo3 () +{ + return global_func ().a1; +} + +int foo4 () +{ + try { + noop (); + return 0; + } catch (...) { + return global_func ().a1; + } +} + +int foo5 () +{ + try { + return global_func ().a1; + } catch (...) { + return 0; + } +} + +int foo6 () +{ + B b; + return b.method (); +} + +int foo7 (B *p) +{ + return p->return_slot ().a1; +} + +/* { dg-final { scan-assembler-times "stack_chk_fail" 7 } } */ diff --git a/gcc/testsuite/gcc.dg/fstack-protector-strong.c b/gcc/testsuite/gcc.dg/fstack-protector-strong.c index 7c232ff..da33abb 100644 --- a/gcc/testsuite/gcc.dg/fstack-protector-strong.c +++ b/gcc/testsuite/gcc.dg/fstack-protector-strong.c @@ -131,4 +131,22 @@ foo10 () return bb.three; } -/* { dg-final { scan-assembler-times "stack_chk_fail" 10 } } */ +struct B +{ + /* Discourage passing this struct in registers. */ + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; +}; + +struct B global3 (void); + +int foo11 () +{ + return global3 ().a1; +} + +void foo12 () +{ + global3 (); +} + +/* { dg-final { scan-assembler-times "stack_chk_fail" 12 } } */ diff --git a/gcc/testsuite/gcc.target/i386/ssp-strong-reg.c b/gcc/testsuite/gcc.target/i386/ssp-strong-reg.c new file mode 100644 index 0000000..9fe5664 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/ssp-strong-reg.c @@ -0,0 +1,19 @@ +/* Test that structs returned in registers do not lead to + instrumentation with -fstack-protector-strong. */ + +/* { dg-do compile { target { ! { ia32 } } } } */ +/* { dg-options "-O2 -fstack-protector-strong" } */ + +struct S { + int a; + int b; +}; + +struct S f (void); + +int g (void) +{ + return f ().a; +} + +/* { dg-final { scan-assembler-times "stack_chk_fail" 0 } } */ |