RFC: Assign regions to orphan sections
Daniel Jacobowitz
dan@codesourcery.com
Mon May 3 22:27:00 GMT 2010
On Wed, Apr 28, 2010 at 03:29:59PM +0000, Joseph S. Myers wrote:
> On Fri, 26 Mar 2010, Daniel Jacobowitz wrote:
>
> > On Thu, Mar 25, 2010 at 05:55:16PM -0700, Ian Lance Taylor wrote:
> > > Daniel Jacobowitz <dan@codesourcery.com> writes:
> > >
> > > > I don't think the file header should be loaded in your case, either.
> > > > Anyone know what determines this? It's not triggered by use of
> > > > SIZEOF_HEADERS, I don't think.
> > >
> > > It's done by default if it can be done. Look at phdr_in_segment in
> > > _bfd_elf_map_sections_to_segments in bfd/elf.c.
> >
> > This bit:
> >
> > /* Deal with -Ttext or something similar such that the first section
> > is not adjacent to the program headers. This is an
> > approximation, since at this point we don't know exactly how many
> > program headers we will need. */
> > if (count > 0)
> > {
> > bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
> >
> > if (phdr_size == (bfd_size_type) -1)
> > phdr_size = get_program_header_size (abfd, info);
> > if ((abfd->flags & D_PAGED) == 0
> > || sections[0]->lma < phdr_size
> > || sections[0]->lma % maxpagesize < phdr_size % maxpagesize)
> > phdr_in_segment = FALSE;
> > }
> >
> > It seems to me that if the maximum page size is one byte, then D_PAGED
> > should be false. There aren't any pages. But that's really only the
> > case for *-elf. Joseph, would tic6x-uclinux also have MAXPAGESIZE==1?
> >
> > Anyway, a safe way to fix the test would be to add -z
> > max-page-size=256. I think that will do it.
>
> Adding -z max-page-size=256 isn't itself a solution - none of the -z
> options are supported by elf32.em unless GENERATE_SHLIB_SCRIPT is set to
> "yes". Setting it for C6X (together with adding the -z option to that
> test) does fix that failure - while introducing some other failures (the
> linker support for shared libraries on this target isn't written, so it's
> unsurprising for the linker to segfault if this option is blindly enabled)
> - but isn't correct either for C6X at present or for the other targets
> without shared library support that might be affected by this issue.
> Should some subset of the -z options (or indeed all of them) not be
> conditional on shared library support?
No, I don't think this should change.
Does ld -N do the trick? There may be some other oddities with
objcopy, because BFD autodetects D_PAGED on input files with program
headers based on the maxpagesize / minpagesize.
I do think there's a real problem here, namely that this will copy ELF
headers onto the target system for no good reason. We could make up a
page size, I suppose. It shouldn't do any harm; ARM programs with the
standard 'page size' are run without an MMU all the time.
--
Daniel Jacobowitz
CodeSourcery
More information about the Binutils
mailing list