.
This commit is contained in:
10
src/lib.rs
10
src/lib.rs
@@ -1,12 +1,18 @@
|
|||||||
#![no_std]
|
#![no_std] #![feature(naked_functions)]
|
||||||
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
|
#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
|
||||||
mod win64 {
|
mod win64 {
|
||||||
|
|
||||||
|
#[used] #[no_mangle]
|
||||||
|
static _fltused: i32 = 0;
|
||||||
|
|
||||||
mod memcpy;
|
mod memcpy;
|
||||||
mod memset;
|
mod memset;
|
||||||
mod strlen;
|
mod strlen;
|
||||||
mod memmove;
|
mod memmove;
|
||||||
mod memcmp;
|
mod memcmp;
|
||||||
|
|
||||||
|
mod misc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
@@ -35,7 +41,5 @@ extern "system" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
src/win64/misc.rs
Normal file
25
src/win64/misc.rs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#[no_mangle] #[naked]
|
||||||
|
pub unsafe extern "C" fn __chkstk() {
|
||||||
|
core::arch::asm!(
|
||||||
|
"push %rcx",
|
||||||
|
"cmp $0x1000,%rax",
|
||||||
|
"lea 16(%rsp),%rcx", // rsp before calling this routine -> rcx
|
||||||
|
"jb 1f",
|
||||||
|
"2:",
|
||||||
|
"sub $0x1000,%rcx",
|
||||||
|
"test %rcx,(%rcx)",
|
||||||
|
"sub $0x1000,%rax",
|
||||||
|
"cmp $0x1000,%rax",
|
||||||
|
"ja 2b",
|
||||||
|
"1:",
|
||||||
|
"sub %rax,%rcx",
|
||||||
|
"test %rcx,(%rcx)",
|
||||||
|
"lea 8(%rsp),%rax", // load pointer to the return address into rax
|
||||||
|
"mov %rcx,%rsp", // install the new top of stack pointer into rsp
|
||||||
|
"mov -8(%rax),%rcx", // restore rcx
|
||||||
|
"push (%rax)", // push return address onto the stack
|
||||||
|
"sub %rsp,%rax", // restore the original value in rax
|
||||||
|
"ret",
|
||||||
|
options(noreturn, att_syntax)
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user