Related articles |
---|
How do linkers deal with C++ duplicate code? johnl@iecc.com (John R Levine) (1998-08-20) |
Re: How do linkers deal with C++ duplicate code? johnmce@world.std.com (1998-08-20) |
Re: How do linkers deal with C++ duplicate code? stes@mundivia.es (David Stes) (1998-08-20) |
Re: How do linkers deal with C++ duplicate code? urs@cs.ucsb.edu (Urs Hoelzle) (1998-08-20) |
Re: How do linkers deal with C++ duplicate code? dlmoore@molalla.net (David L Moore) (1998-08-22) |
Re: How do linkers deal with C++ duplicate code? dwight@pentasoft.com (1998-08-22) |
Re: How do linkers deal with C++ duplicate code? stes@mundivia.es (David Stes) (1998-08-22) |
[11 later articles] |
From: | John R Levine <johnl@iecc.com> |
Newsgroups: | comp.compilers |
Date: | 20 Aug 1998 14:10:17 -0400 |
Organization: | Compilers Central |
Keywords: | linker, question |
I'm finally back at work on my long threatened linker book. (Chapters
should appear on my web site soon, for review and comment.)
I'm trying to figure out how linkers deal with the unique problems of
C++.
-- Name mangling I understand, to deal with routines that have the
same name but different input and output types. Varieties of that go
way back, to PL/I "generic" procedures in the 1960s
-- Global initializers and destructors I understand, too. Code that
needs to be run at program startup time is an old problem. Typically
in C++, the compiler writes anonymous routines to do the initializing
and puts pointers to those routines in a place the linker can
identify, either a special section or pointed to by a funky symbol.
The linker combines the pointer sections, so the actual startup code
can run down the list of pointers and call all the routines, one set
at startup, another set at exit. I suppose it'd also be possible to
create sections with the necessary code in-line and concatenate those.
Anyone do that?
-- Templates and extern inline. This I understand the least. The
problem is that with separate compilation, multiple modules can
contain identical (or at least equivalent) copies of expanded
templated routines and extern inlines. One approach is to pretend
they're all static and live with the code bloat, although as recently
noted, the bloat can be pretty horrible. But some systems actually
identify and discard the duplicates. What do they do, treat them as
name-mangled common blocks full of code and discard all but one of
them? Something cleverer?
All advice and pointers welcome, credit will be lavishly given in the
book. (We authors love to give away free stuff.)
Regards,
John Levine, johnl@iecc.com, Primary Perpetrator of "The Internet for Dummies",
Finger for PGP key, f'print = 3A 5B D0 3F D9 A0 6A A4 2D AC 1E 9E A6 36 A3 47
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.