The problem with linkonce sections in ELF

Ian Lance Taylor
Thu Feb 3 17:52:00 GMT 2000

   Date: Thu, 3 Feb 2000 16:50:34 -0800
   From: "H . J . Lu" <>

   >    > I think I found the problem. build_link_order () is called very
   >    > late. Before that, the input section list of the output section
   >    > is always empty. When we strip a linkonce section,
   >    > _bfd_strip_section_from_output removes the corresponding output
   >    > section by mistake since its input section list is empty. I don't
   >    > know what the best fix is.
   > I don't understand this explanation.  Why is it incorrect to remove an
   > output section which has no input sections?  An output section with no
   > input sections should not occupy any space in any case.

   It is not there are no input sections. It is just that they haven't
   been assigned to the output section yet. It is done in
   build_link_order (), which is called very late from ldwrite ().

   > _bfd_strip_section_from_output should only be called for sections
   > created by the linker.  Are you saying that you have input sections
   > with the same name as sections which the linker creates?  That could
   > indeed be a problem, and I don't think your patch is the correct fix
   > for that.

   _bfd_strip_section_from_output () is called by
   elf_i386_size_dynamic_sections () in elf32-i386.c on
   ".rel.gnu.linkonce.t*" sections. They are created by linker.
   But for some reason. they are not put on the input section
   list. I will look into it more.

The linker creates the .rel.gnu.linkonce.t* sections.  It assumes that
there are no input sections for those sections, just as it assumes
that there are no input sections for any relocation sections.  If
there are input sections for a relocation section, I would be
surprised if the code worked correctly.

It sounds like you are saying that there are input sections named
.rel.gnu.linkonce.t* which do not hold relocations.  If they did hold
relocations, they would not be treated as ordinary input sections.


More information about the Binutils mailing list