Hello!

The attached patch fixes loading FreeBSD and NetBSD a.out kernels by the
GRUB utility.

ChangeLog:

        * stage2/boot.c (load_image): Use RAW_ADDR macro when loading
        a.out kernels

By the way, the current GRUB loads FreeBSD-3.1 and 3.2 without any
problems (apart from inability to pass root_disk_unit)

I must have been used stage2 without my fix for strcmp yesterday :-(
With the attached patch GRUB is known to load following kernels:

                 /sbin/grub           stage2

Linux            Ok                   Ok
gnumach-elf      Ok                   not tested
FreeBSD-2.2.5    Ok                   Ok
NetBSD-1.1       Ok                   not tested
FreeBSD-3.1,3.2  Ok                   Ok
FreeBSD loader   Ok                   Ok    
Mach-a.out       Loading below        not tested
                 1M not supported

Pavel Roskin
Index: stage2/boot.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/boot.c,v
retrieving revision 1.5
diff -u -r1.5 boot.c
--- boot.c      1999/08/03 15:45:15     1.5
+++ boot.c      1999/08/04 06:25:35
@@ -312,7 +312,7 @@
       printf (", loadaddr=0x%x, text%s=0x%x", cur_addr, str, text_len);
 
       /* read text, then read data */
-      if (grub_read ((char *) cur_addr, text_len) == text_len)
+      if (grub_read ((char *) RAW_ADDR (cur_addr), text_len) == text_len)
        {
          cur_addr += text_len;
 
@@ -326,7 +326,7 @@
 
              printf (", data=0x%x", data_len);
 
-             if (grub_read ((char *) cur_addr, data_len) != data_len &&
+             if (grub_read ((char *) RAW_ADDR (cur_addr), data_len) != data_len &&
                  !errnum)
                errnum = ERR_EXEC_FORMAT;
              cur_addr += data_len;
@@ -334,7 +334,7 @@
 
          if (!errnum)
            {
-             memset ((char *) cur_addr, 0, bss_len);
+             memset ((char *) RAW_ADDR (cur_addr), 0, bss_len);
              cur_addr += bss_len;
 
              printf (", bss=0x%x", bss_len);
@@ -353,18 +353,20 @@
 
          mbi.syms.a.addr = cur_addr;
 
-         *(((int *) cur_addr)++) = pu.aout->a_syms;
+         *((int *) RAW_ADDR (cur_addr)) = pu.aout->a_syms;
+         cur_addr += sizeof (int);
 
          printf (", symtab=0x%x", pu.aout->a_syms);
 
-         if (grub_read ((char *) cur_addr, pu.aout->a_syms) == pu.aout->a_syms)
+         if (grub_read ((char *) RAW_ADDR (cur_addr), pu.aout->a_syms) == 
+pu.aout->a_syms)
            {
              cur_addr += pu.aout->a_syms;
              mbi.syms.a.tabsize = pu.aout->a_syms;
 
              if (grub_read ((char *) &i, sizeof (int)) == sizeof (int))
                {
-                 *(((int *) cur_addr)++) = i;
+                 *((int *) RAW_ADDR (cur_addr)) = i;
+                 cur_addr += sizeof (int);
 
                  mbi.syms.a.strsize = i;
 
@@ -372,7 +374,7 @@
 
                  printf (", strtab=0x%x", i);
 
-                 symtab_err = (grub_read ((char *) cur_addr, i) != i);
+                 symtab_err = (grub_read ((char *) RAW_ADDR (cur_addr), i) != i);
                  cur_addr += i;
                }
              else

Reply via email to