Browse Source

Prepare for moving ldso FINI handling into libc.
#define _DL_DO_FINI_IN_LIBC to enable(the arch specific part needs to be in place first).

Joakim Tjernlund 20 years ago
parent
commit
ffd5ef6072
2 changed files with 13 additions and 3 deletions
  1. 7 3
      libc/misc/internals/__uClibc_main.c
  2. 6 0
      libc/stdlib/atexit.c

+ 7 - 3
libc/misc/internals/__uClibc_main.c

@@ -155,16 +155,18 @@ void __uClibc_init(void)
 }
 
 #ifdef __UCLIBC_CTOR_DTOR__
-void (*__app_fini)(void) = NULL;
+void attribute_hidden (*__app_fini)(void) = NULL;
 #endif
 
+void attribute_hidden (*__rtld_fini)(void) = NULL;
+
 /* __uClibc_start_main is the new main stub for uClibc. This function is
  * called from crt0 (version 0.9.16 or newer), after ALL shared libraries
  * are initialized, just before we call the application's main function.
  */
 void __attribute__ ((__noreturn__))
 __uClibc_start_main(int argc, char **argv, char **envp,
-	void (*app_init)(void), void (*app_fini)(void))
+	void (*app_init)(void), void (*app_fini)(void), void (*rtld_fini)(void))
 {
 #ifdef __ARCH_HAS_MMU__
     unsigned long *aux_dat;
@@ -176,6 +178,8 @@ __uClibc_start_main(int argc, char **argv, char **envp,
      * __uClibc_init() regardless, to be sure the right thing happens. */
     __uClibc_init();
 
+    __rtld_fini = rtld_fini;
+
     /* If we are dynamically linked, then ldso already did this for us. */
     if (__environ==NULL) {
 	/* Statically linked. */
@@ -260,6 +264,6 @@ __uClibc_start_main(int argc, char **argv, char **envp,
 void __attribute__ ((__noreturn__))
 __uClibc_main(int argc, char **argv, char ** envp)
 {
-    __uClibc_start_main(argc, argv, envp, NULL, NULL);
+    __uClibc_start_main(argc, argv, envp, NULL, NULL, NULL);
 }
 

+ 6 - 0
libc/stdlib/atexit.c

@@ -222,6 +222,7 @@ pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 extern void (*__app_fini)(void);
 #endif
 
+extern void (*__rtld_fini)(void);
 /*
  * Normal program termination
  */
@@ -238,6 +239,11 @@ void exit(int rv)
 	if (__app_fini != NULL)
 		(__app_fini)();
 #endif
+#ifdef _DL_DO_FINI_IN_LIBC
+/* arches that has moved their ldso FINI handling should #define _DL_DO_FINI_IN_LIBC */
+	if (__rtld_fini != NULL)
+		(__rtld_fini)();
+#endif
 
     /* If we are using stdio, try to shut it down.  At the very least,
 	 * this will attempt to commit all buffered writes.  It may also