The problem with linkonce sections in ELF

Ian Lance Taylor
Tue Feb 1 13:25:00 GMT 2000

   Date: Tue, 1 Feb 2000 13:18:50 -0800
   From: "H . J . Lu" <>

   On Mon, Jan 31, 2000 at 11:27:19PM -0500, Ian Lance Taylor wrote:

   > Duplicate linkonce sections are removed before section addresses are
   > assigned, so they should not leave any holes in the address space.

   > If they do leave holes in the address space, that is definitely a bug.
   > Do you have any reason to think that that is happening?

   You are right. It is .rel.text and .rel.text which cause the problem.
   When they are removed, they leave a hole in the address space. With
   the modified ld/scripttempl/, the hole is now at the end of the
   text segment.

Leaving a hole in the address space is clearly a bug.  Your patch
should not be necessary.  Why are these sections being created with a
non-zero size, and then being removed?  That makes no sense.

Your patch is just papering over whatever the real problem is.  There
is no reason to treat .rel.text differently from any other .rel

   However, there is another bug. Under certain conditions,
   _bfd_elf_set_section_contents will be called on the ".rel.init"
   sections with the section offset == 0, which corrupts the ELF header
   among others. I have no idea why _bfd_elf_set_section_contents is
   called with section offset == 0. I will be happy to provide a binary
   testcase on Linux/x86.

This, too, is evidently a bug.  Can you investigate why the sh_offset
field is 0?  What is the size of the section?  Who is calling


More information about the Binutils mailing list