Is linkonce underused?

H. J. Lu hjl@lucon.org
Tue Dec 17 14:34:00 GMT 2002


On Tue, Dec 17, 2002 at 01:34:50PM -0800, Matt Austern wrote:
> Consider the following C++ source file:
>   void check(const void*);
>   template <class T> T* identity(T* p) { check(p); return p; }
>   void foo() { identity((double*) 0); }
> 
> Using the top of the 3.3 release branch to compile this
> on Linus, and using the options -O0 -g -S, it's easy to
> see what gets placed in which sections.
> 
> _Z8identityIdEPt_S1_ gets placed in a linkonce section,
> as it ought to be.  However, it's the only thing in that
> linkonce section.  This is puzzling, because that
> template instantiation has two other parts: debug
> information, and EH information.  One would think that
> these should all be retained or discarded as a group.
> It's nice that we'll only have one copy of the actual
> code for identity<double> even if it's instantiated in
> a hundred translation units, but it's a shame that we'll
> still get a hundred copies of the EH information and the
> debug information.
> 
> Am I misunderstanding something?  If not, is there some
> reason we aren't using linkonce for EH and debug
> information?

GRP_COMDAT can be used for that. It is available in ELF. I'd like to
see gcc support it.


H.J.



More information about the Gcc mailing list