mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* 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.
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
#include <bp-sym.h>
|
||||
#include <caller.h>
|
||||
#include <sysdep-cancel.h>
|
||||
#include <tls.h>
|
||||
|
||||
#include <dl-dst.h>
|
||||
|
||||
@ -125,15 +126,25 @@ add_to_global (struct link_map *new)
|
||||
{
|
||||
/* We have to extend the existing array of link maps in the
|
||||
main map. */
|
||||
struct link_map **old_global
|
||||
= GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_list;
|
||||
size_t new_nalloc = ((ns->_ns_global_scope_alloc + to_add) * 2);
|
||||
|
||||
new_global = (struct link_map **)
|
||||
realloc (ns->_ns_main_searchlist->r_list,
|
||||
((ns->_ns_global_scope_alloc + to_add + 8)
|
||||
* sizeof (struct link_map *)));
|
||||
malloc (new_nalloc * sizeof (struct link_map *));
|
||||
if (new_global == NULL)
|
||||
goto nomem;
|
||||
|
||||
ns->_ns_global_scope_alloc += to_add + 8;
|
||||
memcpy (new_global, old_global,
|
||||
ns->_ns_global_scope_alloc * sizeof (struct link_map *));
|
||||
|
||||
ns->_ns_global_scope_alloc = new_nalloc;
|
||||
ns->_ns_main_searchlist->r_list = new_global;
|
||||
|
||||
if (!RTLD_SINGLE_THREAD_P)
|
||||
THREAD_GSCOPE_WAIT ();
|
||||
|
||||
free (old_global);
|
||||
}
|
||||
|
||||
/* Now add the new entries. */
|
||||
|
Reference in New Issue
Block a user