diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 15:33:46 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 15:33:46 +0000 |
commit | 3026163fe155e919e994c495493fd65835802049 (patch) | |
tree | 0466f45139f71415e34afe5d6e07f80461a359e2 /elf/dl-sym.c | |
parent | 85b34a3d15a11d8d4d1a7046fa9438c760c3c9c1 (diff) | |
download | glibc-3026163fe155e919e994c495493fd65835802049.tar.gz |
2007-06-09 Ulrich Drepper <drepper@redhat.com>
* elf/do-lookup.h (do_lookup_x): Read r_nlist before r_list and
make sure gcc doesn't mess around with this.
2007-06-08 Ulrich Drepper <drepper@redhat.com>
* elf/dl-lookup.c (_dl_lookup_symbol_x): Remove use of r_nlist.
2007-06-08 Jakub Jelinek <jakub@redhat.com>
* elf/dl-close.c (_dl_close_worker): Remove all to be removed
libraries from the global scope at once and call THREAD_GSCOPE_WAIT
at most once per _dl_close_worker.
2007-05-18 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close_worker): When removing object from
global scope, wait for all lookups to finish afterwards.
* elf/dl-open.c (add_to_global): When global scope array must
grow, allocate a new one and free old array only after all
lookups finish.
* elf/dl-runtime.c (_dl_fixup): Protect using global scope.
(_dl_lookup_symbol_x): Likewise.
* elf/dl-support.c: Define _dl_wait_lookup_done.
* sysdeps/generic/ldsodefs.h (struct rtld_global): Add
_dl_wait_lookup_done.
2007-05-11 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close_worker): Help gcc to optimize by
adding new variables.
* elf/dl-open.c (add_to_global): Introduce variable ns to help gcc
optimize. Completely extend global scope array before making the
new entries visible.
2007-01-15 Ulrich Drepper <drepper@redhat.com>
* sysdeps/generic/ldsodefs.h: Define DL_LOOKUP_SCOPE_LOCK.
* elf/dl-lookup.c (add_dependency): If scope map is locked, unlock
it before getting dl_load_lock and then relock.
(_dl_lookup_symbol_x): Pass flags to add_dependency.
When rerunning _dl_lookup_symbol_x, compute symbol_scope again in
case we unlocked the scope.
* elf/dl-runtime.c (_dl_fixup): Pass DL_LOOKUP_SCOPE_LOCK to
_dl_lookup_symbol_x in case we locked the scope.
(_dl_profile_fixup): Likewise.
* elf/dl-sym.c (do_sym): In flags passed to call_dl_lookup, also
set DL_LOOKUP_SCOPE_LOCK.
2006-10-29 Jakub Jelinek <jakub@redhat.com>
* elf/dl-sym.c (do_sym): Use RTLD_SINGLE_THREAD_P.
* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Likewise.
* elf/dl-close.c (_dl_close_worker): Likewise.
* elf/dl-open.c (_dl_open_worker): Likewise.
* sysdeps/generic/sysdep-cancel.h (RTLD_SINGLE_THREAD_P): Define.
2006-10-27 Jakub Jelinek <jakub@redhat.com>
* elf/dl-lookup.c (_dl_debug_bindings): Remove unused symbol_scope
argument.
(_dl_lookup_symbol_x): Adjust caller.
* sysdeps/generic/ldsodefs.h (struct link_namespaces): Remove
_ns_global_scope.
* elf/rtld.c (dl_main): Don't initialize _ns_global_scope.
* elf/dl-libc.c: Revert l_scope name changes.
* elf/dl-load.c: Likewise.
* elf/dl-object.c: Likewise.
* elf/rtld.c: Likewise.
* elf/dl-close.c (_dl_close): Likewise.
* elf/dl-open.c (dl_open_worker): Likewise. If not SINGLE_THREAD_P,
always use __rtld_mrlock_{change,done}. Always free old scope list
here if not l_scope_mem.
* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Revert l_scope name
change. Never free scope list here. Just __rtld_mrlock_lock before
the lookup and __rtld_mrlock_unlock it after the lookup.
* elf/dl-sym.c: Likewise.
* include/link.h (struct r_scoperec): Remove.
(struct link_map): Replace l_scoperec with l_scope, l_scoperec_mem
with l_scope_mem and l_scoperec_lock with l_scope_lock.
2006-10-18 Ulrich Drepper <drepper@redhat.com>
* elf/dl-lookup.c (_dl_lookup_symbol_x): Add warning to
_dl_lookup_symbol_x code.
2006-10-17 Jakub Jelinek <jakub@redhat.com>
* elf/dl-runtime.c: Include sysdep-cancel.h.
(_dl_fixup, _dl_profile_fixup): Use __rtld_mrlock_* and
scoperec->nusers only if !SINGLE_THREAD_P.
* elf/dl-sym.c: Include sysdep-cancel.h.
(do_sym): Use __rtld_mrlock_* and scoperec->nusers only
if !SINGLE_THREAD_P.
* elf/dl-close.c: Include sysdep-cancel.h.
(_dl_close): Use __rtld_mrlock_* and scoperec->nusers only
if !SINGLE_THREAD_P.
* elf/dl-open.c: Include sysdep-cancel.h.
(dl_open_worker): Use __rtld_mrlock_* and scoperec->nusers only
if !SINGLE_THREAD_P.
2006-10-09 Ulrich Drepper <drepper@redhat.com>
Jakub Jelinek <jakub@redhat.com>
Implement reference counting of scope records.
* elf/dl-close.c (_dl_close): Remove all scopes from removed objects
from the list in objects which remain. Always allocate new scope
record.
* elf/dl-open.c (dl_open_worker): When growing array for scopes,
don't resize, allocate a new one.
* elf/dl-runtime.c: Update reference counters before using a scope
array.
* elf/dl-sym.c: Likewise.
* elf/dl-libc.c: Adjust for l_scope name change.
* elf/dl-load.c: Likewise.
* elf/dl-object.c: Likewise.
* elf/rtld.c: Likewise.
* include/link.h: Include <rtld-lowlevel.h>. Define struct
r_scoperec. Replace r_scope with pointer to r_scoperec structure.
Add l_scoperec_lock.
* sysdeps/generic/ldsodefs.h: Include <rtld-lowlevel.h>.
* sysdeps/generic/rtld-lowlevel.h: New file.
nptl/
2007-05-28 Jakub Jelinek <jakub@redhat.com>
* sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Use explicit
insn suffix.
(THREAD_GSCOPE_GET_FLAG): Remove.
* sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Remove.
* allocatestack.c (__wait_lookup_done): Revert 2007-05-24
changes.
* sysdeps/powerpc/tls.h (tcbhead_t): Remove gscope_flag.
(THREAD_GSCOPE_GET_FLAG): Remove.
(THREAD_GSCOPE_RESET_FLAG): Use THREAD_SELF->header.gscope_flag
instead of THREAD_GSCOPE_GET_FLAG.
(THREAD_GSCOPE_SET_FLAG): Likewise. Add atomic_write_barrier after
it.
* sysdeps/s390/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
THREAD_GSCOPE_WAIT): Define.
* sysdeps/sparc/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
THREAD_GSCOPE_WAIT): Define.
* sysdeps/sh/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
THREAD_GSCOPE_WAIT): Define.
* sysdeps/ia64/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
THREAD_GSCOPE_WAIT): Define.
2007-05-24 Richard Henderson <rth@redhat.com>
* descr.h (struct pthread): Add header.gscope_flag.
* sysdeps/alpha/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
THREAD_GSCOPE_WAIT): Define.
2007-05-26 Ulrich Drepper <drepper@redhat.com>
* allocatestack.c: Revert last change.
* init.c: Likewise.
* sysdeps/i386/tls.h: Likewise.
* sysdeps/x86_64/tls.h: Likewise.
2007-05-24 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/tls.h (tcbhead_t): Add gscope_flag.
(THREAD_GSCOPE_FLAG_UNUSED, THREAD_GSCOPE_FLAG_USED,
THREAD_GSCOPE_FLAG_WAIT): Define.
(THREAD_GSCOPE_GET_FLAG, THREAD_GSCOPE_SET_FLAG,
THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define.
* sysdeps/i386/tls.h (THREAD_GSCOPE_WAIT): Don't use
PTR_DEMANGLE.
(THREAD_GSCOPE_GET_FLAG): Define.
* sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Define.
* allocatestack.c (__wait_lookup_done): Use THREAD_GSCOPE_GET_FLAG
instead of ->header.gscope_flag directly.
2007-05-21 Ulrich Drepper <drepper@redhat.com>
* sysdeps/pthread/pthread-functions.h (struct pthread_functions):
Remove ptr_wait_lookup_done again.
* init.c (pthread_functions): Don't add .ptr_wait_lookup_done here.
(__pthread_initialize_minimal_internal): Initialize
_dl_wait_lookup_done pointer in _rtld_global directly.
* sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
Remove code to code _dl_wait_lookup_done.
* sysdeps/x86_64/tls.h (THREAD_GSCOPE_WAIT): The pointer is not
encrypted for now.
2007-05-19 Ulrich Drepper <drepper@redhat.com>
* allocatestack.c (__wait_lookup_done): New function.
* sysdeps/pthread/pthread-functions.h (struct pthread_functions):
Add ptr_wait_lookup_done.
* init.c (pthread_functions): Initialize .ptr_wait_lookup_done.
* pthreadP.h: Declare __wait_lookup_done.
* sysdeps/i386/tls.h (tcbhead_t): Add gscope_flag.
Define macros to implement reference handling of global scope.
* sysdeps/x86_64/tls.h: Likewise.
* sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
Initialize GL(dl_wait_lookup_done).
2006-12-09 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/rtld-lowlevel.h
(__rtld_mrlock_initialize): Add missing closing parenthesis.
2006-10-29 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (RTLD_SINGLE_THREAD_P):
Define.
(SINGLE_THREAD_P): Define to 1 if IS_IN_rtld.
* sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise.
2006-10-27 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock,
__rtld_mrlock_change): Update oldval if atomic compare and exchange
failed.
* sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (SINGLE_THREAD_P):
Define to THREAD_SELF->header.multiple_threads.
* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SINGLE_THREAD_P):
Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (SINGLE_THREAD_P):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (SINGLE_THREAD_P):
Likewise.
2006-10-09 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/rtld-lowlevel.h: New file..
Diffstat (limited to 'elf/dl-sym.c')
-rw-r--r-- | elf/dl-sym.c | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/elf/dl-sym.c b/elf/dl-sym.c index d2b0ec0dab..20235ae2e6 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -17,6 +17,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <assert.h> #include <stddef.h> #include <setjmp.h> #include <libintl.h> @@ -24,6 +25,7 @@ #include <dlfcn.h> #include <ldsodefs.h> #include <dl-hash.h> +#include <sysdep-cancel.h> #ifdef USE_TLS # include <dl-tls.h> #endif @@ -58,6 +60,29 @@ _dl_tls_symaddr (struct link_map *map, const ElfW(Sym) *ref) #endif +struct call_dl_lookup_args +{ + /* Arguments to do_dlsym. */ + struct link_map *map; + const char *name; + struct r_found_version *vers; + int flags; + + /* Return values of do_dlsym. */ + lookup_t loadbase; + const ElfW(Sym) **refp; +}; + +static void +call_dl_lookup (void *ptr) +{ + struct call_dl_lookup_args *args = (struct call_dl_lookup_args *) ptr; + args->map = GLRO(dl_lookup_symbol_x) (args->name, args->map, args->refp, + args->map->l_scope, args->vers, 0, + args->flags, NULL); +} + + static void * internal_function do_sym (void *handle, const char *name, void *who, @@ -84,10 +109,51 @@ do_sym (void *handle, const char *name, void *who, } if (handle == RTLD_DEFAULT) - /* Search the global scope. */ - result = GLRO(dl_lookup_symbol_x) (name, match, &ref, match->l_scope, - vers, 0, flags|DL_LOOKUP_ADD_DEPENDENCY, - NULL); + { + /* Search the global scope. We have the simple case where + we look up in the scope of an object which was part of + the initial binary. And then the more complex part + where the object is dynamically loaded and the scope + array can change. */ + if (match->l_type != lt_loaded || RTLD_SINGLE_THREAD_P) + result = GLRO(dl_lookup_symbol_x) (name, match, &ref, + match->l_scope, vers, 0, + flags | DL_LOOKUP_ADD_DEPENDENCY, + NULL); + else + { + __rtld_mrlock_lock (match->l_scope_lock); + + struct call_dl_lookup_args args; + args.name = name; + args.map = match; + args.vers = vers; + args.flags = flags | DL_LOOKUP_ADD_DEPENDENCY | DL_LOOKUP_SCOPE_LOCK; + args.refp = &ref; + + const char *objname; + const char *errstring = NULL; + bool malloced; + int err = GLRO(dl_catch_error) (&objname, &errstring, &malloced, + call_dl_lookup, &args); + + __rtld_mrlock_unlock (match->l_scope_lock); + + if (__builtin_expect (errstring != NULL, 0)) + { + /* The lookup was unsuccessful. Rethrow the error. */ + char *errstring_dup = strdupa (errstring); + char *objname_dup = strdupa (objname); + if (malloced) + free ((char *) errstring); + + GLRO(dl_signal_error) (err, objname_dup, NULL, errstring_dup); + /* NOTREACHED */ + } + + result = args.map; + } + } else if (handle == RTLD_NEXT) { if (__builtin_expect (match == GL(dl_ns)[LM_ID_BASE]._ns_loaded, 0)) |