fix a potential problem in configure and fix the function chain_stage2

This commit is contained in:
okuji 1999-06-27 07:32:43 +00:00
parent bdd07e3f83
commit 6336679de2
13 changed files with 98 additions and 36 deletions

View file

@ -1,3 +1,21 @@
1999-06-27 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* configure.in (CFLAGS): Set to "-g", since only this flag is
always sharable.
(STAGE1_CFLAGS): Set to "-O2", and AC_SUBST this.
(GRUB_CFLAGS): Likewise.
(saved_CFLAGS): New variable for temporarily saving CFLAGS.
(STAGE2_CFLAGS): Set to "-Os" if this option is available,
otherwise set to "-fno-strength-reduce -fno-unroll-loops",
and then AC_SUBST this.
* grub/Makefile.am (AM_CFLAGS): Prepended @GRUB_CFLAGS@.
* stage1/Makefile.am (AM_CFLAGS): Prepended @STAGE1_CFLAGS@.
* stage2/Makefile.am (libgrub_a_CFLAGS): Prepened @GRUB_CFLAGS@.
(STAGE2_COMPILE): Prepended @STAGE2_CFLAGS@.
* stage2/asm.S (chain_stage2): Pass CURRENT_PARTITION and
CURRENT_DRIVE, instead of INSTALL_PARTITION and BOOT_DRIVE.
1999-06-27 Pavel Roskin <pavel_roskin@geocities.com>
* configure.in: set CFLAGS to "-Os -g" for compilers which

View file

@ -62,12 +62,15 @@ host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CC = @CC@
GRUB_CFLAGS = @GRUB_CFLAGS@
GRUB_LIBS = @GRUB_LIBS@
LD = @LD@
MAKEINFO = @MAKEINFO@
OBJCOPY = @OBJCOPY@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STAGE1_CFLAGS = @STAGE1_CFLAGS@
STAGE2_CFLAGS = @STAGE2_CFLAGS@
VERSION = @VERSION@
host_cpu = @host_cpu@
host_vendor = @host_vendor@

57
configure vendored
View file

