gold: Relocation refers to discarded comdat section

Ian Lance Taylor iant@google.com
Fri Jul 4 23:13:00 GMT 2008


Roland Baumann <roland.baumann@CoWare.com> writes:

> with a current version of gold (updated today), I get many warnings of
> the form
>
> libsystemc.a(sc_fxval.o):(.rodata+0x60): warning: Relocation refers to
> discarded comdat section
>
> But the executable works fine. I do not see these warning when using
> ld 
>>From binutils 2.18.
>
> I have only a vague idea what the warning means, but I would like to
> avoid it. I use gcc 3.4.4 and the source code is C++. Can someone help
> me out?

The warning means that there is a relocation in a .rodata section
which refers to a section which was discarded as a duplicate.

This can often be harmless.  For example, in some cases the compiler
will put a switch table in the .rodata section.  The switch table will
then have relocations which refer to the code.  If the code is a
template instantiation which winds up being discarded, you can get
this warning.  This is harmless because the switch table will never be
used.

Current versions of gcc will put the switch table in a section group
so that the switch table is discarded when the code is discarded.  You
also need to be using a sufficiently new binutils version. When gcc is
configured, it needs to find an assembler and a linker which support
section groups.

The GNU linker will issue the same warning in some cases.  I don't
know why it is not happening in your case.  This may indicate a bug in
gold, or it may indicate a bug in the GNU linker, or maybe something
else, I don't know.

Ian



More information about the Binutils mailing list