this change is needed to be compatible with fdpic, where some of the
main application's relocations may be performed as part of the crt1
entry point. if we call init functions before passing control, these
relocations will not yet have been performed, and the init code will
potentially make use of invalid pointers.
conceptually, no code provided by the application or third-party
libraries should run before the application entry point. the
difference is not observable to programs using the crt1 we provide,
but it could come into play if custom entry point code is used, so
it's better to be doing this right anyway.
uintptr_t a = (uintptr_t)&__init_array_start;
for (; a<(uintptr_t)&__init_array_end; a+=sizeof(void(*)()))
(*(void (**)())a)();
+#else
+ void __libc_start_init(void);
+ __libc_start_init();
#endif
/* Pass control to the application */
if (need_locking) pthread_mutex_unlock(&init_fini_lock);
}
+void __libc_start_init(void)
+{
+ do_init_fini(tail);
+}
+
static void dl_debug_state(void)
{
}
__init_libc(envp, argv[0]);
atexit(do_fini);
errno = 0;
- do_init_fini(tail);
CRTJMP((void *)aux[AT_ENTRY], argv-1);
for(;;);