bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: BUG: bfd/elf allows only 2 PT_LOAD phdrs


From: Bhavesh P. Davda
Subject: Re: BUG: bfd/elf allows only 2 PT_LOAD phdrs
Date: Tue, 10 Dec 2002 19:42:52 -0700

Not sure what you mean by "this patch won't work". I have tried it with
a normal 2 PT_LOAD ELF executable and a special 3 PT_LOAD ELF
executable. For the normal executable, it produced exactly the same
binary as the existing linker. For the special executable, it produced
the additional PT_LOAD segment, and the Linux kernel (2.2.17) and ld.so
loaded the executable just as expected (I checked /proc/<pid>/maps for
the mapping of the new section/segment)

Can you expand on why you think it's too late to be adjusting section
layout. I thought that this is the function where section layout is
being decided.

- Bhavesh

Alan Modra wrote:
> 
> 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



reply via email to

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