rtld: Use DAGS for symbol lookup; adjust weak symbol logic
authorJohn Marino <draco@marino.st>
Sat, 21 Jan 2012 21:35:24 +0000 (22:35 +0100)
committerJohn Marino <draco@marino.st>
Mon, 23 Jan 2012 16:13:18 +0000 (17:13 +0100)
commit153ab39206bda82ee461410163ae0f433bcb2629
tree78f1e7a57e874d2c449414810f066011d0a2a53c
parente9de6dccf96c643b779ee1f2d5de6a19375e7fa8
rtld: Use DAGS for symbol lookup; adjust weak symbol logic

get_program_var_addr() must prefer the strong symbol to the weak one.
Search global objects, together with main object and dependencies for the
requested symbol.

Move the common code from symlook_default() into new helper
symlook_global(), and use it both in symlook_global() and
get_program_var_addr().  Supply lock state to get_program_var_addr().

Taken-from: FreeBSD SVN 217223 (10 JAN 2011)

Eliminate the use of symlook_needed function in favor of DAGS.  Place
elements on DAG lists in breadth-first order. This allows us to walk
pre-built list in all cases where breadth-first dependency chain
enumeration is required.

Fix dlsym on special handle obtained by dlopen(NULL, ...) to do what
comment claims it does. Take advantage of recently added symlook_global
function to iterate over main objects and global DAGs lists properly in
search of a symbol. Since rtld itself provides part of the global
namespace, search rtld_obj too.

Remove recursion from init_dag and symlook_needed functions. Use
symlook_needed for ELF filtee processing only and change lookup order
used in the function to match the order used by Solaris runtime linker
under same circumstances. While there, fix weak symbol handling in the
loop so that we return the first weak symbol definition if no strong one
was found, instead of the last one.

Taken-from: FreeBSD SVN 218051 (28 JAN 2011)
libexec/rtld-elf/rtld.c