PATCH: PR ld/5522: Section contents partially overwritten with zero

Alan Modra amodra@bigpond.net.au
Wed Jan 9 05:14:00 GMT 2008


On Tue, Jan 08, 2008 at 05:25:42AM -0800, H.J. Lu wrote:
> On Tue, Jan 08, 2008 at 09:29:56PM +1030, Alan Modra wrote:
> > > >2007-12-27  H.J. Lu  <hongjiu.lu@intel.com>
> > > >
> > > >	PR ld/5522
> > > >	* elflink.c (elf_link_input_bfd): Don't write out a section if
> > > >	its output section is marked with SEC_NEVER_LOAD.
> > 
> > ld.info gives an example of NOLOAD output sections saying "The
> > contents of the section will appear in the linker output file as
> > usual".  NOLOAD sets SEC_NEVER_LOAD on the output section, therefore
> > not writing out the section here is wrong.  I think we are suffering
> > bit rot.  Probably partly my fault..
> > 
> > >From what I can see of the history (I can't access private Cygnus CVS,
> > so can't see before 1999), it appears that SEC_NEVER_LOAD was
> > invented for COFF to mirror STYP_NOLOAD.  I'm inclined to think it
> > should remain that way.  ie. Only used in COFF code or in the generic
> > linker code to hanlde NOLOAD.  ELF doesn't have an external section
> > flag similar to STYP_NOLOAD so SEC_NEVER_LOAD should not appear
> > anywhere in ELF specific code.  SEC_LOAD is sufficient.  Does anyone
> > have any enlightening comments?
> > 
> 
> bfd/section.c has
> 
> .  {* An instruction to the linker to not output the section
> .     even if it has information which would normally be written.  *}
> .#define SEC_NEVER_LOAD 0x200
> 
> I don't know which one is correct.

Both.

bfd overloads SEC_NEVER_LOAD with different meanings for input and
output sections.  For input sections, SEC_NEVER_LOAD does as per the
section.c comment;  The section contents are replaced with padding.

For output sections, SEC_NEVER_LOAD is set via NOLOAD in a link
script.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list