On Tue, 2008-02-05 at 14:23 -0600, [EMAIL PROTECTED] wrote:
> On Sun, Feb 03, 2008 at 09:11:23AM -0800, walt wrote:
> > [EMAIL PROTECTED] wrote:
> >> Hi,
> >>
> >> In the course of actually trying to use the MultibootDraft, I've
> >> discovered
> >> some places where the draft and the grub2 implementation differ...
> >
> > Hi Jonathan,
> >
> > Are you using grub2/cvs with or without Bean's latest multiboot patch?
>
> I tend not to be aware of these things. I'm using stock sources.
>
> > It still hasn't been committed, and I was about to ask about it anyway.
> > Without that patch, multiboot doesn't work.
>
> Hmm.
Agreed :o) Bean's patch had some whitespace corruption anyway, so here
it is again, diffed against today's latest cvs grub2:
========================================================================
this is the patch, problems found:
1, the mbi structure is not initialized to all zeros, this means some
important member, like mods_count, will contain trash.
2, the entry point in the header is virtual address, we need to
translate it to physical address.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get
physical
address of entry.
(grub_multiboot_load_elf64): Likewise.
(grub_multiboot): Initialize mbi structure.
Index: loader/i386/pc/multiboot.c
===================================================================
RCS file: /sources/grub/grub2/loader/i386/pc/multiboot.c,v
retrieving revision 1.15
diff -u -r1.15 multiboot.c
--- loader/i386/pc/multiboot.c 2 Jan 2008 11:55:23 -0000 1.15
+++ loader/i386/pc/multiboot.c 6 Feb 2008 01:16:26 -0000
@@ -96,6 +96,7 @@
{
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) buffer;
Elf32_Phdr *phdr;
+ grub_addr_t real_entry = 0;
int i;
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
@@ -144,9 +145,16 @@
if (phdr->p_filesz < phdr->p_memsz)
grub_memset ((char *) phdr->p_paddr + phdr->p_filesz, 0,
phdr->p_memsz - phdr->p_filesz);
+
+ if ((entry >= phdr->p_vaddr) &&
+ (entry < phdr->p_vaddr + phdr->p_memsz))
+ real_entry = entry + phdr->p_paddr - phdr->p_vaddr;
}
}
-
+
+ if (real_entry)
+ entry = real_entry;
+
return grub_errno;
}
@@ -164,6 +172,7 @@
{
Elf64_Ehdr *ehdr = (Elf64_Ehdr *) buffer;
Elf64_Phdr *phdr;
+ grub_addr_t real_entry = 0;
int i;
if (ehdr->e_ident[EI_CLASS] != ELFCLASS64)
@@ -226,9 +235,16 @@
+ phdr->p_filesz),
0,
phdr->p_memsz - phdr->p_filesz);
+
+ if ((entry >= phdr->p_vaddr) &&
+ (entry < phdr->p_vaddr + phdr->p_memsz))
+ real_entry = entry + phdr->p_paddr - phdr->p_vaddr;
}
}
-
+
+ if (real_entry)
+ entry = real_entry;
+
return grub_errno;
}
@@ -306,6 +322,8 @@
if (! mbi)
goto fail;
+ grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
+
mbi->flags = MULTIBOOT_INFO_MEMORY;
/* Convert from bytes to kilobytes. */
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel