Hello!
I have tried to compile the latest (CVS) GRUB on Cygwin B20.1 (standard
install + egcs-1.1.1)
These are the problems that I've encountered and the fixes that I've made.
Since I'm using the latest snapshot of binutils, it is important that
grub_ASM_PREFIX_REQUIREMENT uses "addr32" on the same line as the next
instruction. Otherwise the prefix is ignored. But the COFF format doesn't
support the relocation needed when addr32 is missing, so the test fails.
This means that ADDR32 should be defined before
grub_ASM_PREFIX_REQUIREMENT is used.
I have moved the defines for ADDR32 and DATA32 from configure.in to
acinclude.m4
A positive side effect was that the related entries in acconfig.h became
unnecessary.
grub_ASM_ADDR32 now requires grub_ASM_PREFIX_REQUIREMENT
configure.in calls now grub_ASM_PREFIX_REQUIREMENT before grub_ASM_ADDR32
asm.S defined putchar() as a function. On ELF systems putchar was always
replaced with grub_putchar, but in doesn't works on COFF systems, where
EXT_C adds "_" and ENTRY adds ":" to the result of EXT_C
The resulting object file exports _grub_putchar and has _putchar
undefined:
00000331 T _grub_putchar
U _putchar
I think it's Ok to replace putchar with grub_putchar in asm.S
Also $EXT_C(end) expands to $_end which has no sence. $end is Ok.
stage1.S and stage1_lba.S require using absolute addresses when addresses
in the code are used as data.
The attached patch doesn't yet make possible building GRUB on Cygwin.
The remaining problems are:
1) Unresolved _alloca in load_image(). By some reason GCC decides to call
_alloca at the beginning of load_image(). It may be a GCC (egcs-1.1.1)
bug.
2) stage1, stage1_lba, *stage1_5 and stage2 begin with zeros. There are no
chances that they will work.
However, stage1 and stage2 compiled on Linux are exactly the same as
before the patch (checked with "cmp"), so at least in shouldn't break
anything.
ChangeLog:
* acconfig.h: remove definitions for ADDR32 and DATA32
* acinclude.m4 (grub_ASM_ADDR32): Use ADDR32 instead of
addr32. Require grub_ASM_PREFIX_REQUIREMENT
(grub_ASM_PREFIX_REQUIREMENT): define ADDR32 and DATA32
* configure: call grub_ASM_PREFIX_REQUIREMENT before
grub_ASM_ADDR32. Don't define ADDR32 and DATA32
* stage1/stage1_lba.S: Use ABS in MSG definition and for
access to firstlist.
* stage1/stage1.S: Likewise. Also use MSG for
fd_probe_error_string
* stage2/asm.S (grub_putchar): write the function name
as grub_putchar, not as putchar
(get_code_end): Use $end instead of $EXT_C(end)
Pavel Roskin
Index: acconfig.h
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/acconfig.h,v
retrieving revision 1.1
diff -u -r1.1 acconfig.h
--- acconfig.h 1999/09/13 04:31:27 1.1
+++ acconfig.h 1999/09/17 10:57:10
@@ -1,11 +1,5 @@
/* This file is still needed because the defines below are
AC_DEFINEd in more than one place. */
-/* Defined it to "addr32" or "addr32;" to make GAS happy. */
-#undef ADDR32
-
-/* Defined it to "data32" or "data32;" to make GAS happy. */
-#undef DATA32
-
/* Defined if you have a curses library (ncurses preferred). */
#undef HAVE_LIBCURSES
Index: acinclude.m4
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/acinclude.m4,v
retrieving revision 1.6
diff -u -r1.6 acinclude.m4
--- acinclude.m4 1999/09/13 04:31:28 1.6
+++ acinclude.m4 1999/09/17 10:57:10
@@ -86,12 +86,12 @@
dnl stage1/stage1.S.
AC_DEFUN(grub_ASM_ADDR32,
[AC_REQUIRE([AC_PROG_CC])
+AC_REQUIRE([grub_ASM_PREFIX_REQUIREMENT])
AC_MSG_CHECKING([for .code16 addr32 assembler support])
AC_CACHE_VAL(grub_cv_asm_addr32,
[cat > conftest.s <<\EOF
.code16
-l1: addr32
- movb %al, l1
+l1: ADDR32 movb %al, l1
EOF
if AC_TRY_COMMAND([${CC-cc} -c conftest.s]) && test -s conftest.o; then
@@ -118,8 +118,18 @@
if AC_TRY_COMMAND([${CC-cc} -c conftest.s]) && test -s conftest.o; then
grub_cv_asm_prefix_requirement=yes
+ grub_tmp_addr32="addr32"
+ grub_tmp_data32="data32"
else
grub_cv_asm_prefix_requirement=no
+ grub_tmp_addr32="addr32;"
+ grub_tmp_data32="data32;"
fi
+
+AC_DEFINE_UNQUOTED([ADDR32], $grub_tmp_addr32,
+ [Define it to \"addr32\" or \"addr32;\" to make GAS happy])
+AC_DEFINE_UNQUOTED([DATA32], $grub_tmp_data32,
+ [Define it to \"data32\" or \"data32;\" to make GAS happy])
+
rm -f conftest*])
AC_MSG_RESULT([$grub_cv_asm_prefix_requirement])])
Index: configure.in
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/configure.in,v
retrieving revision 1.20
diff -u -r1.20 configure.in
--- configure.in 1999/09/14 06:55:20 1.20
+++ configure.in 1999/09/17 10:57:11
@@ -92,18 +92,11 @@
AC_MSG_ERROR([GRUB requires a working absolute objcopy; upgrade your binutils])
fi
+grub_ASM_PREFIX_REQUIREMENT
+
grub_ASM_ADDR32
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.
Index: stage1/stage1.S
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage1/stage1.S,v
retrieving revision 1.13
diff -u -r1.13 stage1.S
--- stage1.S 1999/09/15 05:41:00 1.13
+++ stage1.S 1999/09/17 10:57:12
@@ -31,7 +31,7 @@
#define ABS(x) (x-_start+0x7c00)
/* Print message string */
-#define MSG(x) movw $x, %si; call message
+#define MSG(x) movw $ABS(x), %si; call message
.file "stage1.S"
@@ -104,7 +104,7 @@
/*
* Check if we have a forced disk reference here
*/
- movb firstlist, %al
+ movb ABS(firstlist), %al
cmpb $0xff, %al
je 1f
movb %al, %dl
@@ -460,8 +460,7 @@
/*
* Floppy disk probe failure.
*/
- movw $fd_probe_error_string, %si
- call message
+ MSG(fd_probe_error_string)
jmp general_error
fd_probe_error_string: .string "Floppy"
Index: stage1/stage1_lba.S
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage1/stage1_lba.S,v
retrieving revision 1.7
diff -u -r1.7 stage1_lba.S
--- stage1_lba.S 1999/09/15 05:41:01 1.7
+++ stage1_lba.S 1999/09/17 10:57:12
@@ -31,7 +31,7 @@
#define ABS(x) (x-_start+0x7c00)
/* Print message string */
-#define MSG(x) movw $x, %si; call message
+#define MSG(x) movw $ABS(x), %si; call message
.file "stage1_lba.S"
@@ -99,7 +99,7 @@
/*
* Check if we have a forced disk reference here
*/
- movb firstlist, %al
+ movb ABS(firstlist), %al
cmpb $0xff, %al
je 1f
movb %al, %dl
Index: stage2/asm.S
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/asm.S,v
retrieving revision 1.8
diff -u -r1.8 asm.S
--- asm.S 1999/09/14 06:55:52 1.8
+++ asm.S 1999/09/17 10:57:13
@@ -724,8 +724,8 @@
/*
- * putchar(c) : Puts character on the screen, interpreting '\n' as in the
- * UNIX fashion.
+ * grub_putchar(c) : Puts character on the screen, interpreting '\n' as
+ * in the UNIX fashion.
*
* BIOS call "INT 10H Function 0Eh" to write character to console
* Call with %ah = 0x0e
@@ -735,7 +735,7 @@
*/
-ENTRY(putchar)
+ENTRY(grub_putchar)
push %ebp
push %eax
push %ebx
@@ -748,7 +748,7 @@
/* if newline, print CR as well */
pushl $0xd
- call EXT_C(putchar)
+ call EXT_C(grub_putchar)
popl %eax
pc_notnewline:
@@ -773,7 +773,7 @@
* 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 */
+ movl $end, %eax /* will be the end of the bss */
shrl $2, %eax /* Round up to the next word. */
incl %eax
shll $2, %eax