Summary: minor, add stack to --with-error-checking to turn SSP on
authorSebastian Freundt <hroptatyr@fresse.org>
Sun, 22 Jan 2012 11:42:14 +0000 (11:42 +0000)
committerSebastian Freundt <hroptatyr@fresse.org>
Sun, 22 Jan 2012 11:42:14 +0000 (11:42 +0000)
Keywords: bldchn diagnostics

This changeset fixes a potential stack bashing in the mapfam permutation
code by inserting proper break statements where they belong.  This could
be one of the reasons of bug #135 and it's yet to be shown that it fixes
anything (other than pleasing coverity).

* configure.ac: add `stack' to the error-checking multiarg

* m4/sxe-compiler.m4: check for -fstack-protector and link with libssp

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

index 823f010..4d61bbc 100644 (file)
@@ -446,6 +446,7 @@ OG_MULTIARG_WITH([error-checking], [dnl
        OG_MULTIARG_ITEM([byte_code], [byte_code], [checks on byte compiled code])
        OG_MULTIARG_ITEM([bufpos], [bufpos], [checks on buffer position])
        OG_MULTIARG_ITEM([glyphs], [glyphs], [checks on glyph data])
+       OG_MULTIARG_ITEM([stack], [stack], [checks on stack barriers])
 ])
 
 OG_ARG_WITH([purify],
index 83d1634..7c39bcf 100644 (file)
@@ -985,14 +985,6 @@ dnl                [optiflags="$optiflags -fstrict-aliasing"])
        SXE_CHECK_COMPILER_FLAGS([-fsection-anchors],
                [optiflags="$optiflags -fsection-anchors"])
 
-dnl    ## actually this belongs to error-checking stuff
-dnl    SXE_CHECK_COMPILER_FLAGS([-fstack-protector],
-dnl            [optiflags="$optiflags -fstack-protector"])
-dnl    if test "$sxe_cv_c_flags__fstack_protector" = "yes"; then
-dnl            ## just check for ssp in this case
-dnl            AC_CHECK_LIB([ssp], [__stack_chk_guard])
-dnl    fi
-
        SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize])
        SXE_CHECK_COMPILER_FLAGS([-fbranch-target-load-optimize2])
        if test "$sxe_cv_c_flags__fbranch_target_load_optimize2" = "yes"; then
@@ -1612,6 +1604,16 @@ extern void f(void*restrict[]);
        AC_MSG_RESULT([$typeofname])
 ])dnl SXE_CHECK_BROKEN_RESTRICT        
 
+AC_DEFUN([SXE_STACK_FLAGS], [dnl
+       ## actually this belongs to error-checking stuff
+       SXE_CHECK_COMPILER_FLAGS([-fstack-protector],
+               [diagflags="${diagflags} -fstack-protector"])
+       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
+])dnl SXE_STACK_FLAGS
+
 dnl recommended interface macros
 ## compiler wrapper
 AC_DEFUN([SXE_CHECK_CC], [dnl
@@ -1662,16 +1664,24 @@ AC_DEFUN([SXE_CHECK_CFLAGS], [dnl
        dnl #### This may need to be overhauled so that all of SXEMACS_CC's flags
        dnl are handled separately, not just the xe_cflags_warning stuff.
 
+       ## diagnostic stuff and error checking
+       ## this may somehow be in contradiction to optimisation flags later on
+       ## so we issue the tests right here
+       if test "${with_error_checking_stack}" = "yes"; then
+               SXE_STACK_FLAGS
+               SXE_CFLAGS="${SXE_CFLAGS} ${diagflags}"
+       fi
+
        ## Use either command line flag, environment var, or autodetection
        if test "$with_ridiculously_aggressive_optimisations" = "yes"; then
                CFLAGS=""
                SXE_DEBUGFLAGS
                SXE_WARNFLAGS
                SXE_OPTIFLAGS
-               SXE_CFLAGS="$debugflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $debugflags $optiflags $warnflags"
 
                SXE_FEATFLAGS
-               SXE_CFLAGS="$debugflags $featflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $featflags"
 
        elif test "$CFLAGS_uspecified_p" = "no" -o \
                "$ac_test_CFLAGS" != "set"; then
@@ -1712,16 +1722,17 @@ AC_DEFUN([SXE_CHECK_CFLAGS], [dnl
                                optiflags="-O"])
                fi
 
-               SXE_CFLAGS="$debugflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $debugflags $optiflags $warnflags"
 
                SXE_FEATFLAGS
-               SXE_CFLAGS="$debugflags $featflags $optiflags $warnflags"
+               SXE_CFLAGS="$SXE_CFLAGS $featflags"
        else
-               SXE_CFLAGS=${USER_CFLAGS}
+               SXE_CFLAGS="${SXE_CFLAGS} ${USER_CFLAGS}"
                featflags=""
                debugflags=""
                optiflags=""
                warnflags=""
+               diagflags=""
        fi
 
        ## unset the werror flag again