Linkonce vs comdat

Matt Austern austern@apple.com
Tue Sep 23 18:06:00 GMT 2003


On Sep 22, 2003, at 4:16 PM, Ian Lance Taylor wrote:

> Matt Austern <austern@apple.com> writes:
>
>> Perhaps one of the things that I'm missing is the documentation.  I
>> couldn't find anything in the ld documentation that said exactly what
>> it did with gnu.linkonce sections.  In the compiler documentation I
>> did  find a brief discussion in the user manual
>> (http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Vague-
>> Linkage.html#Vague%20Linkage) and nothing in the internals manual.  So
>> mostly I'm just trying to trace this through the source code.  If
>> there's somewhere better for me to be looking, I'd appreciate a
>> pointer.
>
> I think that this is the complete existing linker documentation, from
> bfd/elf.c:
>
>   /* As a GNU extension, if the name begins with .gnu.linkonce, we
>      only link a single copy of the section.  This is used to support
>      g++.  g++ will emit each template expansion in its own section.
>      The symbols will be defined as weak, so that multiple definitions
>      are permitted.  The GNU linker extension is to actually discard
>      all but one of the sections.  */

I see.  So the main difference between linkonce and real COMDAT,
then, is that the linkonce scheme doesn't have a notion of groups.  It's
based purely on section names, and there's no guarantee that the
different pieces of a function (text, data, EH information, debug
information) will be kept or discarded together.

			--Matt



More information about the Gcc mailing list