From 7e9ca17ace0d997114bdcba57196265b7a910085 Mon Sep 17 00:00:00 2001 From: bean Date: Wed, 4 Mar 2009 05:56:31 +0000 Subject: [PATCH] 2009-03-04 Bean * 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. --- ChangeLog | 11 +++++++ DISTLIST | 1 - commands/handler.c | 2 +- configure | 71 ++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 23 +++++++++++++-- kern/handler.c | 2 +- kern/list.c | 2 +- 7 files changed, 102 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 329d82156..4968e0d3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-03-04 Bean + + * 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 Move more components to the relocation area, and fix mbi pointer diff --git a/DISTLIST b/DISTLIST index 3c8bd341b..fbe6aef5b 100644 --- a/DISTLIST +++ b/DISTLIST @@ -61,7 +61,6 @@ commands/read.c commands/reboot.c commands/search.c commands/sleep.c -commands/terminal.c commands/test.c commands/usbtest.c commands/videotest.c diff --git a/commands/handler.c b/commands/handler.c index f30337e1f..cb1e7baea 100644 --- a/commands/handler.c +++ b/commands/handler.c @@ -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. diff --git a/configure b/configure index c3677c687..b24958080 100644 --- a/configure +++ b/configure @@ -6774,6 +6774,12 @@ fi 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,13 +6832,72 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 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 # diff --git a/configure.ac b/configure.ac index fd89d302a..0220898c6 100644 --- a/configure.ac +++ b/configure.ac @@ -299,17 +299,34 @@ fi 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 # diff --git a/kern/handler.c b/kern/handler.c index c3ca18f24..2bf85313c 100644 --- a/kern/handler.c +++ b/kern/handler.c @@ -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. diff --git a/kern/list.c b/kern/list.c index b22218ee9..41f55740b 100644 --- a/kern/list.c +++ b/kern/list.c @@ -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.