diff options
Diffstat (limited to 'src/exit')
-rw-r--r-- | src/exit/exit.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/exit/exit.c b/src/exit/exit.c index 163d8f1..b391f33 100644 --- a/src/exit/exit.c +++ b/src/exit/exit.c @@ -11,24 +11,24 @@ static void dummy() weak_alias(dummy, __funcs_on_exit); weak_alias(dummy, __stdio_exit); -#ifndef SHARED -weak_alias(dummy, _fini); +extern void _fini() __attribute__((weak)); extern void (*const __fini_array_start)() __attribute__((weak)); extern void (*const __fini_array_end)() __attribute__((weak)); -#endif -_Noreturn void exit(int code) +static void libc_exit_fini(void) { - __funcs_on_exit(); - -#ifndef SHARED uintptr_t a = (uintptr_t)&__fini_array_end; for (; a>(uintptr_t)&__fini_array_start; a-=sizeof(void(*)())) (*(void (**)())(a-sizeof(void(*)())))(); - _fini(); -#endif + if (_fini) _fini(); +} - __stdio_exit(); +weak_alias(libc_exit_fini, __libc_exit_fini); +_Noreturn void exit(int code) +{ + __funcs_on_exit(); + __libc_exit_fini(); + __stdio_exit(); _Exit(code); } |