tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: __strong_alias
On Fri, Feb 15, 2013 at 02:57:46AM +0100, Emmanuel Dreyfus wrote:
>
> This time I get the PLT right, but strong_foo() is still not called.
> Does that means that dlopen() never causes strong aliases to override
> weak aliases?
A program image has multiple elf symbol name spaces, each made up of
the symbols of many elf objects (the program or shared libraries).
Everything loaded at program load time ends up in one name space,
if there duplicate symbols the one 'nearest' the program binary
is used (which is what allows things like malloc() be intercepted),
a weak symbol is only used if there aren't any non-weak ones.
dlopen() normaly creates another name space (of the loaded library and
anything loaded to resolve its NEEDED entries). This is used for symbols
within that library, but not for the main program.
Code in the main program has to use dlsym() if it wants the address
of a symbol in a library loaded by dlopen().
This is all done to make unloading libraries 'sane'.
If you specify RTLD_GLOBAL then the symbols are added to the main
program name space - so a later lookup (eg from a PLT function)
should find a non-weak sysmbol in a shared lib in preference to a
weak one in the main program.
However if you then unload the library it will go 'all wrong'.
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index