It seems that grub-mkimage generates awkward ELF files, in which the Program header table is at the end of the file instead of right after the ELF header.
I know very little about ELF, but: - This figure in ELF standard seems to indicate which is the "normal" (not sure if mandatory) location: http://www.cs.ucdavis.edu/~haungs/paper/node11.html - Our own ELF loader doesn't like phdroff > 0x2000 either, from loader/i386/pc/multiboot.c: /* FIXME: Should we support program headers at strange locations? */ if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH) return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset"); This breaks self-boot in the LinuxBIOS target. Moving the Program header (see attached patch) fixed it, with no apparent drawbacks or regressions in any of the ELF loaders around (tested on LinuxBIOS ELF loader and Efika OF). I'm not completely sure of its correctness though, and would appreciate if someone with a better understanding of ELF can comment on it. In particular, I don't know if my proposed solution could overwrite valid data. Are the segments garanteed to always leave room for the program header, do we have to explicitly check for that, or perhaps we need to relocate the segments when needed? -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
2007-10-12 Robert Millan <[EMAIL PROTECTED]> * util/elf/grub-mkimage.c (add_segments): Allocate Program header table right after ELF header. diff -ur grub2/util/elf/grub-mkimage.c grub2.phdr/util/elf/grub-mkimage.c --- grub2/util/elf/grub-mkimage.c 2007-10-12 12:22:27.000000000 +0200 +++ grub2.phdr/util/elf/grub-mkimage.c 2007-10-12 12:36:38.000000000 +0200 @@ -250,7 +250,7 @@ ehdr.e_shstrndx = 0; /* Append entire segment table to the file. */ - phdroff = ALIGN_UP (grub_util_get_fp_size (out), sizeof (long)); + phdroff = ALIGN_UP (sizeof (ehdr), sizeof (long)); grub_util_write_image_at (phdrs, grub_target_to_host16 (ehdr.e_phentsize) * grub_target_to_host16 (ehdr.e_phnum), phdroff, out);
_______________________________________________ Grub-devel mailing list Grubfirstname.lastname@example.org http://lists.gnu.org/mailman/listinfo/grub-devel