[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BUG: bfd/elf allows only 2 PT_LOAD phdrs
From: |
Alan Modra |
Subject: |
Re: BUG: bfd/elf allows only 2 PT_LOAD phdrs |
Date: |
Wed, 11 Dec 2002 13:06:04 +1030 |
User-agent: |
Mutt/1.4i |
On Tue, Dec 10, 2002 at 10:55:45AM -0700, Bhavesh P. Davda wrote:
> I am also attaching a alternative patch to bfd/elf.c, since
> address@hidden, the binutils maintainer for RedHat refused to apply my
> original patch. His concern was valid: the original patch would grow the
> program headers for all elf binaries, whether or not you needed 2 or
> more PT_LOAD segments.
Unfortunately, this patch won't work either. It's way too late to
be adjusting section layout.
Possible solutions are:
a) Add heuristics to elf.c:get_program_header_size
b) Use a custom linker script that either specifies PHDRS or allocates
the correct space for phdrs without using SIZEOF_HDRS.
c) Implement a new linker script keyword, say EXTRA_PHDR (<number>).
d) Arrange some way to easily INCLUDE the standard linker script into
a user script.
c) or d) are probably the nicest solutions. For d), I'm thinking of
a user script something like this
===============
. = <base address> + SIZEOF_HEADERS + <space for extra header>
INCLUDE "*default*";
SECTIONS { <extra user sections>}
===============
The "*default*" won't do anything special at the moment, so a little
coding is required to implement this, and all default linker scripts
need modifying so that instead of using
. = <base address> + SIZEOF_HEADERS;
they use
. = (. == 0 ? <base address> + SIZEOF_HEADERS : .);
--
Alan Modra
IBM OzLabs - Linux Technology Centre