The problem with linkonce sections in ELF

H . J . Lu
Tue Feb 1 13:35:00 GMT 2000

On Tue, Feb 01, 2000 at 04:24:50PM -0500, Ian Lance Taylor wrote:
> 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.

I was given some .o files with .rel.text sections and linker
removes them when generating DSO with -Bsymbolic.
BTW, I have a feeling that those .o files are not compiled
with PIC. I will check it out.

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

That may be true.

>    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

All fields are zero.

> _bfd_elf_set_section_contents?

bfd_set_section_contents in section.c. It looks like a -Bsymbolic bug.

H.J. Lu (

More information about the Binutils mailing list