summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-open.c12
-rw-r--r--elf/rtld.c16
2 files changed, 19 insertions, 9 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 458cf0cd13..c3f0e42d5e 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -490,6 +490,18 @@ dl_open_worker (void *a)
if (imap->l_need_tls_init)
{
+ /* For static TLS we have to allocate the memory here
+ and now. This includes allocating memory in the DTV.
+ But we cannot change any DTV other than our own. So,
+ if we cannot guarantee that there is room in the DTV
+ we don't even try it and fail the load.
+
+ XXX We could track the minimum DTV slots allocated in
+ all threads. */
+ if (! RTLD_SINGLE_THREAD_P && imap->l_tls_modid > DTV_SURPLUS)
+ _dl_signal_error (0, "dlopen", NULL, N_("\
+cannot load any more object with static TLS"));
+
imap->l_need_tls_init = 0;
#ifdef SHARED
/* Update the slot information data for at least the
diff --git a/elf/rtld.c b/elf/rtld.c
index 69c27cc4ac..f97de9ac08 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2181,8 +2181,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
if (l->l_tls_blocksize != 0 && tls_init_tp_called)
_dl_add_to_slotinfo (l);
}
-
- _dl_sysdep_start_cleanup ();
}
else
{
@@ -2237,13 +2235,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
HP_TIMING_DIFF (relocate_time, start, stop);
- /* Do any necessary cleanups for the startup OS interface code.
- We do these now so that no calls are made after rtld re-relocation
- which might be resolved to different functions than we expect.
- We cannot do this before relocating the other objects because
- _dl_relocate_object might need to call `mprotect' for DT_TEXTREL. */
- _dl_sysdep_start_cleanup ();
-
/* Now enable profiling if needed. Like the previous call,
this has to go here because the calls it makes should use the
rtld versions of the functions (particularly calloc()), but it
@@ -2299,6 +2290,13 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
HP_TIMING_ACCUM_NT (relocate_time, add);
}
+ /* Do any necessary cleanups for the startup OS interface code.
+ We do these now so that no calls are made after rtld re-relocation
+ which might be resolved to different functions than we expect.
+ We cannot do this before relocating the other objects because
+ _dl_relocate_object might need to call `mprotect' for DT_TEXTREL. */
+ _dl_sysdep_start_cleanup ();
+
#ifdef SHARED
/* Auditing checkpoint: we have added all objects. */
if (__builtin_expect (GLRO(dl_naudit) > 0, 0))