Avoid unconditional __call_tls_dtors calls in static linking.
authorRoland McGrath <roland@hack.frob.com>
Thu, 28 Mar 2013 23:52:57 +0000 (16:52 -0700)
committerRoland McGrath <roland@hack.frob.com>
Thu, 28 Mar 2013 23:52:57 +0000 (16:52 -0700)
ChangeLog
include/stdlib.h
nptl/ChangeLog
nptl/pthread_create.c
stdlib/cxa_thread_atexit_impl.c
stdlib/exit.c

index 876b577839add7a51da0ff48a31cb17d115ca479..d4da5407d8319007e60d06d9441c431761d9d60d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-03-28  Roland McGrath  <roland@hack.frob.com>
+
+       * include/stdlib.h [!SHARED] (__call_tls_dtors):
+       Declare with __attribute__ ((weak)).
+       * stdlib/exit.c (__libc_atexit) [!SHARED]:
+       Call __call_tls_dtors only if it's not NULL.
+
 2013-03-28  Roland McGrath  <roland@hack.frob.com>
 
        * csu/libc-start.c (__libc_start_main) [!SHARED]: If _dl_aux_init
index db1812d85ad6f9dd0230ea4a4332be1039726ef9..e50985a5b82c3f1259f6b5f55ee0a9fc53c49443 100644 (file)
@@ -102,8 +102,12 @@ extern int __cxa_atexit_internal (void (*func) (void *), void *arg, void *d)
 
 extern int __cxa_thread_atexit_impl (void (*func) (void *), void *arg,
                                     void *d);
-extern void __call_tls_dtors (void);
-libc_hidden_proto (__call_tls_dtors);
+extern void __call_tls_dtors (void)
+#ifndef SHARED
+  __attribute__ ((weak))
+#endif
+  ;
+libc_hidden_proto (__call_tls_dtors)
 
 extern void __cxa_finalize (void *d);
 
index 707744a6570056919e5a6935ce5afd4262422011..3a1dde6f431deecc91b18331b76edae8662b50b9 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-28  Roland McGrath  <roland@hack.frob.com>
+
+       * pthread_create.c (start_thread) [!SHARED]:
+       Call __call_tls_dtors only if it's not NULL.
+
 2013-03-19  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * allocatestack.c (allocate_stack): Use __default_pthread_attr
index c18278cf08c8ef1d6ad49ae6eafd2e3bf16b5788..c43077fe2d401407967b08b0048fe9975da38e73 100644 (file)
@@ -312,7 +312,10 @@ start_thread (void *arg)
     }
 
   /* Call destructors for the thread_local TLS variables.  */
-  __call_tls_dtors ();
+#ifndef SHARED
+  if (&__call_tls_dtors != NULL)
+#endif
+    __call_tls_dtors ();
 
   /* Run the destructor for the thread-local data.  */
   __nptl_deallocate_tsd ();
index ebf3c4ab059137fdb2c694867824132bc1f2d516..dfd4c7e694a1b98f40fd5433711b3e4592502465 100644 (file)
@@ -76,7 +76,7 @@ __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
 }
 
 /* Call the destructors.  This is called either when a thread returns from the
-   initial function or when the process exits via the exit(3) function.  */
+   initial function or when the process exits via the exit function.  */
 void
 __call_tls_dtors (void)
 {
index 2e86caa2d44026392b1816fe96ceb480057bc31a..270fda7b4fe4daba7d3e07baa2b28c4f1fbef29f 100644 (file)
@@ -34,7 +34,10 @@ __run_exit_handlers (int status, struct exit_function_list **listp,
                     bool run_list_atexit)
 {
   /* First, call the TLS destructors.  */
-  __call_tls_dtors ();
+#ifndef SHARED
+  if (&__call_tls_dtors != NULL)
+#endif
+    __call_tls_dtors ();
 
   /* We do it this way to handle recursive calls to exit () made by
      the functions registered with `atexit' and `on_exit'. We call