[coreboot] Patch set updated: 56440ee mkelfImage: Use -fno-stack-protector if supported by gcc

Raymond Danks (raymonddanks@gmail.com) gerrit at coreboot.org
Sun Sep 4 05:50:44 CEST 2011


Raymond Danks (raymonddanks at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/112

-gerrit

commit 56440ee651a1508722d3256003fe66d126b0f8e5
Author: Raymond Danks <raymonddanks at gmail.com>
Date:   Sat Sep 3 21:45:38 2011 -0600

    mkelfImage: Use -fno-stack-protector if supported by gcc
    
    Gcc 4.1 comes with an SSP https://wiki.ubuntu.com/GccSsp
    This is disabled to work around '__stack_chk_fail' symbol not found failures
    http://www.coreboot.org/FAQ/Obsolete#How_do_I_fix_stack_chk_fail_errors.3F
    
    The presence of -fno-stack-protector is tested for automatically by configure.
    
    Change-Id: I28ef158829f5935f985cfd5a5440733685cf479a
    Reported-by: Raymond Danks <raymonddanks at gmail.com>
    Signed-off-by: Raymond Danks <raymonddanks at gmail.com>
---
 util/mkelfImage/configure    |   38 +++++++++++++++++++++++++++++++++++++-
 util/mkelfImage/configure.ac |   21 +++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/util/mkelfImage/configure b/util/mkelfImage/configure
index b3021de..150e5c8 100755
--- a/util/mkelfImage/configure
+++ b/util/mkelfImage/configure
@@ -690,6 +690,7 @@ IA64_LD
 IA64_AS
 IA64_OBJCOPY
 HOST_CC
+libc_cv_fno_stack_protector
 HOST_CFLAGS
 I386_CFLAGS
 I386_ASFLAGS
@@ -4963,6 +4964,40 @@ IA64_LDFLAGS='-static --warn-multiple-gp --warn-common'
 
 
 
+{ echo "$as_me:$LINENO: checking for -fno-stack-protector" >&5
+echo $ECHO_N "checking for -fno-stack-protector... $ECHO_C" >&6; }
+if test "${libc_cv_fno_stack_protector+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat > conftest.c <<EOF
+int foo;
+main () { return 0;}
+EOF
+if { ac_try='$I386_CC -fno-stack-protector
+                           -o conftest conftest.c 1>&5'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }
+then
+  libc_cv_fno_stack_protector=yes
+else
+  libc_cv_fno_stack_protector=no
+fi
+rm -f conftest*
+fi
+{ echo "$as_me:$LINENO: result: $libc_cv_fno_stack_protector" >&5
+echo "${ECHO_T}$libc_cv_fno_stack_protector" >&6; }
+if test $libc_cv_fno_stack_protector = yes; then
+  I386_CFLAGS="$I386_CFLAGS -fno-stack-protector"
+  IA64_CFLAGS="$IA64_CFLAGS -fno-stack-protector"
+
+fi
+
+
+
 
 
 
@@ -5689,6 +5724,7 @@ IA64_LD!$IA64_LD$ac_delim
 IA64_AS!$IA64_AS$ac_delim
 IA64_OBJCOPY!$IA64_OBJCOPY$ac_delim
 HOST_CC!$HOST_CC$ac_delim
+libc_cv_fno_stack_protector!$libc_cv_fno_stack_protector$ac_delim
 HOST_CFLAGS!$HOST_CFLAGS$ac_delim
 I386_CFLAGS!$I386_CFLAGS$ac_delim
 I386_ASFLAGS!$I386_ASFLAGS$ac_delim
@@ -5700,7 +5736,7 @@ LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 87; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/util/mkelfImage/configure.ac b/util/mkelfImage/configure.ac
index 7aebd36..a7fc37e 100644
--- a/util/mkelfImage/configure.ac
+++ b/util/mkelfImage/configure.ac
@@ -186,6 +186,27 @@ IA64_ASFLAGS='-mconstant-gp -mauto-pic'
 IA64_LDFLAGS='-static --warn-multiple-gp --warn-common'
 
 AC_SUBST([HOST_CC])
+
+AC_CACHE_CHECK(for -fno-stack-protector, libc_cv_fno_stack_protector, [
+cat > conftest.c <<EOF
+int foo;
+main () { return 0;}
+EOF
+if AC_TRY_COMMAND([$I386_CC -fno-stack-protector
+                           -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
+then
+  libc_cv_fno_stack_protector=yes
+else
+  libc_cv_fno_stack_protector=no
+fi
+rm -f conftest*])
+if test $libc_cv_fno_stack_protector = yes; then
+  I386_CFLAGS="$I386_CFLAGS -fno-stack-protector"
+  IA64_CFLAGS="$IA64_CFLAGS -fno-stack-protector"
+  
+fi
+AC_SUBST(libc_cv_fno_stack_protector)
+
 AC_SUBST([HOST_CFLAGS])
 
 AC_SUBST([I386_CC])




More information about the coreboot mailing list