From 0accb2cab89728b266a3d3fee58d1a1d5d1a0e28 Mon Sep 17 00:00:00 2001 From: okuji Date: Sun, 4 Apr 2004 09:15:43 +0000 Subject: [PATCH] 2004-04-04 Yoshinori K. Okuji * configure.ac (STAGE2_CFLAGS): Check if -fno-stack-protector is supported by GCC. If yes, added the option. This is necessary for OpenBSD, because the stack protector defines additional symbols. Reported by uc.sheda . --- ChangeLog | 7 ++++++ configure | 54 +++++++++++++++++++++++++++++++++++++++++++ configure.ac | 15 ++++++++++++ docs/grub-install.8 | 2 +- docs/grub-md5-crypt.8 | 2 +- docs/grub-terminfo.8 | 2 +- docs/grub.8 | 2 +- grub/Makefile.in | 2 +- netboot/Makefile.in | 2 +- 9 files changed, 82 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 673b96419..798b7838c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-04-04 Yoshinori K. Okuji + + * configure.ac (STAGE2_CFLAGS): Check if -fno-stack-protector is + supported by GCC. If yes, added the option. This is necessary + for OpenBSD, because the stack protector defines additional + symbols. Reported by uc.sheda . + 2004-03-28 Pavel Roskin * stage2/boot.c: Imply --no-mem-option for Linux kernels with diff --git a/configure b/configure index c26ea52cd..50a6ea3d3 100644 --- a/configure +++ b/configure @@ -3289,6 +3289,60 @@ echo "${ECHO_T}$size_flag" >&6 else STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops" fi + # OpenBSD has a GCC extension for protecting applications from + # stack smashing attacks, but GRUB doesn't want this feature. + echo "$as_me:$LINENO: checking whether gcc has -fno-stack-protector" >&5 +echo $ECHO_N "checking whether gcc has -fno-stack-protector... $ECHO_C" >&6 +if test "${no_stack_protector_flag+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + saved_CFLAGS=$CFLAGS + CFLAGS="-fno-stack-protector" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (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 + no_stack_protector_flag=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +no_stack_protector_flag=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + CFLAGS=$saved_CFLAGS + +fi +echo "$as_me:$LINENO: result: $no_stack_protector_flag" >&5 +echo "${ECHO_T}$no_stack_protector_flag" >&6 + if test "x$no_stack_protector_flag" = xyes; then + STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector" + fi fi fi diff --git a/configure.ac b/configure.ac index 8bb18b56a..14e75b1c0 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,21 @@ if test "x$ac_cv_prog_gcc" = xyes; then else STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops" fi + # OpenBSD has a GCC extension for protecting applications from + # stack smashing attacks, but GRUB doesn't want this feature. + AC_CACHE_CHECK([whether gcc has -fno-stack-protector], + no_stack_protector_flag, [ + saved_CFLAGS=$CFLAGS + CFLAGS="-fno-stack-protector" + AC_TRY_COMPILE(, + , + no_stack_protector_flag=yes, + no_stack_protector_flag=no) + CFLAGS=$saved_CFLAGS + ]) + if test "x$no_stack_protector_flag" = xyes; then + STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector" + fi fi fi diff --git a/docs/grub-install.8 b/docs/grub-install.8 index a89affe98..21e3cef2e 100644 --- a/docs/grub-install.8 +++ b/docs/grub-install.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB-INSTALL "8" "March 2004" "grub-install (GNU GRUB 0.94)" FSF +.TH GRUB-INSTALL "8" "April 2004" "grub-install (GNU GRUB 0.94)" FSF .SH NAME grub-install \- install GRUB on your drive .SH SYNOPSIS diff --git a/docs/grub-md5-crypt.8 b/docs/grub-md5-crypt.8 index 28505648c..cb05cdb7d 100644 --- a/docs/grub-md5-crypt.8 +++ b/docs/grub-md5-crypt.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB-MD5-CRYPT "8" "March 2004" "grub-md5-crypt (GNU GRUB )" FSF +.TH GRUB-MD5-CRYPT "8" "April 2004" "grub-md5-crypt (GNU GRUB )" FSF .SH NAME grub-md5-crypt \- Encrypt a password in MD5 format .SH SYNOPSIS diff --git a/docs/grub-terminfo.8 b/docs/grub-terminfo.8 index 869d08c43..3485d3944 100644 --- a/docs/grub-terminfo.8 +++ b/docs/grub-terminfo.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB-TERMINFO "8" "March 2004" "grub-terminfo (GNU GRUB 0.94)" FSF +.TH GRUB-TERMINFO "8" "April 2004" "grub-terminfo (GNU GRUB 0.94)" FSF .SH NAME grub-terminfo \- Generate a terminfo command from a terminfo name .SH SYNOPSIS diff --git a/docs/grub.8 b/docs/grub.8 index acaa41c82..1cd63e486 100644 --- a/docs/grub.8 +++ b/docs/grub.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB "8" "March 2004" "grub (GNU GRUB 0.94)" FSF +.TH GRUB "8" "April 2004" "grub (GNU GRUB 0.94)" FSF .SH NAME grub \- the grub shell .SH SYNOPSIS diff --git a/grub/Makefile.in b/grub/Makefile.in index 2da761b2b..eef7a20fc 100644 --- a/grub/Makefile.in +++ b/grub/Makefile.in @@ -142,9 +142,9 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ sbin_PROGRAMS = grub +@SERIAL_SPEED_SIMULATION_FALSE@SERIAL_FLAGS = -DSUPPORT_SERIAL=1 @SERIAL_SPEED_SIMULATION_TRUE@SERIAL_FLAGS = -DSUPPORT_SERIAL=1 -DSIMULATE_SLOWNESS_OF_SERIAL=1 -@SERIAL_SPEED_SIMULATION_FALSE@SERIAL_FLAGS = -DSUPPORT_SERIAL=1 AM_CPPFLAGS = -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 \ -DFSYS_FFS=1 -DFSYS_MINIX=1 -DSUPPORT_HERCULES=1 \ diff --git a/netboot/Makefile.in b/netboot/Makefile.in index e08f91a0a..07494505d 100644 --- a/netboot/Makefile.in +++ b/netboot/Makefile.in @@ -144,10 +144,10 @@ target_alias = @target_alias@ # For and . INCLUDES = -I$(top_srcdir)/stage2 -I$(top_srcdir)/stage1 +@NETBOOT_SUPPORT_FALSE@LIBDRIVERS = # Don't build the netboot support by default. @NETBOOT_SUPPORT_TRUE@LIBDRIVERS = libdrivers.a -@NETBOOT_SUPPORT_FALSE@LIBDRIVERS = noinst_LIBRARIES = $(LIBDRIVERS)