12.10.2007, в 11:19, Robert Millan писал(а):
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?
I don't think the ELF TIS says anything about location of PHDRs.
That's the whole point of EHDR - so that the location, size of each
entry, and count can be variable. The only invalid case would be for
phoff or phoff + phentcount * phentsize to exceed end of file offset.
--
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 /.)
<phdr.diff>
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel