Summary: fix, make sure ssp actually works before using it
authorSebastian Freundt <hroptatyr@fresse.org>
Tue, 24 Jan 2012 23:45:43 +0000 (23:45 +0000)
committerSebastian Freundt <hroptatyr@fresse.org>
Tue, 24 Jan 2012 23:45:43 +0000 (23:45 +0000)
Keywords: bldchn diagnostics

This changeset hopefully resolves the issue Nelson had with ssp and
-fstack-protector.  Using crystal ball technology and rune readings
it turns out that gcc single-handedly adds -lssp as soon as
-fstack-protector is specified, regardless if it works or exists.

* m4/sxe-compiler.m4 (SXE_STACK_FLAGS): check if ssp works before adding
  -fstack-protector

Signed-off-by: Sebastian Freundt <hroptatyr@fresse.org>
m4/sxe-compiler.m4

index 12fd03b..d27ed6d 100644 (file)
@@ -1606,12 +1606,18 @@ extern void f(void*restrict[]);
 
 AC_DEFUN([SXE_STACK_FLAGS], [dnl
        ## actually this belongs to error-checking stuff
-       SXE_CHECK_COMPILER_FLAGS([-fstack-protector],
-               [diagflags="${diagflags} -fstack-protector"])
+       SXE_CHECK_COMPILER_FLAGS([-fstack-protector])
+       ## check if ssp is actually working
        if test "${sxe_cv_c_flags__fstack_protector}" = "yes"; then
                ## just check for ssp in this case
                AC_CHECK_LIB([ssp], [__stack_chk_guard])
        fi
+       ## final thing
+       if test "${sxe_cv_c_flags__fstack_protector}" = "yes" -a \
+               "${ac_cv_lib_ssp___stack_chk_guard}" = "yes"; then
+               ## only if ssp is guaranteed to work
+               diagflags="${diagflags} -fstack-protector"
+       fi
 ])dnl SXE_STACK_FLAGS
 
 dnl recommended interface macros