This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, testsuite] Remove static from __stack_chk_fail in gcc.dg/ssp-1.c


Adam Nemet <anemet@caviumnetworks.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

Adam

> 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.
>
> OK?
>
> Adam
>
> 	* 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
> +void
>  __stack_chk_fail (void)
>  {
>    exit (0); /* pass */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]