about summary refs log tree commit diff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-11-23 13:12:03 +0100
committerFlorian Weimer <fweimer@redhat.com>2016-11-23 13:12:03 +0100
commit7a5e3d9d633c828d84a9535f26b202a6179978e7 (patch)
treed90227bd1ddf169cf7d986cbd89e8b66cca1d551 /elf/dl-load.c
parentb0216d3e4d98a3528bad428c22ff96fcbcc102a4 (diff)
downloadglibc-7a5e3d9d633c828d84a9535f26b202a6179978e7.tar.gz
glibc-7a5e3d9d633c828d84a9535f26b202a6179978e7.tar.xz
glibc-7a5e3d9d633c828d84a9535f26b202a6179978e7.zip
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.
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c54
1 files changed, 7 insertions, 47 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index c0d6249373..51fb0d005c 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1135,54 +1135,14 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
 	    }
 
 #ifdef SHARED
-	  if (l->l_prev == NULL || (mode & __RTLD_AUDIT) != 0)
-	    /* We are loading the executable itself when the dynamic linker
-	       was executed directly.  The setup will happen later.  */
-	    break;
-
-# ifdef _LIBC_REENTRANT
-	  /* In a static binary there is no way to tell if we dynamically
-	     loaded libpthread.  */
-	  if (GL(dl_error_catch_tsd) == &_dl_initial_error_catch_tsd)
-# endif
+	  /* We are loading the executable itself when the dynamic
+	     linker was executed directly.  The setup will happen
+	     later.  Otherwise, the TLS data structures are already
+	     initialized, and we assigned a TLS modid above.  */
+	  assert (l->l_prev == NULL || (mode & __RTLD_AUDIT) != 0);
+#else
+	  assert (false && "TLS not initialized in static application");
 #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;
 
 	case PT_GNU_STACK: