[2012] 2009-03-04 Bean <[email protected]>

Bean <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2012
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2012
Author:   bean
Date:     2009-03-04 05:56:31 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
2009-03-04  Bean  <[email protected]>

	* configure.ac: Only test -mcmodel=large option in x86_64-efi, also add
	another option -mno-red-zone.

	* commands/handler.c: Change module description.

	* kern/handler.c: Add missing space at the end of description line.

	* kern/list.c: Likewise.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/DISTLIST
    trunk/grub2/commands/handler.c
    trunk/grub2/configure
    trunk/grub2/configure.ac
    trunk/grub2/kern/handler.c
    trunk/grub2/kern/list.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/ChangeLog	2009-03-04 05:56:31 UTC (rev 2012)
@@ -1,3 +1,14 @@
+2009-03-04  Bean  <[email protected]>
+
+	* configure.ac: Only test -mcmodel=large option in x86_64-efi, also add
+	another option -mno-red-zone.
+
+	* commands/handler.c: Change module description.
+
+	* kern/handler.c: Add missing space at the end of description line.
+
+	* kern/list.c: Likewise.
+
 2009-03-03  Robert Millan  <[email protected]>
 
 	Move more components to the relocation area, and fix mbi pointer

Modified: trunk/grub2/DISTLIST
===================================================================
--- trunk/grub2/DISTLIST	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/DISTLIST	2009-03-04 05:56:31 UTC (rev 2012)
@@ -61,7 +61,6 @@
 commands/reboot.c
 commands/search.c
 commands/sleep.c
-commands/terminal.c
 commands/test.c
 commands/usbtest.c
 commands/videotest.c

Modified: trunk/grub2/commands/handler.c
===================================================================
--- trunk/grub2/commands/handler.c	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/commands/handler.c	2009-03-04 05:56:31 UTC (rev 2012)
@@ -1,4 +1,4 @@
-/* handler.c - test module for dynamic loading */
+/* handler.c - commands to list or select handlers */
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 2009  Free Software Foundation, Inc.

Modified: trunk/grub2/configure
===================================================================
--- trunk/grub2/configure	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/configure	2009-03-04 05:56:31 UTC (rev 2012)
@@ -6774,6 +6774,12 @@
 
 if test "x$target_m64" = x1; then
   # Force 64-bit mode.
+  TARGET_CFLAGS="$TARGET_CFLAGS -m64"
+  TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
+fi
+
+if test "$target_cpu"-"$platform" = x86_64-efi; then
+  # Use large model to support 4G memory
   { echo "$as_me:$LINENO: checking whether option -mcmodel=large works" >&5
 echo $ECHO_N "checking whether option -mcmodel=large works... $ECHO_C" >&6; }
 if test "${grub_cv_cc_mcmodel+set}" = set; then
@@ -6826,15 +6832,74 @@
 fi
 { echo "$as_me:$LINENO: result: $grub_cv_cc_mcmodel" >&5
 echo "${ECHO_T}$grub_cv_cc_mcmodel" >&6; }
-  if test "x$grub_cv_cc_mcmodel" = xno; then
+  if test "x$grub_cv_cc_no_mcmodel" = xno; then
     { { echo "$as_me:$LINENO: error: -mcmodel=large not supported, upgrade your gcc" >&5
 echo "$as_me: error: -mcmodel=large not supported, upgrade your gcc" >&2;}
    { (exit 1); exit 1; }; }
   fi
-  TARGET_CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
-  TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
+
+  # EFI writes to stack below %rsp, we must not use the red zone
+  { echo "$as_me:$LINENO: checking whether option -mno-red-zone works" >&5
+echo $ECHO_N "checking whether option -mno-red-zone works... $ECHO_C" >&6; }
+if test "${grub_cv_cc_no_red_zone+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    CFLAGS="-m64 -mno-red-zone"
+    cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  grub_cv_cc_no_red_zone=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	grub_cv_cc_no_red_zone=no
 fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ echo "$as_me:$LINENO: result: $grub_cv_cc_no_red_zone" >&5
+echo "${ECHO_T}$grub_cv_cc_no_red_zone" >&6; }
+  if test "x$grub_cv_cc_no_red_zone" = xno; then
+    { { echo "$as_me:$LINENO: error: -mno-red-zone not supported, upgrade your gcc" >&5
+echo "$as_me: error: -mno-red-zone not supported, upgrade your gcc" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large -mno-red-zone"
+fi
+
 #
 # Compiler features.
 #

Modified: trunk/grub2/configure.ac
===================================================================
--- trunk/grub2/configure.ac	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/configure.ac	2009-03-04 05:56:31 UTC (rev 2012)
@@ -299,17 +299,34 @@
 
 if test "x$target_m64" = x1; then
   # Force 64-bit mode.
+  TARGET_CFLAGS="$TARGET_CFLAGS -m64"
+  TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
+fi
+
+if test "$target_cpu"-"$platform" = x86_64-efi; then
+  # Use large model to support 4G memory
   AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
     CFLAGS="-m64 -mcmodel=large"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 		      [grub_cv_cc_mcmodel=yes],
 		      [grub_cv_cc_mcmodel=no])
   ])
-  if test "x$grub_cv_cc_mcmodel" = xno; then
+  if test "x$grub_cv_cc_no_mcmodel" = xno; then
     AC_MSG_ERROR([-mcmodel=large not supported, upgrade your gcc])
   fi
-  TARGET_CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
-  TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
+
+  # EFI writes to stack below %rsp, we must not use the red zone
+  AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
+    CFLAGS="-m64 -mno-red-zone"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+		      [grub_cv_cc_no_red_zone=yes],
+		      [grub_cv_cc_no_red_zone=no])
+  ])
+  if test "x$grub_cv_cc_no_red_zone" = xno; then
+    AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large -mno-red-zone"
 fi
 
 #

Modified: trunk/grub2/kern/handler.c
===================================================================
--- trunk/grub2/kern/handler.c	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/kern/handler.c	2009-03-04 05:56:31 UTC (rev 2012)
@@ -1,4 +1,4 @@
-/* handler.c - grub handler function*/
+/* handler.c - grub handler function */
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 2009  Free Software Foundation, Inc.

Modified: trunk/grub2/kern/list.c
===================================================================
--- trunk/grub2/kern/list.c	2009-03-03 19:00:41 UTC (rev 2011)
+++ trunk/grub2/kern/list.c	2009-03-04 05:56:31 UTC (rev 2012)
@@ -1,4 +1,4 @@
-/* list.c - grub list function*/
+/* list.c - grub list function */
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 2009  Free Software Foundation, Inc.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.