-fstack-protector-strong: Instrumentation for return slots
authorFlorian Weimer <fweimer@redhat.com>
Fri, 9 May 2014 12:23:46 +0000 (14:23 +0200)
committerFlorian Weimer <fw@gcc.gnu.org>
Fri, 9 May 2014 12:23:46 +0000 (14:23 +0200)
commit6545746e3c784d94300954ccb155e6510c598ffa
tree6da35ec3f858b95d454e7bb32fb9dd5f8dc6c95c
parentb8d29c66597d6ff2a41ca6a190c0bd52126f491d
-fstack-protector-strong: Instrumentation for return slots

This patch fixes a loophole in the -fstack-protector-strong protection.
If a function call uses a return slot, the caller needs stack protector
instrumentation because the return slot is addressable.

gcc/

2014-05-09  Florian Weimer  <fweimer@redhat.com>

* cfgexpand.c (stack_protect_decl_p): New function, extracted from
expand_used_vars.
(stack_protect_return_slot_p): New function.
(expand_used_vars): Call stack_protect_decl_p and
stack_protect_return_slot_p for -fstack-protector-strong.

gcc/testsuite/

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.

From-SVN: r210275
gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/fstack-protector-strong.C
gcc/testsuite/gcc.dg/fstack-protector-strong.c
gcc/testsuite/gcc.target/i386/ssp-strong-reg.c [new file with mode: 0644]