aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-open.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-10-27 15:54:20 +0000
committerUlrich Drepper <drepper@redhat.com>2006-10-27 15:54:20 +0000
commitc0a777e8d01ab40dd9c0ce95328430a4ce7299e3 (patch)
treecf716a0ed441fb850dd3ec3774aa6eebeac4d95b /elf/dl-open.c
parentee96ce2fca39c9660a7efccb708f4ad876b24883 (diff)
downloadglibc-c0a777e8d01ab40dd9c0ce95328430a4ce7299e3.zip
glibc-c0a777e8d01ab40dd9c0ce95328430a4ce7299e3.tar.gz
glibc-c0a777e8d01ab40dd9c0ce95328430a4ce7299e3.tar.bz2
* elf/dl-lookup.c (_dl_debug_bindings): Remove unised 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.
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r--elf/dl-open.c61
1 files changed, 25 insertions, 36 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 85b9637..2ae861f 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -344,7 +344,7 @@ dl_open_worker (void *a)
start the profiling. */
struct link_map *old_profile_map = GL(dl_profile_map);
- _dl_relocate_object (l, l->l_scoperec->scope, 1, 1);
+ _dl_relocate_object (l, l->l_scope, 1, 1);
if (old_profile_map == NULL && GL(dl_profile_map) != NULL)
{
@@ -357,7 +357,7 @@ dl_open_worker (void *a)
}
else
#endif
- _dl_relocate_object (l, l->l_scoperec->scope, lazy, 0);
+ _dl_relocate_object (l, l->l_scope, lazy, 0);
}
if (l == new)
@@ -375,7 +375,7 @@ dl_open_worker (void *a)
not been loaded here and now. */
if (imap->l_init_called && imap->l_type == lt_loaded)
{
- struct r_scope_elem **runp = imap->l_scoperec->scope;
+ struct r_scope_elem **runp = imap->l_scope;
size_t cnt = 0;
while (*runp != NULL)
@@ -395,62 +395,51 @@ dl_open_worker (void *a)
/* The 'r_scope' array is too small. Allocate a new one
dynamically. */
size_t new_size;
- struct r_scoperec *newp;
+ struct r_scope_elem **newp;
- if (imap->l_scoperec != &imap->l_scoperec_mem
- && imap->l_scope_max < NINIT_SCOPE_ELEMS (imap)
- && imap->l_scoperec_mem.nusers == 0)
+#define SCOPE_ELEMS(imap) \
+ (sizeof (imap->l_scope_mem) / sizeof (imap->l_scope_mem[0]))
+
+ if (imap->l_scope != imap->l_scope_mem
+ && imap->l_scope_max < SCOPE_ELEMS (imap))
{
- new_size = NINIT_SCOPE_ELEMS (imap);
- newp = &imap->l_scoperec_mem;
+ new_size = SCOPE_ELEMS (imap);
+ newp = imap->l_scope_mem;
}
else
{
new_size = imap->l_scope_max * 2;
- newp = (struct r_scoperec *)
- malloc (sizeof (struct r_scoperec)
- + new_size * sizeof (struct r_scope_elem *));
+ newp = (struct r_scope_elem **)
+ malloc (new_size * sizeof (struct r_scope_elem *));
if (newp == NULL)
_dl_signal_error (ENOMEM, "dlopen", NULL,
N_("cannot create scope list"));
}
- newp->nusers = 0;
- newp->remove_after_use = false;
- newp->notify = false;
- memcpy (newp->scope, imap->l_scoperec->scope,
- cnt * sizeof (imap->l_scoperec->scope[0]));
- struct r_scoperec *old = imap->l_scoperec;
+ memcpy (newp, imap->l_scope, cnt * sizeof (imap->l_scope[0]));
+ struct r_scope_elem **old = imap->l_scope;
- if (old == &imap->l_scoperec_mem)
- imap->l_scoperec = newp;
- else if (SINGLE_THREAD_P)
- {
- imap->l_scoperec = newp;
- free (old);
- }
+ if (SINGLE_THREAD_P)
+ imap->l_scope = newp;
else
{
- __rtld_mrlock_change (imap->l_scoperec_lock);
- imap->l_scoperec = newp;
- __rtld_mrlock_done (imap->l_scoperec_lock);
-
- atomic_increment (&old->nusers);
- old->remove_after_use = true;
- if (atomic_decrement_val (&old->nusers) == 0)
- /* No user, we can free it here and now. */
- free (old);
+ __rtld_mrlock_change (imap->l_scope_lock);
+ imap->l_scope = newp;
+ __rtld_mrlock_done (imap->l_scope_lock);
}
+ if (old != imap->l_scope_mem)
+ free (old);
+
imap->l_scope_max = new_size;
}
/* First terminate the extended list. Otherwise a thread
might use the new last element and then use the garbage
at offset IDX+1. */
- imap->l_scoperec->scope[cnt + 1] = NULL;
+ imap->l_scope[cnt + 1] = NULL;
atomic_write_barrier ();
- imap->l_scoperec->scope[cnt] = &new->l_searchlist;
+ imap->l_scope[cnt] = &new->l_searchlist;
}
#if USE_TLS
/* Only add TLS memory if this object is loaded now and