Topic: Weak refs suffice for virtual pruning - NOT
Author: bbrunswick@my-dejanews.com
Date: 1998/07/23 Raw View
In article <6p4cc4$u9f$1@nnrp1.dejanews.com>,
bbrunswick@my-dejanews.com wrote:
> In article <6p063o$8kt$1@shell7.ba.best.com>, ncm@nospam.cantrip.org (Nathan
> Myers) wrote:
> > Omitting unused virtual functions is an important tool for eliminating
> > some bloat, but weak references by themselves (as Pete likes to remind
> > us) are not sufficient to omit unused virtual functions; that takes a
> > linker extension.
>
> Surely that turns out not to be the case.
>
> Isn't it sufficient for the compiler to generate the vtbl filled with
> weak references, and then each virtual function call to use a symbol to
> get the offset in the vtbl that it should use. Those symbols get defined
> with the virtual function definition, meaning its only pulled in if needed.
>
Other comments about facets, probably just as wrong
>
> Please tell me my understanding is lacking and that these are actually hard
> problems... its worrying if so much argument is going on over things that can
> be worked around easily.
>
Ok, I'll reply to my own post, since my understanding was indeed lacking, and
I was wrong.
Also, I feel in retrospect that the last statement comes across slightly
stronger than I meant it - of course most discussion is useful.
Anyway, the problem is that when a particular virtual function is used,
it is necessary to pull in at the link stage not just one object file, but
several that provide different definitions overriding the base definition of
the virtual function. Moreover, in the separate compilation model, these
separate functions know nothing about one another.
Traditional linkers follow a model where an undefined symbol causes exactly
one other file to be included, that defines that symbol. Weak references
provide un undefined symbol that doesn't on its own cause the inclusion of a
file that defines it. Really, we would need some kind of "strong" reference
that caused all files that defined it to be included - perhaps the linker
could report an error if any of those definitions conflicted. I'm sure that
some such technique is already in use in those environments that support
virtual stripping.
I also believe I've heard the term "strong" used for symbols that are capable
of overriding the definition of the same normal symbol included in the link -
is this standard usage?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]