Linkonce vs comdat

Ian Lance Taylor ian@wasabisystems.com
Tue Sep 23 19:25:00 GMT 2003


Matt Austern <austern@apple.com> writes:

> > 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.

Well, the notion of ``real COMDAT'' is not particularly meaningful.
There are several versions of COMDAT, and they have different
capabilities.  linkonce is real COMDAT.

Your statement is correct comparing linkonce and SHT_GROUP.

Ian



More information about the Gcc mailing list