mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
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: Inlcude <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. * include/atomic.h: Rename atomic_and to atomic_and_val and atomic_or to atomic_or_val. Define new macros atomic_and and atomic_or which do not return values. * sysdeps/x86_64/bits/atomic.h: Define atomic_and and atomic_or. Various cleanups. * sysdeps/i386/i486/bits/atomic.h: Likewise.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/* On-demand PLT fixup for shared objects.
|
||||
Copyright (C) 1995-2002,2003,2004,2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -92,16 +92,36 @@ _dl_fixup (
|
||||
version = NULL;
|
||||
}
|
||||
|
||||
struct r_scoperec *scoperec = l->l_scoperec;
|
||||
if (l->l_type == lt_loaded)
|
||||
{
|
||||
__rtld_mrlock_lock (l->l_scoperec_lock);
|
||||
scoperec = l->l_scoperec;
|
||||
atomic_increment (&scoperec->nusers);
|
||||
__rtld_mrlock_unlock (l->l_scoperec_lock);
|
||||
}
|
||||
|
||||
result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym,
|
||||
l->l_scope, version, ELF_RTYPE_CLASS_PLT,
|
||||
scoperec->scope, version,
|
||||
ELF_RTYPE_CLASS_PLT,
|
||||
DL_LOOKUP_ADD_DEPENDENCY, NULL);
|
||||
|
||||
if (l->l_type == lt_loaded
|
||||
&& atomic_decrement_val (&scoperec->nusers) == 0
|
||||
&& __builtin_expect (scoperec->remove_after_use, 0))
|
||||
{
|
||||
if (scoperec->notify)
|
||||
__rtld_notify (scoperec->nusers);
|
||||
else
|
||||
free (scoperec);
|
||||
}
|
||||
|
||||
/* Currently result contains the base load address (or link map)
|
||||
of the object that defines sym. Now add in the symbol
|
||||
offset. */
|
||||
value = DL_FIXUP_MAKE_VALUE (result,
|
||||
sym ? LOOKUP_VALUE_ADDRESS (result)
|
||||
+ sym->st_value : 0);
|
||||
sym ? (LOOKUP_VALUE_ADDRESS (result)
|
||||
+ sym->st_value) : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -174,11 +194,30 @@ _dl_profile_fixup (
|
||||
version = NULL;
|
||||
}
|
||||
|
||||
struct r_scoperec *scoperec = l->l_scoperec;
|
||||
if (l->l_type == lt_loaded)
|
||||
{
|
||||
__rtld_mrlock_lock (l->l_scoperec_lock);
|
||||
scoperec = l->l_scoperec;
|
||||
atomic_increment (&scoperec->nusers);
|
||||
__rtld_mrlock_unlock (l->l_scoperec_lock);
|
||||
}
|
||||
|
||||
result = _dl_lookup_symbol_x (strtab + refsym->st_name, l, &defsym,
|
||||
l->l_scope, version,
|
||||
scoperec->scope, version,
|
||||
ELF_RTYPE_CLASS_PLT,
|
||||
DL_LOOKUP_ADD_DEPENDENCY, NULL);
|
||||
|
||||
if (l->l_type == lt_loaded
|
||||
&& atomic_decrement_val (&scoperec->nusers) == 0
|
||||
&& __builtin_expect (scoperec->remove_after_use, 0))
|
||||
{
|
||||
if (scoperec->notify)
|
||||
__rtld_notify (scoperec->nusers);
|
||||
else
|
||||
free (scoperec);
|
||||
}
|
||||
|
||||
/* Currently result contains the base load address (or link map)
|
||||
of the object that defines sym. Now add in the symbol
|
||||
offset. */
|
||||
|
Reference in New Issue
Block a user