1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

elf, nptl: Resolve recursive lock implementation early

If libpthread is included in libc, it is not necessary to delay
initialization of the lock/unlock function pointers until libpthread
is loaded.  This eliminates two unprotected function pointers
from _rtld_global and removes some initialization code from
libpthread.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer
2021-05-10 10:31:41 +02:00
parent a64af8c9b6
commit d6163dfd38
7 changed files with 120 additions and 24 deletions

View File

@@ -179,15 +179,6 @@ __pthread_initialize_minimal_internal (void)
lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE);
#ifdef SHARED
/* Make __rtld_lock_{,un}lock_recursive use pthread_mutex_{,un}lock,
keep the lock count from the ld.so implementation. */
GL(dl_rtld_lock_recursive) = (void *) __pthread_mutex_lock;
GL(dl_rtld_unlock_recursive) = (void *) __pthread_mutex_unlock;
unsigned int rtld_lock_count = GL(dl_load_lock).mutex.__data.__count;
GL(dl_load_lock).mutex.__data.__count = 0;
while (rtld_lock_count-- > 0)
__pthread_mutex_lock (&GL(dl_load_lock).mutex);
GL(dl_make_stack_executable_hook) = &__make_stacks_executable;
#endif