This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH roland/weak-tls-dtors] Avoid unconditional __call_tls_dtors calls in static linking.


This simpler change doesn't affect the (correct) use of libc_hidden_proto
for __call_tls_dtors, which libpthread also calls.


Thanks,
Roland


2013-03-25  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.

nptl/
2013-03-25  Roland McGrath  <roland@hack.frob.com>

	* pthread_create.c (start_thread) [!SHARED]:
	Call __call_tls_dtors only if it's not NULL.

--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -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);
 
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -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 ();
--- a/stdlib/exit.c
+++ b/stdlib/exit.c
@@ -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]