From 84bf7c7d5dc93d19cb4285e9a8bd78db7a707778 Mon Sep 17 00:00:00 2001 From: okuji Date: Fri, 17 Sep 1999 18:35:23 +0000 Subject: [PATCH] fix the memcheck problem in the grub shell. --- ChangeLog | 36 ++++++++++ acconfig.h | 12 ++++ acinclude.m4 | 116 +++++++++++++++++++++++++++++++++ aclocal.m4 | 116 +++++++++++++++++++++++++++++++++ config.h.in | 12 ++++ configure | 166 ++++++++++++++++++++++++++++++++++++++++++----- configure.in | 14 ++++ stage2/asm.S | 7 +- stage2/char_io.c | 41 ++++++++---- stage2/disk_io.c | 4 +- 10 files changed, 492 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 773959745..6f87991ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +1999-09-18 OKUJI Yoshinori + + * acinclude.m4 (grub_CHECK_START_SYMBOL): New function. + (grub_CHECK_USCORE_START_SYMBOL): Likewise. + (grub_CHECK_END_SYMBOL): Likewise. + (grub_CHECK_USCORE_SYMBOL): Likewise. + * configure.in: Call grub_CHECK_START_SYMBOL and + grub_CHECK_USCORE_START_SYMBOL, and if neither start nor _start + is defined, print an error message and exit. + Likewise, call grub_CHECK_END_SYMBOL and + grub_CHECK_USCORE_END_SYMBOL, and if neither end nor _end is + defined, print an error message and exit. + * acconfig.h (HAVE_START_SYMBOL): Added the "undef" entry. + (HAVE_USCORE_START_SYMBOL): Likewise. + (HAVE_END_SYMBOL): Likewise. + (HAVE_USCORE_END_SYMBOL): Likewise. + * stage2/char_io.c (memcheck): Rename the argument START to + ADDR. Added two missing equal characters. + [GRUB_UTIL]: Define new local functions start_addr and end_addr. + [GRUB_UTIL && HAVE_START_SYMBOL]: The function start_addr + returns START. + [GRUB_UTIL && HAVE_USCORE_START_SYMBOL]: The function start_addr + returns _START. + [GRUB_UTIL && HAVE_END_SYMBOL]: The function end_addr returns + END. + [GRUB_UTIL && HAVE_USCORE_END_SYMBOL]: The function end_addr + returns _END. + [GRUB_UTIL]: If ADDR is equal to or greater than the address + returned by start_addr, and ADDR plus LEN is less than the + address returned by end_addr, return ! ERRNUM. + * stage2/asm.S (get_code_end) [HAVE_END_SYMBOL]: Use $end as the + end of the bss. + [HAVE_USCORE_END_SYMBOL]: Use $_end as the end of the bss. + * stage2/disk_io.c [!STAGE1_5] (cur_part_desc): Made static. + Need not to be global any longer. + 1999-09-17 OKUJI Yoshinori * stage2/char_io.c [!STAGE1_5] (get_cmdline): The argument diff --git a/acconfig.h b/acconfig.h index 4ffb9ea7c..3344beca3 100644 --- a/acconfig.h +++ b/acconfig.h @@ -9,3 +9,15 @@ /* Defined if you have a curses library (ncurses preferred). */ #undef HAVE_LIBCURSES + +/* Defined if start is defined. */ +#undef HAVE_START_SYMBOL + +/* Defined if _start is defined. */ +#undef HAVE_USCORE_START_SYMBOL + +/* Defined if end is defined. */ +#undef HAVE_END_SYMBOL + +/* Defined if _end is defined. */ +#undef HAVE_USCORE_END_SYMBOL diff --git a/acinclude.m4 b/acinclude.m4 index e507e0114..58b337069 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -123,3 +123,119 @@ else fi rm -f conftest*]) AC_MSG_RESULT([$grub_cv_asm_prefix_requirement])]) + +dnl +dnl grub_CHECK_START_SYMBOL checks if start is automatically defined by +dnl the compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_START_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if start is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_start_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl start"); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_start_symbol=yes + AC_DEFINE([HAVE_START_SYMBOL]) +else + grub_cv_check_start_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_start_symbol]) +]) + +dnl +dnl grub_CHECK_USCORE_START_SYMBOL checks if _start is automatically +dnl defined by the compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_USCORE_START_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if _start is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_uscore_start_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl _start"); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_uscore_start_symbol=yes + AC_DEFINE([HAVE_USCORE_START_SYMBOL]) +else + grub_cv_check_uscore_start_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_uscore_start_symbol]) +]) + +dnl +dnl grub_CHECK_END_SYMBOL checks if end is automatically defined by the +dnl compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_END_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if end is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_end_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl end); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_end_symbol=yes + AC_DEFINE([HAVE_END_SYMBOL]) +else + grub_cv_check_end_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_end_symbol]) +]) + +dnl +dnl grub_CHECK_USCORE_END_SYMBOL checks if _end is automatically defined +dnl by the compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_USCORE_END_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if _end is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_uscore_end_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl _end"); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_uscore_end_symbol=yes + AC_DEFINE([HAVE_USCORE_END_SYMBOL]) +else + grub_cv_check_uscore_end_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_uscore_end_symbol]) +]) diff --git a/aclocal.m4 b/aclocal.m4 index 8f1c325a6..32b6ebc3b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -136,6 +136,122 @@ fi rm -f conftest*]) AC_MSG_RESULT([$grub_cv_asm_prefix_requirement])]) +dnl +dnl grub_CHECK_START_SYMBOL checks if start is automatically defined by +dnl the compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_START_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if start is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_start_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl start"); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_start_symbol=yes + AC_DEFINE([HAVE_START_SYMBOL]) +else + grub_cv_check_start_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_start_symbol]) +]) + +dnl +dnl grub_CHECK_USCORE_START_SYMBOL checks if _start is automatically +dnl defined by the compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_USCORE_START_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if _start is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_uscore_start_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl _start"); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_uscore_start_symbol=yes + AC_DEFINE([HAVE_USCORE_START_SYMBOL]) +else + grub_cv_check_uscore_start_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_uscore_start_symbol]) +]) + +dnl +dnl grub_CHECK_END_SYMBOL checks if end is automatically defined by the +dnl compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_END_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if end is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_end_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl end); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_end_symbol=yes + AC_DEFINE([HAVE_END_SYMBOL]) +else + grub_cv_check_end_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_end_symbol]) +]) + +dnl +dnl grub_CHECK_USCORE_END_SYMBOL checks if _end is automatically defined +dnl by the compiler. +dnl Written by OKUJI Yoshinori +AC_DEFUN(grub_CHECK_USCORE_END_SYMBOL, +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([if _end is defined by the compiler]) +AC_CACHE_VAL(grub_cv_check_uscore_end_symbol, +[cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl _end"); + return 0; +} +EOF + +if AC_TRY_COMMAND([${CC-cc} conftest.c -o conftest]) && test -s conftest; then + grub_cv_check_uscore_end_symbol=yes + AC_DEFINE([HAVE_USCORE_END_SYMBOL]) +else + grub_cv_check_uscore_end_symbol=no +fi + +rm -f conftest*]) + +AC_MSG_RESULT([$grub_cv_check_uscore_end_symbol]) +]) + # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. diff --git a/config.h.in b/config.h.in index d6e7be972..ba0a15f00 100644 --- a/config.h.in +++ b/config.h.in @@ -9,6 +9,18 @@ /* Defined if you have a curses library (ncurses preferred). */ #undef HAVE_LIBCURSES +/* Defined if start is defined. */ +#undef HAVE_START_SYMBOL + +/* Defined if _start is defined. */ +#undef HAVE_USCORE_START_SYMBOL + +/* Defined if end is defined. */ +#undef HAVE_END_SYMBOL + +/* Defined if _end is defined. */ +#undef HAVE_USCORE_END_SYMBOL + /* Define if you have the header file. */ #undef HAVE_CURSES_H diff --git a/configure b/configure index b1a29905b..4719639b0 100644 --- a/configure +++ b/configure @@ -1625,9 +1625,143 @@ EOF fi + +echo $ac_n "checking if start is defined by the compiler""... $ac_c" 1>&6 +echo "configure:1631: checking if start is defined by the compiler" >&5 +if eval "test \"\${grub_cv_check_start_symbol+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl start"); + return 0; +} +EOF + +if { ac_try='${CC-cc} conftest.c -o conftest'; { (eval echo configure:1644: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest; then + grub_cv_check_start_symbol=yes + cat >> confdefs.h <<\EOF +#define HAVE_START_SYMBOL 1 +EOF + +else + grub_cv_check_start_symbol=no +fi + +rm -f conftest* +fi + + +echo "$ac_t""$grub_cv_check_start_symbol" 1>&6 + + +echo $ac_n "checking if _start is defined by the compiler""... $ac_c" 1>&6 +echo "configure:1662: checking if _start is defined by the compiler" >&5 +if eval "test \"\${grub_cv_check_uscore_start_symbol+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl _start"); + return 0; +} +EOF + +if { ac_try='${CC-cc} conftest.c -o conftest'; { (eval echo configure:1675: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest; then + grub_cv_check_uscore_start_symbol=yes + cat >> confdefs.h <<\EOF +#define HAVE_USCORE_START_SYMBOL 1 +EOF + +else + grub_cv_check_uscore_start_symbol=no +fi + +rm -f conftest* +fi + + +echo "$ac_t""$grub_cv_check_uscore_start_symbol" 1>&6 + +if test "x$grub_cv_check_start_symbol" != "xyes" \ + -a "x$grub_cv_check_uscore_start_symbol" != "xyes"; then + { echo "configure: error: Neither start nor _start is defined" 1>&2; exit 1; } +fi + + +echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6 +echo "configure:1698: checking if end is defined by the compiler" >&5 +if eval "test \"\${grub_cv_check_end_symbol+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl end); + return 0; +} +EOF + +if { ac_try='${CC-cc} conftest.c -o conftest'; { (eval echo configure:1711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest; then + grub_cv_check_end_symbol=yes + cat >> confdefs.h <<\EOF +#define HAVE_END_SYMBOL 1 +EOF + +else + grub_cv_check_end_symbol=no +fi + +rm -f conftest* +fi + + +echo "$ac_t""$grub_cv_check_end_symbol" 1>&6 + + +echo $ac_n "checking if _end is defined by the compiler""... $ac_c" 1>&6 +echo "configure:1729: checking if _end is defined by the compiler" >&5 +if eval "test \"\${grub_cv_check_uscore_end_symbol+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<\EOF +int +main (void) +{ + asm ("incl _end"); + return 0; +} +EOF + +if { ac_try='${CC-cc} conftest.c -o conftest'; { (eval echo configure:1742: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest; then + grub_cv_check_uscore_end_symbol=yes + cat >> confdefs.h <<\EOF +#define HAVE_USCORE_END_SYMBOL 1 +EOF + +else + grub_cv_check_uscore_end_symbol=no +fi + +rm -f conftest* +fi + + +echo "$ac_t""$grub_cv_check_uscore_end_symbol" 1>&6 + +if test "x$grub_cv_check_end_symbol" != "xyes" \ + -a "x$grub_cv_check_uscore_end_symbol" != "xyes"; then + { echo "configure: error: Neither end nor _end is defined" 1>&2; exit 1; } +fi + # Check for curses libraries. echo $ac_n "checking for wgetch in -lncurses""... $ac_c" 1>&6 -echo "configure:1631: checking for wgetch in -lncurses" >&5 +echo "configure:1765: checking for wgetch in -lncurses" >&5 ac_lib_var=`echo ncurses'_'wgetch | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1635,7 +1769,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1669,7 +1803,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for wgetch in -lcurses""... $ac_c" 1>&6 -echo "configure:1673: checking for wgetch in -lcurses" >&5 +echo "configure:1807: checking for wgetch in -lcurses" >&5 ac_lib_var=`echo curses'_'wgetch | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1677,7 +1811,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1826: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1718,7 +1852,7 @@ fi # Check for headers. echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1722: checking how to run the C preprocessor" >&5 +echo "configure:1856: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1733,13 +1867,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1743: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1877: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1750,13 +1884,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1760: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1894: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1767,13 +1901,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1911: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1801,17 +1935,17 @@ for ac_hdr in string.h strings.h ncurses/curses.h ncurses.h curses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1805: checking for $ac_hdr" >&5 +echo "configure:1939: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1815: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* diff --git a/configure.in b/configure.in index 5084811b0..2113fb91a 100644 --- a/configure.in +++ b/configure.in @@ -106,6 +106,20 @@ else AC_DEFINE_UNQUOTED([DATA32], [data32]) fi +grub_CHECK_START_SYMBOL +grub_CHECK_USCORE_START_SYMBOL +if test "x$grub_cv_check_start_symbol" != "xyes" \ + -a "x$grub_cv_check_uscore_start_symbol" != "xyes"; then + AC_MSG_ERROR([Neither start nor _start is defined]) +fi + +grub_CHECK_END_SYMBOL +grub_CHECK_USCORE_END_SYMBOL +if test "x$grub_cv_check_end_symbol" != "xyes" \ + -a "x$grub_cv_check_uscore_end_symbol" != "xyes"; then + AC_MSG_ERROR([Neither end nor _end is defined]) +fi + # Check for curses libraries. AC_CHECK_LIB(ncurses, wgetch, [GRUB_LIBS="$GRUB_LIBS -lncurses" AC_DEFINE(HAVE_LIBCURSES)], diff --git a/stage2/asm.S b/stage2/asm.S index 4e26fa918..2c094a5f3 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -773,7 +773,12 @@ pc_notnewline: * This is here so that it can be replaced by asmstub.c. */ ENTRY(get_code_end) - movl $EXT_C(end), %eax /* will be the end of the bss */ + /* will be the end of the bss */ +# if defined(HAVE_END_SYMBOL) + movl $end, %eax +# elif defined(HAVE_USCORE_END_SYMBOL) + movl $_end, %eax +# endif shrl $2, %eax /* Round up to the next word. */ incl %eax shll $2, %eax diff --git a/stage2/char_io.c b/stage2/char_io.c index ceba60859..4ad656962 100644 --- a/stage2/char_io.c +++ b/stage2/char_io.c @@ -790,23 +790,40 @@ grub_strlen (const char *str) int -memcheck (int start, int len) +memcheck (int addr, int len) { #ifdef GRUB_UTIL - /* FIXME: cur_part_desc is the only global variable that we memmove - to. We should fix this so that we don't need a special case - (i.e. so that it lives on the stack, or somewhere inside - grub_scratch_mem). */ - extern char cur_part_desc[]; - if (start >= (int) cur_part_desc && start + len <= (int) cur_part_desc + 16) + static int start_addr (void) + { + int ret; +# if defined(HAVE_START_SYMBOL) + asm volatile ("movl $start, %0" : "=a" (ret)); +# elif defined(HAVE_USCORE_START_SYMBOL) + asm volatile ("movl $_start, %0" : "=a" (ret)); +# endif + return ret; + } + + static int end_addr (void) + { + int ret; +# if defined(HAVE_END_SYMBOL) + asm volatile ("movl $end, %0" : "=a" (ret)); +# elif defined(HAVE_USCORE_END_SYMBOL) + asm volatile ("movl $_end, %0" : "=a" (ret)); +# endif + return ret; + } + + if (start_addr () <= addr && end_addr () > addr + len) return ! errnum; #endif /* GRUB_UTIL */ - if ((start < RAW_ADDR (0x1000)) || - (start < RAW_ADDR (0x100000) && - RAW_ADDR (mbi.mem_lower * 1024) < (start + len)) || - (start >= RAW_ADDR (0x100000) && - RAW_ADDR (mbi.mem_upper * 1024) < ((start - 0x100000) + len))) + if ((addr < RAW_ADDR (0x1000)) + || (addr < RAW_ADDR (0x100000) + && RAW_ADDR (mbi.mem_lower * 1024) <= (addr + len)) + || (addr >= RAW_ADDR (0x100000) + && RAW_ADDR (mbi.mem_upper * 1024) <= ((addr - 0x100000) + len))) errnum = ERR_WONT_FIT; return ! errnum; diff --git a/stage2/disk_io.c b/stage2/disk_io.c index cba6d1a4c..4a0bf28b9 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -437,10 +437,8 @@ check_BSD_parts (int flags) } -/* This isn't static, because the GRUB utility's char_io.c (memcheck) - needs to know about it as a special case. */ #ifndef STAGE1_5 -char cur_part_desc[16]; +static char cur_part_desc[16]; #endif static int