On Tue, Jan 28, 2014 at 10:31 PM, patrick keshishian
<sids...@boxsoft.com> wrote:
> On Tue, Jan 28, 2014 at 09:02:31PM -0800, Philip Guenther wrote:
..
>> If you need to delay the loading of the shared-object until after
>> process startup via dlopen(), then the executable should use dlsym()
>> to get the symbol address, passing it the handle that dlopen()
>> returned.
>
> Yes. I do that right now with a bit of "dance". However,
> reading a bit about __attribute__((weak)) on-line, I
> thought, there may be an easier way to achieve this. But,
> I quite possibly misunderstood the use of that attribute.

Undefined weak symbols are useful for testing for the presence of
optional functionality loaded at the same time as the code with the
reference to the weak symbol.  If the code that may contain the symbol
will be loaded later, using a weak symbol reference is fragile, as it
is dependent on the order of operations and reputably can conflict
with compiler optimizations on some platforms.  Even Sun, who were
quite in love with their dynamic linker, recommended against doing
that (c.f. the Sun "Linker and Libraries Guide").


Philip Guenther

Reply via email to