https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124011
Bug ID: 124011
Summary: Checking for target supports -fstack-protector fails
on mingw
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: testsuite
Assignee: unassigned at gcc dot gnu.org
Reporter: nightstrike at gmail dot com
Target Milestone: ---
On Windows systems (at least under Wine), libssp is supported, but the
testsuite check to determine this fails to do so. The current test checks for
a / style path separator, which under Wine or on Windows is \. Conceptually,
though, the test doesn't actually check that libssp is available and working,
which is why the test was modified previously under r255484 (commit
38b28c6eb28463feadfc7e18d553f8f2327a2219). The following idea illustrates how
we can override the SSP error handling to return a DejaGNU "success" while
having any other solution result in a DejaGNU "failure":
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index d4885070f6e..c20d2b567bd 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1406,10 +1406,16 @@ proc check_effective_target_fstack_protector {} {
return 0;
}
return [check_runtime fstack_protector {
- #include <string.h>
- int main (int argc, char *argv[]) {
+ void __stack_chk_fail(void) {
+ _Exit(0);
+ }
+ void f() {
char buf[64];
- return !strcpy (buf, strrchr (argv[0], '/'));
+ strcpy (buf,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+ }
+ int main() {
+ f();
+ __builtin_abort();
}
} "-fstack-protector"]
}
Originally, I thought that the test could return -1 from main() indiciating a
failure, but Iains on IRC mentioned that the test should call abort() instead.
Since the SSP is only checked after the function returns, it has to be factored
out into a helper function to allow main() to call abort in the case that the
SSP doesn't handle it.
I hope someone can take this idea and run with it.