[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] ELF program header

From: Robert Millan
Subject: [PATCH] ELF program header
Date: Fri, 12 Oct 2007 18:19:55 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

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:

  - Our own ELF loader doesn't like phdroff > 0x2000 either, from

  /* 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 /.)

Attachment: phdr.diff
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]