mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
elf: Assume TLS is initialized in _dl_map_object_from_fd
libc.so uses TLS data, so when dlopen is called later, the TLS data structures have already been initialized.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2016-11-23 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-load.c (_dl_map_object_from_fd): Delayed TLS data
|
||||||
|
structure initialization is no longer needed.
|
||||||
|
|
||||||
2016-11-23 Joseph Myers <joseph@codesourcery.com>
|
2016-11-23 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
[BZ #20855]
|
[BZ #20855]
|
||||||
|
@ -1135,54 +1135,14 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHARED
|
#ifdef SHARED
|
||||||
if (l->l_prev == NULL || (mode & __RTLD_AUDIT) != 0)
|
/* We are loading the executable itself when the dynamic
|
||||||
/* We are loading the executable itself when the dynamic linker
|
linker was executed directly. The setup will happen
|
||||||
was executed directly. The setup will happen later. */
|
later. Otherwise, the TLS data structures are already
|
||||||
break;
|
initialized, and we assigned a TLS modid above. */
|
||||||
|
assert (l->l_prev == NULL || (mode & __RTLD_AUDIT) != 0);
|
||||||
# ifdef _LIBC_REENTRANT
|
#else
|
||||||
/* In a static binary there is no way to tell if we dynamically
|
assert (false && "TLS not initialized in static application");
|
||||||
loaded libpthread. */
|
|
||||||
if (GL(dl_error_catch_tsd) == &_dl_initial_error_catch_tsd)
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
/* We have not yet loaded libpthread.
|
|
||||||
We can do the TLS setup right now! */
|
|
||||||
|
|
||||||
void *tcb;
|
|
||||||
|
|
||||||
/* The first call allocates TLS bookkeeping data structures.
|
|
||||||
Then we allocate the TCB for the initial thread. */
|
|
||||||
if (__glibc_unlikely (_dl_tls_setup ())
|
|
||||||
|| __glibc_unlikely ((tcb = _dl_allocate_tls (NULL)) == NULL))
|
|
||||||
{
|
|
||||||
errval = ENOMEM;
|
|
||||||
errstring = N_("\
|
|
||||||
cannot allocate TLS data structures for initial thread");
|
|
||||||
goto call_lose;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now we install the TCB in the thread register. */
|
|
||||||
errstring = TLS_INIT_TP (tcb);
|
|
||||||
if (__glibc_likely (errstring == NULL))
|
|
||||||
{
|
|
||||||
/* Now we are all good. */
|
|
||||||
l->l_tls_modid = ++GL(dl_tls_max_dtv_idx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The kernel is too old or somesuch. */
|
|
||||||
errval = 0;
|
|
||||||
_dl_deallocate_tls (tcb, 1);
|
|
||||||
goto call_lose;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Uh-oh, the binary expects TLS support but we cannot
|
|
||||||
provide it. */
|
|
||||||
errval = 0;
|
|
||||||
errstring = N_("cannot handle TLS data");
|
|
||||||
goto call_lose;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PT_GNU_STACK:
|
case PT_GNU_STACK:
|
||||||
|
Reference in New Issue
Block a user