about summary refs log tree commit diff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-12-03 01:51:07 +0000
committerRoland McGrath <roland@gnu.org>2002-12-03 01:51:07 +0000
commit2d14868942150183adaf0bc80b8ed6b70b65261e (patch)
tree6f1aea1c1f443244ed6a0883ddf276c01232381d /elf/dl-load.c
parentf87277f2cdbfde84d4b82687a62e6eb8fd2222f9 (diff)
downloadglibc-2d14868942150183adaf0bc80b8ed6b70b65261e.tar.gz
glibc-2d14868942150183adaf0bc80b8ed6b70b65261e.tar.xz
glibc-2d14868942150183adaf0bc80b8ed6b70b65261e.zip
* elf/tst-tls4.c: Define an unused TLS variable here, so that no lazy
	TLS setup is required.
	* elf/tst-tls5.c: Likewise.
	* elf/tst-tls6.c: Likewise.
	* elf/tst-tls7.c: Likewise.
	* elf/tst-tls8.c: Likewise.
	* elf/tst-tls9.c: Likewise.

	* elf/rtld.c (dl_main): Remove [! SHARED] conditional from
	`if (GL(dl_tls_max_dtv_idx) > 0)' tests for doing TLS setup.
	* elf/dl-close.c (libc_freeres_fn): Check GL(dl_tls_dtv_slotinfo_list)
	for being null before calling free_slotinfo.
	* elf/dl-load.c (_dl_map_object_from_fd) [SHARED]: For PT_TLS in
	dynamic loading, bail with error if GL(dl_tls_max_dtv_idx) is zero.
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 3452c0b1b4..c550204ac5 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -942,7 +942,19 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 
 	case PT_TLS:
 #ifdef USE_TLS
-	  if (ph->p_memsz > 0)
+	  if (ph->p_memsz == 0)
+	    /* Nothing to do for an empty segment.  */
+	    break;
+
+	  /* If not loading the initial set of shared libraries,
+	     check whether we should permit loading a TLS segment.  */
+	  if (
+# ifdef SHARED
+	      __builtin_expect (l->l_type == lt_library, 1) ||
+# endif
+	      /* If GL(dl_tls_max_dtv_idx) == 0, then rtld.c did not
+		 set up TLS data structures, so don't use them now.  */
+	      __builtin_expect (GL(dl_tls_max_dtv_idx), 1) != 0)
 	    {
 	      l->l_tls_blocksize = ph->p_memsz;
 	      l->l_tls_align = ph->p_align;
@@ -953,14 +965,20 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 
 	      /* Assign the next available module ID.  */
 	      l->l_tls_modid = _dl_next_tls_modid ();
+	      break;
 	    }
-#else
+
+	  if (l->l_prev == NULL)
+	    /* We are loading the executable itself when the dynamic linker
+	       was executed directly.  The setup will happen later.  */
+	    break;
+#endif
+
 	  /* Uh-oh, the binary expects TLS support but we cannot
 	     provide it.  */
 	  errval = 0;
 	  errstring = N_("cannot handle TLS data");
 	  goto call_lose;
-#endif
 	  break;
 	}