This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ vague linkage data


 Hello,

 when gcc emits vague linkage data for C++ like vtables it makes them all 
weak. Is there some reason why this needs to be done?

 If I'm getting it right, based on e.g. on the comment in binutils/bfd/elf.c 
saying that they are weak in order to allow multiple copies and that the GNU 
ld extension linkonce will discard all but one, this seems to be done only 
for historical reasons (or call that compatibility, whatever). With the usual 
setup of using the complete GNU toolchain, there will be always only one such 
symbol because of the linkonce feature in each resulting binary/library. If 
there will be more such libraries each of them having the same symbol, the 
normal ELF symbol rules will bind all references only to one of them, and 
those symbols are all the same anyway.

 Which means that in such case there's no reason to have those symbols weak, 
and having them weak means that the symbol lookup in ld.so for them will be 
more expensive (because it has to search all libraries for a non-weak symbol 
only to find out there's obviously no such thing). Is there some reason why 
this shouldn't be changed to have these symbols emitted normally as non-weak?

 
 On a somewhat related note, I've been looking at how to better control 
emitting of such vague linkage data. It's not that difficult to have many of 
these things emitted in many places, which I expect should lead to things 
like longer build times, larger binaries, even more conflicts with prelink, 
non-unique symbols problems if one doesn't (want to) use RTLD_GLOBAL and such 
(well, I don't just expect the last two ones to happen - they do).

 Info pages info:/gcc/Vague Linkage and info:/gcc/C++ Interface are quite 
helpful on this, so I think I'll try the effect of #pragma 
interface/implementation . However the docs give me kind of the impression 
that this is not really the recommended way of doing things - is there some 
better way or are there any problems with these pragmas I should expect? I 
also wonder about the exact effect of these on templates, those pages and 
info:/gcc/Template Instantiation are a bit unclear (and obsolete?) on this 
topic. From my test it seems those pragmas don't have any special effect as 
far as templates are concerned - am I right on this?

 Thanks

gcc --version : gcc (GCC) 4.0.2 20050901 (prerelease) (SUSE Linux)
-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak@suse.cz , l.lunak@kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]