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 876b577..d4da540 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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
        didn't do it already, then set _dl_phdr and _dl_phnum based on the
        magic __ehdr_start linker symbol if it's defined.
index db1812d..e50985a 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 707744a..3a1dde6 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 c18278c..c43077f 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 ebf3c4a..dfd4c7e 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 2e86caa..270fda7 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