tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: __strong_alias
On Thu, Feb 14, 2013 at 02:59:25AM +0100, Emmanuel Dreyfus wrote:
> I get the same result without dlopen. In the example I posted, if I link
> test with libtest (cc -o test -L. -R. -ltest test.c) I get the same
> result: mail_foo is always called, and never libtest_foo
>
> I thought __strong_alias() were used to override __weak_alias(). Either
> it is not the way it works, or I have a missing bit in this test case.
IIRC __weak_alias generates a symbol with the WEAK property that
has the same value as another symbol. __strong_alias generates a
symbol without the WEAK property.
The dynamic linker should use a WEAK symbol if it can't find a non-weak
symbol with the same name. They are typically used for the functions
in a library (eg libc) that aren't mandated to be there - so if a program
defines a function with the same name it calls its own copy.
To see what is happening in your test program too at the namelists
from the program and shared library, and then look at the relocation
entries (objdump -R) to see what is actually referenced by the call
foo().
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index