support both of binutils 2.9.1.0.x and 2.9.5.0.x

This commit is contained in:
okuji 1999-08-05 09:42:15 +00:00
parent 0623b3f394
commit ce03b57275
6 changed files with 156 additions and 55 deletions

View file

@ -1,3 +1,11 @@
1999-08-05 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* acinclude.m4 (grub_ASM_PREFIX_REQUIREMENT): New function.
* configure.in: Call grub_ASM_PREFIX_REQUIREMENT, and define
ADDR32 and DATA32 based on the result.
* stage2/asm.S: Replace addr32 and data32 prefixes with ADDR32
and DATA32 respectively.
1999-08-05 Pavel Roskin <pavel_roskin@geocities.com>
* stage2/boot.c (load_image): Use RAW_ADDR macro when loading

View file

@ -106,3 +106,25 @@ else
fi
rm -f conftest*])
AC_MSG_RESULT([$grub_cv_asm_addr32])])
dnl
dnl Later versions of GAS requires that addr32 and data32 prefixes
dnl appear in the same lines as the instructions they modify, while
dnl earlier versions requires that they appear in separate lines.
AC_DEFUN(grub_ASM_PREFIX_REQUIREMENT,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl
[whether addr32 must be in the same line as the instruction])
AC_CACHE_VAL(grub_cv_asm_prefix_requirement,
[cat > conftest.s <<\EOF
.code16
l1: addr32 movb %al, l1
EOF
if AC_TRY_COMMAND([${CC-cc} -c conftest.s]) && test -s conftest.o; then
grub_cv_asm_prefix_requirement=yes
else
grub_cv_asm_prefix_requirement=no
fi
rm -f conftest*])
AC_MSG_RESULT([$grub_cv_asm_prefix_requirement])])

22
aclocal.m4 vendored
View file

@ -119,6 +119,28 @@ fi
rm -f conftest*])
AC_MSG_RESULT([$grub_cv_asm_addr32])])
dnl
dnl Later versions of GAS requires that addr32 and data32 prefixes
dnl appear in the same lines as the instructions they modify, while
dnl earlier versions requires that they appear in separate lines.
AC_DEFUN(grub_ASM_PREFIX_REQUIREMENT,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl
[whether addr32 must be in the same line as the instruction])
AC_CACHE_VAL(grub_cv_asm_prefix_requirement,
[cat > conftest.s <<\EOF
.code16
l1: addr32 movb %al, l1
EOF
if AC_TRY_COMMAND([${CC-cc} -c conftest.s]) && test -s conftest.o; then
grub_cv_asm_prefix_requirement=yes
else
grub_cv_asm_prefix_requirement=no
fi
rm -f conftest*])
AC_MSG_RESULT([$grub_cv_asm_prefix_requirement])])
# 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.

72
configure vendored
View file

