This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, testsuite] Remove static from __stack_chk_fail in gcc.dg/ssp-1.c
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Apr 2009 18:21:48 -0700
- Subject: Re: [PATCH, testsuite] Remove static from __stack_chk_fail in gcc.dg/ssp-1.c
- References: <firstname.lastname@example.org>
Adam Nemet <email@example.com> writes:
> As I reported in my MIPS -fstack-protector patch this test is failing on MIPS.
> __stack_chk_fail is an internal function to the GCC runtime (libssp), however,
> the tests ssp-1.c and ssp-2.c redefine it as a way to signal the outcome of
> the tests.
> In ssp-1.c the function is defined static while in
> default_hidden_stack_protect_fail it is declared global. This is not valid C;
> a static declaration cannot follow a non-static but this being an internal
> function we don't diagnose in pushdecl.
I should probably repeat in this thread too how the above leads to a failure
on MIPS. We generate the call to __stack_chk_fail as if it was a global
function using a call16 relocation which then confuses the linker:
ld: ssp-1.o: CALL16 reloc at 0xb4 not against global symbol
> The patch below removes the static (in ssp-2.c the function in non-static).
> The test now passes (together with MIPS -fstack-protector patch) and does not
> regress on x86_64-linux either.
> * gcc.dg/ssp-1.c (__stack_chk_fail): Remove static.
> Index: ssp-1.c
> --- ssp-1.c (revision 146303)
> +++ ssp-1.c (working copy)
> @@ -4,7 +4,7 @@
> #include <stdlib.h>
> -static void
> __stack_chk_fail (void)
> exit (0); /* pass */