@ -1244,24 +1244,29 @@ else
fi
# optimization flags
if test "x$ac_cv_prog_gcc" = xyes; then
if test "x$default_CFLAGS" = xyes; then
CFLAGS="-g"
STAGE1_CFLAGS="-O2"
GRUB_CFLAGS="-O2"
echo $ac_n "checking whether optimization for size works""... $ac_c" 1>&6
echo "configure:1251: checking whether optimization for size works" >&5
echo "configure:1255: checking whether optimization for size works" >&5
if eval "test \"\${size_flag+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
saved_CFLAGS=$CFLAGS
CFLAGS="-Os -g"
cat > conftest.$ac_ext <<EOF
#line 1258 "configure"
#line 1263 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
if { (eval echo configure:1265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1270: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
size_flag=yes
else
@ -1271,25 +1276,30 @@ else
size_flag=no
fi
rm -f conftest*
CFLAGS=$saved_CFLAGS
fi
echo "$ac_t""$size_flag" 1>&6
if test "x$size_flag" = xyes; then
CFLAGS="-Os -g"
STAGE2_CFLAGS="-Os"
else
CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops -g"
STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
fi
fi
fi
# Enforce coding standards.
CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused"
# Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
set dummy ${ac_tool_prefix}ld; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1293: checking for $ac_word" >&5
echo "configure:1303: checking for $ac_word" >&5
if eval "test \"\${ac_cv_prog_LD+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1321,7 +1331,7 @@ fi
# Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args.
set dummy ${ac_tool_prefix}objcopy; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1325: checking for $ac_word" >&5
echo "configure:1335: checking for $ac_word" >&5
if eval "test \"\${ac_cv_prog_OBJCOPY+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1354,7 +1364,7 @@ fi
# Defined in acinclude.m4.
echo $ac_n "checking symbol names produced by ${CC-cc}""... $ac_c" 1>&6
echo "configure:1358: checking symbol names produced by ${CC-cc}" >&5
echo "configure:1368: checking symbol names produced by ${CC-cc}" >&5
if eval "test \"\${grub_cv_asm_ext_c+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1367,7 +1377,7 @@ func (int *list)
}
EOF
if { ac_try='${CC-cc} -S conftest.c'; { (eval echo configure:1371: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then :
if { ac_try='${CC-cc} -S conftest.c'; { (eval echo configure:1381: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then :
else
{ echo "configure: error: ${CC-cc} failed to produce assembly code" 1>&2; exit 1; }
fi
@ -1396,7 +1406,7 @@ EOF
echo $ac_n "checking whether ${OBJCOPY} works for absolute addresses""... $ac_c" 1>&6
echo "configure:1400: checking whether ${OBJCOPY} works for absolute addresses" >&5
echo "configure:1410: checking whether ${OBJCOPY} works for absolute addresses" >&5
if eval "test \"\${grub_cv_prog_objcopy_absolute+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1408,21 +1418,21 @@ blah (void)
}
EOF
if { (eval echo configure:1412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then :
if { (eval echo configure:1422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then :
else
{ echo "configure: error: ${CC-cc} cannot compile C source code" 1>&2; exit 1; }
fi
grub_cv_prog_objcopy_absolute=yes
for link_addr in 2000 8000 7C00; do
if { ac_try='${LD-ld} -N -Ttext $link_addr conftest.o -o conftest.exec'; { (eval echo configure:1418: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
if { ac_try='${LD-ld} -N -Ttext $link_addr conftest.o -o conftest.exec'; { (eval echo configure:1428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
else
{ echo "configure: error: ${LD-ld} cannot link at address $link_addr" 1>&2; exit 1; }
fi
if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1422: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
else
{ echo "configure: error: ${OBJCOPY-objcopy} cannot create binary files" 1>&2; exit 1; }
fi
if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
mv -f conftest conftest.old
else
grub_cv_prog_objcopy_absolute=no
@ -1439,7 +1449,7 @@ fi
echo $ac_n "checking for .code16 addr32 assembler support""... $ac_c" 1>&6
echo "configure:1443: checking for .code16 addr32 assembler support" >&5
echo "configure:1453: checking for .code16 addr32 assembler support" >&5
if eval "test \"\${grub_cv_asm_addr32+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1449,7 +1459,7 @@ l1: addr32
movb %al, l1
EOF
if { ac_try='${CC-cc} -c conftest.s'; { (eval echo configure:1453: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
if { ac_try='${CC-cc} -c conftest.s'; { (eval echo configure:1463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
grub_cv_asm_addr32=yes
else
grub_cv_asm_addr32=no
@ -1464,7 +1474,7 @@ fi
# Check for curses libraries.
echo $ac_n "checking for getch in -lncurses""... $ac_c" 1>&6
echo "configure:1468: checking for getch in -lncurses" >&5
echo "configure:1478: checking for getch in -lncurses" >&5
ac_lib_var=`echo ncurses'_'getch | sed 'y%./+-:%__p__%'`
if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1472,7 +1482,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1476 "configure"
#line 1486 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1483,7 +1493,7 @@ int main() {
getch()
; return 0; }
EOF
if { (eval echo configure:1487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1497: \"$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
@ -1506,7 +1516,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for getch in -lcurses""... $ac_c" 1>&6
echo "configure:1510: checking for getch in -lcurses" >&5
echo "configure:1520: checking for getch in -lcurses" >&5
ac_lib_var=`echo curses'_'getch | sed 'y%./+-:%__p__%'`
if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1514,7 +1524,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1518 "configure"
#line 1528 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1525,7 +1535,7 @@ int main() {
getch()
; return 0; }
EOF
if { (eval echo configure:1529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1539: \"$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
@ -1727,6 +1737,9 @@ s%@build_vendor@%$build_vendor%g
s%@build_os@%$build_os%g
s%@CC@%$CC%g
s%@RANLIB@%$RANLIB%g
s%@STAGE1_CFLAGS@%$STAGE1_CFLAGS%g
s%@STAGE2_CFLAGS@%$STAGE2_CFLAGS%g
s%@GRUB_CFLAGS@%$GRUB_CFLAGS%g
s%@LD@%$LD%g
s%@OBJCOPY@%$OBJCOPY%g
s%@GRUB_LIBS@%$GRUB_LIBS%g

View file

@ -56,20 +56,30 @@ AC_CHECK_TOOL(CC, gcc)
AC_PROG_CC
AC_PROG_RANLIB
# optimization flags
if test "x$ac_cv_prog_gcc" = xyes; then
if test "x$default_CFLAGS" = xyes; then
CFLAGS="-g"
STAGE1_CFLAGS="-O2"
GRUB_CFLAGS="-O2"
AC_CACHE_CHECK([whether optimization for size works], size_flag, [
saved_CFLAGS=$CFLAGS
CFLAGS="-Os -g"
AC_TRY_COMPILE(, , size_flag=yes, size_flag=no)
CFLAGS=$saved_CFLAGS
])
if test "x$size_flag" = xyes; then
CFLAGS="-Os -g"
STAGE2_CFLAGS="-Os"
else
CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops -g"
STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
fi
fi
fi
AC_SUBST(STAGE1_CFLAGS)
AC_SUBST(STAGE2_CFLAGS)
AC_SUBST(GRUB_CFLAGS)
# Enforce coding standards.
CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused"

3
debian/Makefile.in vendored
View file

@ -62,12 +62,15 @@ host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CC = @CC@
GRUB_CFLAGS = @GRUB_CFLAGS@
GRUB_LIBS = @GRUB_LIBS@
LD = @LD@
MAKEINFO = @MAKEINFO@
OBJCOPY = @OBJCOPY@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STAGE1_CFLAGS = @STAGE1_CFLAGS@
STAGE2_CFLAGS = @STAGE2_CFLAGS@
VERSION = @VERSION@
host_cpu = @host_cpu@
host_vendor = @host_vendor@

View file

@ -62,12 +62,15 @@ host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CC = @CC@
GRUB_CFLAGS = @GRUB_CFLAGS@
GRUB_LIBS = @GRUB_LIBS@
LD = @LD@
MAKEINFO = @MAKEINFO@
OBJCOPY = @OBJCOPY@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STAGE1_CFLAGS = @STAGE1_CFLAGS@
STAGE2_CFLAGS = @STAGE2_CFLAGS@
VERSION = @VERSION@
host_cpu = @host_cpu@
host_vendor = @host_vendor@

View file

@ -1,6 +1,7 @@
sbin_PROGRAMS = grub
AM_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings -I$(top_srcdir)/stage2
AM_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings \
-I$(top_srcdir)/stage2
grub_SOURCES = main.c asmstub.c
grub_LDADD = ../stage2/libgrub.a @GRUB_LIBS@

View file

@ -62,12 +62,15 @@ host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CC = @CC@
GRUB_CFLAGS = @GRUB_CFLAGS@
GRUB_LIBS = @GRUB_LIBS@
LD = @LD@
MAKEINFO = @MAKEINFO@
OBJCOPY = @OBJCOPY@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STAGE1_CFLAGS = @STAGE1_CFLAGS@
STAGE2_CFLAGS = @STAGE2_CFLAGS@
VERSION = @VERSION@
host_cpu = @host_cpu@
host_vendor = @host_vendor@
@ -76,7 +79,9 @@ install_sh = @install_sh@
sbin_PROGRAMS = grub
AM_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings -I$(top_srcdir)/stage2
AM_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings \
-I$(top_srcdir)/stage2
grub_SOURCES = main.c asmstub.c
grub_LDADD = ../stage2/libgrub.a @GRUB_LIBS@

View file

@ -3,7 +3,7 @@ nodist_pkgdata_DATA = stage1
CLEANFILES = $(pkgdata_DATA)
# We can't use builtins or standard includes.
AM_CFLAGS = -fno-builtin -nostdinc
AM_CFLAGS = @STAGE1_CFLAGS@ -fno-builtin -nostdinc
noinst_PROGRAMS = stage1.exec
stage1_exec_SOURCES = stage1.S

View file

@ -60,12 +60,15 @@ host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CC = @CC@
GRUB_CFLAGS = @GRUB_CFLAGS@
GRUB_LIBS = @GRUB_LIBS@
LD = @LD@
MAKEINFO = @MAKEINFO@
OBJCOPY = @OBJCOPY@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STAGE1_CFLAGS = @STAGE1_CFLAGS@
STAGE2_CFLAGS = @STAGE2_CFLAGS@
VERSION = @VERSION@
host_cpu = @host_cpu@
host_vendor = @host_vendor@
@ -77,7 +80,7 @@ nodist_pkgdata_DATA = stage1
CLEANFILES = $(pkgdata_DATA)
# We can't use builtins or standard includes.
AM_CFLAGS = -fno-builtin -nostdinc
AM_CFLAGS = @STAGE1_CFLAGS@ -fno-builtin -nostdinc
noinst_PROGRAMS = stage1.exec
stage1_exec_SOURCES = stage1.S

View file

@ -12,7 +12,7 @@ EXTRA_DIST = smp-imps.c $(noinst_SCRIPTS)
noinst_LIBRARIES = libgrub.a
libgrub_a_SOURCES = boot.c common.c char_io.c cmdline.c disk_io.c \
gunzip.c fsys_ffs.c fsys_ext2fs.c fsys_fat.c stage2.c
libgrub_a_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings
libgrub_a_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings
# Stage 2 and Stage 1.5's.
pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
@ -23,7 +23,7 @@ noinst_PROGRAMS = stage2.exec e2fs_stage1_5.exec fat_stage1_5.exec \
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
STAGE2_COMPILE = -fno-builtin -nostdinc
STAGE2_COMPILE = @STAGE2_CFLAGS@ -fno-builtin -nostdinc
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1 \

View file

@ -60,12 +60,15 @@ host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CC = @CC@
GRUB_CFLAGS = @GRUB_CFLAGS@
GRUB_LIBS = @GRUB_LIBS@
LD = @LD@
MAKEINFO = @MAKEINFO@
OBJCOPY = @OBJCOPY@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STAGE1_CFLAGS = @STAGE1_CFLAGS@
STAGE2_CFLAGS = @STAGE2_CFLAGS@
VERSION = @VERSION@
host_cpu = @host_cpu@
host_vendor = @host_vendor@
@ -89,7 +92,7 @@ noinst_LIBRARIES = libgrub.a
libgrub_a_SOURCES = boot.c common.c char_io.c cmdline.c disk_io.c \
gunzip.c fsys_ffs.c fsys_ext2fs.c fsys_fat.c stage2.c
libgrub_a_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings
libgrub_a_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings
# Stage 2 and Stage 1.5's.
pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
@ -101,7 +104,7 @@ noinst_PROGRAMS = stage2.exec e2fs_stage1_5.exec fat_stage1_5.exec \
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
STAGE2_COMPILE = -fno-builtin -nostdinc
STAGE2_COMPILE = @STAGE2_CFLAGS@ -fno-builtin -nostdinc
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1 \

View file

@ -201,12 +201,12 @@ ENTRY(chain_stage2)
/* generate linear address */
addl %eax, %ebx
/* store install info */
movl EXT_C(install_partition), %eax
/* set up to pass the partition where stage2 is located in */
movl EXT_C(current_partition), %eax
movl %eax, EXT_C(install_partition)-EXT_C(start)(%ebx)
/* set up to pass boot drive */
movb EXT_C(boot_drive), %dl
/* set up to pass the drive where stage2 is located in */
movb EXT_C(current_drive), %dl
call EXT_C(prot_to_real)
.code16