linker operation sequence issue

Alan Modra
Mon Nov 20 22:14:00 GMT 2006

On Mon, Nov 20, 2006 at 12:20:07PM +0100, Jan Beulich wrote:
> lang_process() calls lang_place_orphans() before ldemul_before_allocation(),
> however the latter is where .eh_frame_hdr gets marked SEC_EXCLUDE if
> unused, hence the section is considered orphan and, depending on whether
> elf32 or generic/genelf is being used this then in the latter case results (after
> the pending adjustment of making .eh_frame_hdr generation independent
> of the use of dynamic linking) is the section not getting assigned to a
> segment at all.
> Question: Is this odd/inverted dependency intentional?

Yes.  It's not an odd ordering.  All the input sections need to be
mapped to output sections before we can decide whether output sections
are unused.

It sounds to me like you are trying to size .eh_frame_hdr too late,
ie. after strip_excluded_output_sections has run.  That's a bad idea.
You can prevent the output section being stripped, by setting
SEC_LINKER_CREATED on one of its input sections, but that will mean
all executables have an .eh_frame_hdr section.

You say that you want to "make .eh_frame_hdr generation independent of
the use of dynamic linking".  OK, but why doesn't the current sizing
scheme work for you with just a small change in
bfd_elf_size_dynamic_sections?  ie. Move the call to
_bfd_elf_maybe_strip_eh_frame_hdr up a few lines before the dynobj

Alan Modra
IBM OzLabs - Linux Technology Centre

More information about the Binutils mailing list