|How do linkers deal with C++ duplicate code? email@example.com (John R Levine) (1998-08-20)|
|Re: How do linkers deal with C++ duplicate code? firstname.lastname@example.org (1998-08-20)|
|Re: How do linkers deal with C++ duplicate code? email@example.com (David Stes) (1998-08-20)|
|Re: How do linkers deal with C++ duplicate code? firstname.lastname@example.org (Urs Hoelzle) (1998-08-20)|
|Re: How do linkers deal with C++ duplicate code? email@example.com (David L Moore) (1998-08-22)|
|Re: How do linkers deal with C++ duplicate code? firstname.lastname@example.org (1998-08-22)|
|Re: How do linkers deal with C++ duplicate code? email@example.com (David Stes) (1998-08-22)|
|[11 later articles]|
|From:||John R Levine <firstname.lastname@example.org>|
|Date:||20 Aug 1998 14:10:17 -0400|
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
-- 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.)
John Levine, email@example.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
Search the comp.compilers archives again.