On 27/06/12 07:35, Ian Lance Taylor wrote:
There are a few different versions of weak symbols, and I'm not sure
which one you mean. Are you talking about __attribute__ ((weak,
alias("name"))), or just __attribute__ ((weak)), or __attribute__
((weakref("name")))?
I meant __attribute__ ((weakref("name"))) indeed. So all your answers
are very to-the point. Thanks very much.
There's one thing though that I do not yet understand, probably due to
me underspecifying the case (I'll retry below):
...
c. does it matter whether the link is resolved by the link editor or
dynamically, at runtime, by the loader?
No. __attribute__ ((weakref("name"))) only works with static symbols,
so it is basicall just renaming the symbol in the compiler. No
significant linker action is involved.
What I meant is the following:
When specifying a weak reference using __attribute__
((weakref("name"))), an attempt to resolve the symbol "name" will be
done at some time, possibly when linking together program files before
the code is run, possibly at run-time using the loader.
OK?
So, all other things being equal, does it matter for the success of
symbol resolution whether it is performed by the link-editor (ld), or by
the loader (ld.so)? In other words: is __attribute__ ((weakref("name")))
a useful construct for both linking scenario's?
Erik.
Ian