Add signal support - exit on signal
This commit is contained in:
parent
b551b30300
commit
bf292bc0d1
1 changed files with 393 additions and 311 deletions
40
libstd/libc/src/start.rs
Normal file
40
libstd/libc/src/start.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use super::exit;
|
||||
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub unsafe fn _start() {
|
||||
asm!("push esp
|
||||
call _start_stack
|
||||
pop esp"
|
||||
:
|
||||
:
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
let _ = exit(0);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub unsafe fn _start() {
|
||||
asm!("mov rdi, rsp
|
||||
and rsp, 0xFFFFFFFFFFFFFFF0
|
||||
call _start_stack"
|
||||
:
|
||||
:
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
let _ = exit(0);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn _start_stack(stack: *const usize){
|
||||
extern "C" {
|
||||
fn main(argc: usize, argv: *const *const u8) -> usize;
|
||||
}
|
||||
|
||||
let argc = *stack as usize;
|
||||
let argv = stack.offset(1) as *const *const u8;
|
||||
let _ = exit(main(argc, argv));
|
||||
}
|
||||
Loading…
Reference in a new issue