Skip to content
Snippets Groups Projects
Verified Commit ae115ac6 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Run pre-init array before _init

parent e764fedb
No related branches found
No related tags found
No related merge requests found
......@@ -77,19 +77,25 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
stdio::stdout = stdio::default_stdout.get();
stdio::stderr = stdio::default_stderr.get();
// Run preinit array
{
let mut f = &__preinit_array_start as *const _;
while f < &__preinit_array_end {
(*f)();
f = f.offset(1);
}
}
// Call init section
_init();
// Look for the neighbor functions in memory until the end
let mut f = &__preinit_array_start as *const _;
while f < &__preinit_array_end {
(*f)();
f = f.offset(1);
}
f = &__init_array_start as *const _;
while f < &__init_array_end {
(*f)();
f = f.offset(1);
// Run init array
{
let mut f = &__init_array_start as *const _;
while f < &__init_array_end {
(*f)();
f = f.offset(1);
}
}
// not argv or envp, because programs like bash try to modify this *const* pointer :|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment