]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2007-02-03 Thomas Schwinge <tschwinge@gnu.org>
authortschwinge <tschwinge@localhost>
Sat, 3 Feb 2007 11:36:13 +0000 (11:36 +0000)
committertschwinge <tschwinge@localhost>
Sat, 3 Feb 2007 11:36:13 +0000 (11:36 +0000)
* aclocal.m4 (grub_CHECK_STACK_PROTECTOR): New definition.
* configure.ac: Use it for testing the HOST and TARGET compilers.

ChangeLog
aclocal.m4
configure.ac

index abd03bf0a3c2511e34871b39b0f1a71533d16481..a6dd60a80cc67ebe790c5be281b94b7ebb4c2c34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-03  Thomas Schwinge  <tschwinge@gnu.org>
+
+       * aclocal.m4 (grub_CHECK_STACK_PROTECTOR): New definition.
+       * configure.ac: Use it for testing the HOST and TARGET compilers.
+
 2006-12-13  Thomas Schwinge  <tschwinge@gnu.org>
 
        * Makefile.in (enable_grub_emu): New variable.
index a032c2aadfcdf55f70246e2615b610748456aa6f..706c3ef2150779caf9423adb8c4865a668a0842a 100644 (file)
@@ -343,3 +343,22 @@ dnl So use regparm 2 until a better test is found.
        [Catch gcc bug])
 fi
 ])
+\f
+dnl Check if the C compiler supports `-fstack-protector'.
+AC_DEFUN(grub_CHECK_STACK_PROTECTOR,[
+[# Smashing stack protector.
+ssp_possible=yes]
+AC_MSG_CHECKING([whether `$CC' accepts `-fstack-protector'])
+# Is this a reliable test case?
+AC_LANG_CONFTEST([[void foo (void) { volatile char a[8]; a[3]; }]])
+[# `$CC -c -o ...' might not be portable.  But, oh, well...  Is calling
+# `ac_compile' like this correct, after all?
+if eval "$ac_compile -S -fstack-protector -o conftest.s" 2> /dev/null; then]
+  AC_MSG_RESULT([yes])
+  [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
+  rm -f conftest.s
+else
+  ssp_possible=no]
+  AC_MSG_RESULT([no])
+[fi]
+])
index ba205b501fc6cef40b6012b95bfcb9bd9de9ee44..1c0bbfee582e40307ec7f787b57e750410591fe8 100644 (file)
@@ -148,6 +148,19 @@ fi
 # Check for functions.
 AC_CHECK_FUNCS(posix_memalign memalign)
 
+#
+# Compiler features.
+#
+
+# Smashing stack protector.
+grub_CHECK_STACK_PROTECTOR
+[# Need that, because some distributions ship compilers that include
+# `-fstack-protector' in the default specs.
+if [ x"$ssp_possible" = xyes ]; then
+  CFLAGS=$CFLAGS\ -fno-stack-protector
+fi]
+
+
 #
 # Check for target programs.
 #
@@ -225,6 +238,18 @@ if test "x$target_m32" = x1; then
   TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
 fi
 
+#
+# Compiler features.
+#
+
+# Smashing stack protector.
+grub_CHECK_STACK_PROTECTOR
+[# Need that, because some distributions ship compilers that include
+# `-fstack-protector' in the default specs.
+if [ x"$ssp_possible" = xyes ]; then
+  TARGET_CFLAGS=$TARGET_CFLAGS\ -fno-stack-protector
+fi]
+
 AC_SUBST(TARGET_CFLAGS)
 AC_SUBST(TARGET_CPPFLAGS)
 AC_SUBST(TARGET_LDFLAGS)