Revert "Register __libc_fini as early as possible."

This reverts commit e880c736d6.

Change-Id: Ide83e442eb5dbfef5298a15bc602c3fe1dda1862
This commit is contained in:
Dmitriy Ivanov
2014-09-04 21:54:34 +00:00
parent e880c736d6
commit 4b41555ba5
6 changed files with 27 additions and 15 deletions

View File

@@ -61,9 +61,6 @@
extern "C" int __cxa_atexit(void (*)(void *), void *, void *);
__attribute__ ((section (".fini_array")))
void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
static void call_array(void(**list)()) {
// First element is -1, list is null-terminated
while (*++list) {
@@ -102,13 +99,14 @@ __noreturn void __libc_init(void* raw_args,
// do never use it. Therefore, we ignore it.
call_array(structors->preinit_array);
call_array(structors->init_array);
// The executable may have its own destructors listed in its .fini_array
// so we need to ensure that these are called when the program exits
// normally.
__cxa_atexit(__libc_fini,&__FINI_ARRAY__, NULL);
call_array(structors->init_array);
if (structors->fini_array != NULL) {
__cxa_atexit(__libc_fini,structors->fini_array,NULL);
}
exit(slingshot(args.argc, args.argv, args.envp));
}