From 8b25e69788383ea391541033582e3908b6084ecb Mon Sep 17 00:00:00 2001 From: thopre01 Date: Thu, 7 Dec 2017 21:48:35 +0000 Subject: [PATCH] Improve fstack_protector effective target Effective target fstack_protector fails to return an error for newlib-based target (such as arm-none-eabi targets) which does not support stack protector. This is due to the test being too simplist for stack protection code to be generated by GCC: it does not contain a local buffer and does not read unknown input. This commit adds a small local buffer with a copy of the filename to trigger stack protector code to be generated. The filename is used instead of the full path so as to ensure the size will fit in the local buffer. 2017-12-07 Thomas Preud'homme gcc/testsuite/ * lib/target-supports.exp (check_effective_target_fstack_protector): Copy filename in local buffer to trigger stack protection. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255484 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/lib/target-supports.exp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dab24f42438..9f8e8373aaf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-07 Thomas Preud'homme + + * lib/target-supports.exp (check_effective_target_fstack_protector): + Copy filename in local buffer to trigger stack protection. + 2017-12-07 Joseph Myers * gcc.dg/c11-align-7.c, gcc.dg/c11-align-8.c, diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 6242ce95469..ed7d624873c 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1064,7 +1064,11 @@ proc check_effective_target_static {} { # Return 1 if the target supports -fstack-protector proc check_effective_target_fstack_protector {} { return [check_runtime fstack_protector { - int main (void) { return 0; } + #include + int main (int argc, char *argv[]) { + char buf[64]; + return !strcpy (buf, strrchr (argv[0], '/')); + } } "-fstack-protector"] } -- 2.11.4.GIT