diff options
author | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2005-03-20 17:45:03 +0000 |
---|---|---|
committer | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2005-03-20 17:45:03 +0000 |
commit | ffd5ef60722c8a7295731cb6f7f54126fd07da3e (patch) | |
tree | b6cf7b6e2d13c1e5f59c6edf0ce728886bfa77b1 | |
parent | d028db7898abe3472c9c5f0019d1dfaa14ecbdc2 (diff) |
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).
-rw-r--r-- | libc/misc/internals/__uClibc_main.c | 10 | ||||
-rw-r--r-- | libc/stdlib/atexit.c | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index 33fc2ec68..a33e6fe4a 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/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); } diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index 082e532fd..d5f83ee8e 100644 --- a/libc/stdlib/atexit.c +++ b/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 |