@ -1507,9 +1507,49 @@ if test "x$grub_cv_asm_addr32" != xyes; then
{ echo "configure: error: GRUB requires GAS .code16 addr32 support; upgrade your binutils" 1>&2; exit 1; }
fi
echo $ac_n "checking whether addr32 must be in the same line as the instruction""... $ac_c" 1>&6
echo "configure:1513: checking whether addr32 must be in the same line as the instruction" >&5
if eval "test \"\${grub_cv_asm_prefix_requirement+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<\EOF
.code16
l1: addr32 movb %al, l1
EOF
if { ac_try='${CC-cc} -c conftest.s'; { (eval echo configure:1522: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
grub_cv_asm_prefix_requirement=yes
else
grub_cv_asm_prefix_requirement=no
fi
rm -f conftest*
fi
echo "$ac_t""$grub_cv_asm_prefix_requirement" 1>&6
if test "x$grub_cv_asm_prefix_requirement" != xyes; then
cat >> confdefs.h <<EOF
#define ADDR32 addr32;
EOF
cat >> confdefs.h <<EOF
#define DATA32 data32;
EOF
else
cat >> confdefs.h <<EOF
#define ADDR32 addr32
EOF
cat >> confdefs.h <<EOF
#define DATA32 data32
EOF
fi
# Check for curses libraries.
echo $ac_n "checking for getch in -lncurses""... $ac_c" 1>&6
echo "configure:1513: checking for getch in -lncurses" >&5
echo "configure:1553: 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
@ -1517,7 +1557,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1521 "configure"
#line 1561 "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
@ -1528,7 +1568,7 @@ int main() {
getch()
; return 0; }
EOF
if { (eval echo configure:1532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1572: \"$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
@ -1551,7 +1591,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for getch in -lcurses""... $ac_c" 1>&6
echo "configure:1555: checking for getch in -lcurses" >&5
echo "configure:1595: 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
@ -1559,7 +1599,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1563 "configure"
#line 1603 "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
@ -1570,7 +1610,7 @@ int main() {
getch()
; return 0; }
EOF
if { (eval echo configure:1574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1614: \"$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
@ -1600,7 +1640,7 @@ fi
# Check for headers.
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1604: checking how to run the C preprocessor" >&5
echo "configure:1644: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -1615,13 +1655,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 1619 "configure"
#line 1659 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1625: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1665: \"$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
:
@ -1632,13 +1672,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1636 "configure"
#line 1676 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1642: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1682: \"$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
:
@ -1649,13 +1689,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 1653 "configure"
#line 1693 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1659: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1699: \"$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
:
@ -1683,17 +1723,17 @@ for ac_hdr in string.h strings.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1687: checking for $ac_hdr" >&5
echo "configure:1727: 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
#line 1692 "configure"
#line 1732 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1697: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1737: \"$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*

View file

@ -98,6 +98,15 @@ if test "x$grub_cv_asm_addr32" != xyes; then
AC_MSG_ERROR([GRUB requires GAS .code16 addr32 support; upgrade your binutils])
fi
grub_ASM_PREFIX_REQUIREMENT
if test "x$grub_cv_asm_prefix_requirement" != xyes; then
AC_DEFINE_UNQUOTED([ADDR32], [addr32; ])
AC_DEFINE_UNQUOTED([DATA32], [data32; ])
else
AC_DEFINE_UNQUOTED([ADDR32], [addr32])
AC_DEFINE_UNQUOTED([DATA32], [data32])
fi
# Check for curses libraries.
AC_CHECK_LIB(ncurses, getch, [GRUB_LIBS="$GRUB_LIBS -lncurses"
AC_DEFINE(HAVE_LIBCURSES)],

View file

@ -95,13 +95,13 @@ codestart:
sti /* we're safe again */
/* save boot drive reference */
addr32 movb %dl, EXT_C(boot_drive)
ADDR32 movb %dl, EXT_C(boot_drive)
/* reset disk system (%ah = 0) */
int $0x13
/* transition to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
/* The ".code32" directive takes GAS out of 16-bit mode. */
.code32
@ -170,7 +170,7 @@ ENTRY(chain_stage1)
call EXT_C(prot_to_real)
.code16
data32 addr32 ljmp (offset)
DATA32 ADDR32 ljmp (offset)
.code32
#endif /* STAGE1_5 */
@ -209,7 +209,7 @@ ENTRY(chain_stage2)
call EXT_C(prot_to_real)
.code16
data32 addr32 ljmp (offset)
DATA32 ADDR32 ljmp (offset)
.code32
@ -225,7 +225,7 @@ ENTRY(real_to_prot)
cli
/* load the GDT register */
data32 addr32 lgdt gdtdesc
DATA32 ADDR32 lgdt gdtdesc
/* turn on protected mode */
movl %cr0, %eax
@ -233,7 +233,7 @@ ENTRY(real_to_prot)
movl %eax, %cr0
/* jump to relocation, flush prefetch queue, and reload %cs */
data32 ljmp $PROT_MODE_CSEG, $protcseg
DATA32 ljmp $PROT_MODE_CSEG, $protcseg
/*
* The ".code32" directive only works in GAS, the GNU assembler!
@ -307,7 +307,7 @@ tmpcseg:
movl %eax, %cr0
/* flush prefetch queue, reload %cs */
data32 ljmp $0, $realcseg
DATA32 ljmp $0, $realcseg
realcseg:
/* we are in real mode now
@ -326,7 +326,7 @@ realcseg:
sti
/* return on new stack! */
data32 ret
DATA32 ret
.code32
@ -370,7 +370,7 @@ ENTRY(biosdisk_int13_extensions)
xorw %ax, %ax
movw %ax, %ds
/* back to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movb %dl, %al /* return value in %eax */
@ -442,7 +442,7 @@ ENTRY(biosdisk_standard)
jmp 1b /* retry */
2:
/* back to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movb %bl, %al /* return value in %eax */
@ -495,7 +495,7 @@ ENTRY(check_int13_extensions)
xorb %bl, %bl
2:
/* back to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movb %bl, %al /* return value in %eax */
@ -543,7 +543,7 @@ ENTRY(get_diskinfo_int13_extensions)
xorw %ax, %ax
movw %ax, %ds
/* back to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movb %bl, %al /* return value in %eax */
@ -592,7 +592,7 @@ ENTRY(get_diskinfo_standard)
1:
movb %ah, %bl /* save return value in %bl */
/* back to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
/* restore %ebp */
@ -687,7 +687,7 @@ probe_values:
2:
/* back to protected mode */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
/* restore %ebp */
@ -758,7 +758,7 @@ pc_notnewline:
movw $1, %bx
int $0x10
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
pop %ebx
@ -796,10 +796,10 @@ ENTRY(get_memsize)
.code16
cmpb $0x1, %bl
data32 je xext
DATA32 je xext
int $0x12
data32 jmp xdone
DATA32 jmp xdone
xext:
movb $0x88, %ah
@ -808,7 +808,7 @@ xext:
xdone:
movw %ax, %bx
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movw %bx, %ax
@ -845,7 +845,7 @@ ENTRY(get_eisamemsize)
shll $16, %ebx
movw %ax, %bx
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movl $0xFFFFFFFF, %eax
@ -906,24 +906,24 @@ ENTRY(get_mmap_entry)
movl $0xe820, %eax
int $0x15
data32 jc xnosmap
DATA32 jc xnosmap
cmpl $0x534d4150, %eax
data32 jne xnosmap
DATA32 jne xnosmap
cmpl $0x14, %ecx
data32 jl xnosmap
DATA32 jl xnosmap
cmpl $0x400, %ecx
data32 jg xnosmap
DATA32 jg xnosmap
data32 jmp xsmap
DATA32 jmp xsmap
xnosmap:
movl $0, %ecx
xsmap:
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
/* write length of buffer (zero if error) into "addr" */
@ -1001,10 +1001,10 @@ ENTRY(patch_code) /* labels start with "pc_" */
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
addr32 movl $0, 0
ADDR32 movl $0, 0
pc_stop:
hlt
data32 jmp pc_stop
DATA32 jmp pc_stop
ENTRY(patch_code_end)
.code32
@ -1054,7 +1054,7 @@ ENTRY(big_linux_boot)
movw %ax, %ss
/* jump to start */
data32 addr32 ljmp (offset)
DATA32 ADDR32 ljmp (offset)
.code32
@ -1103,7 +1103,7 @@ ENTRY(cls)
xorb %ah, %ah
int $0x10 /* Set Video mode (clears screen) */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
pop %ebx
@ -1133,7 +1133,7 @@ ENTRY(nocursor)
movb $0x1, %ah
int $0x10
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
pop %edx
@ -1168,7 +1168,7 @@ ENTRY(getxy)
movb $0x3, %ah
int $0x10 /* get cursor position */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movb %dl, %ah
@ -1207,7 +1207,7 @@ ENTRY(gotoxy)
movb $0x2, %ah
int $0x10 /* set cursor position */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
pop %edx
@ -1271,7 +1271,7 @@ ENTRY(set_attrib)
movw $1, %cx
int $0x10
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
pop %ecx
@ -1310,11 +1310,11 @@ ENTRY(getrtsecs)
movb $0x2, %ah
int $0x1a
data32 jnc gottime
DATA32 jnc gottime
movb $0xff, %dh
gottime:
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movb %dh, %al
@ -1344,7 +1344,7 @@ ENTRY(getkey)
movw %ax, %bx /* real_to_prot uses %eax */
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
movw %bx, %ax
@ -1379,15 +1379,15 @@ ENTRY(checkkey)
movb $0x1, %ah
int $0x16
data32 jz notpending
DATA32 jz notpending
movw %ax, %bx
data32 jmp pending
DATA32 jmp pending
notpending:
movl $0xFFFFFFFF, %ebx
pending:
data32 call EXT_C(real_to_prot)
DATA32 call EXT_C(real_to_prot)
.code32
mov %ebx, %eax