about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--csu/libc-tls.c2
-rw-r--r--elf/dl-tls.c2
3 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 08fa5a1608..7385bcb707 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-09-06  H.J. Lu  <hongjiu.lu@intel.com>
 
+	[BZ #14545]
+	* csu/libc-tls.c (_dl_initial_dtv): New variable.
+	* elf/dl-tls.c (_dl_deallocate_tls): Always check dtv before
+	freeing dtv[-1].
+
+2012-09-06  H.J. Lu  <hongjiu.lu@intel.com>
+
 	[BZ #14544]
 	* Makeconfig (link-static-before-libc): Replace $(+prector)
 	with $(+prectorT).
diff --git a/csu/libc-tls.c b/csu/libc-tls.c
index b00a5ccb9d..eb9c5025ff 100644
--- a/csu/libc-tls.c
+++ b/csu/libc-tls.c
@@ -65,6 +65,8 @@ size_t _dl_tls_static_size = 2048;
 size_t _dl_tls_static_used;
 /* Alignment requirement of the static TLS block.  */
 size_t _dl_tls_static_align;
+/* Initial dtv of the main thread, not allocated with normal malloc.  */
+void *_dl_initial_dtv = &static_dtv[1];
 
 /* Generation counter for the dtv.  */
 size_t _dl_tls_generation;
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 4138312b94..ff59e9e773 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -477,9 +477,7 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb)
       free (dtv[1 + cnt].pointer.val);
 
   /* The array starts with dtv[-1].  */
-#ifdef SHARED
   if (dtv != GL(dl_initial_dtv))
-#endif
     free (dtv - 1);
 
   if (dealloc_tcb)