From 7b5d0a799b241e120abe84f0c4d8661d37a22f8e Mon Sep 17 00:00:00 2001 From: Jessie Date: Mon, 29 Jan 2024 02:22:04 -0500 Subject: [PATCH] . --- src/win64/misc.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/win64/misc.rs b/src/win64/misc.rs index 0439f30..d795a9b 100644 --- a/src/win64/misc.rs +++ b/src/win64/misc.rs @@ -2,8 +2,9 @@ pub unsafe extern "C" fn __chkstk() { core::arch::asm!( "push %rcx", + "push %rax", "cmp $0x1000,%rax", - "lea 16(%rsp),%rcx", // rsp before calling this routine -> rcx + "lea 24(%rsp),%rcx", "jb 1f", "2:", "sub $0x1000,%rcx", @@ -14,11 +15,8 @@ pub unsafe extern "C" fn __chkstk() { "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 + "pop %rax", + "pop %rcx", "ret", options(noreturn, att_syntax) );