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

Call _init and _fini

parent 882b86e2
No related branches found
No related tags found
No related merge requests found
......@@ -218,12 +218,18 @@ pub extern "C" fn erand(xsubi: [c_ushort; 3]) -> c_double {
#[no_mangle]
pub unsafe extern "C" fn exit(status: c_int) {
extern "C" {
fn _fini();
}
for i in (0..ATEXIT_FUNCS.len()).rev() {
if let Some(func) = ATEXIT_FUNCS[i] {
(func)();
}
}
_fini();
Sys::exit(status);
}
......
use alloc::Vec;
use core::ptr;
use header::stdio;
use header::{stdio, stdlib};
use platform;
use platform::types::*;
use platform::{Pal, Sys};
......@@ -30,6 +30,7 @@ impl Stack {
#[no_mangle]
pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
extern "C" {
fn _init();
fn main(argc: isize, argv: *const *const c_char, envp: *const *const c_char) -> c_int;
}
......@@ -63,11 +64,15 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
stdio::stdout = stdio::default_stdout.get();
stdio::stderr = stdio::default_stderr.get();
Sys::exit(main(
_init();
stdlib::exit(main(
argc,
argv,
// not envp, because programs like bash try to modify this *const*
// pointer :|
platform::environ as *const *const c_char,
));
unreachable!();
}
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