On Mon, Nov 28, 2005 at 04:10:55PM +0100, Lubos Lunak wrote:
> 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?
glibc ld.so doesn't work that way for almost 3 years now, it doesn't special
case weak symbols, first matching symbol is returned and I believe
glibc was the only one that violated the spec in that case.
Jakub