From e0f2d48196d0c4e8ed0bbd14c108efc716474c8d Mon Sep 17 00:00:00 2001 From: edef Date: Wed, 24 Dec 2014 06:48:49 +0100 Subject: [PATCH] sneak an extra argument in by using rbx for the jump target --- src/arch.rs | 4 ++-- src/arch.s | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/arch.rs b/src/arch.rs index f768b56..b32d1cc 100644 --- a/src/arch.rs +++ b/src/arch.rs @@ -62,11 +62,11 @@ pub fn initialise_call_frame(stack: &mut Stack, init: uintptr_t, args: &[uintptr rbp: 0, rsp: sp as uintptr_t, ip: bootstrap as uintptr_t, - r12: init, + rbx: init, .. Registers::new() }; - match into_fields!(regs { rdi, r13, r14, r15 } <- args.iter().cloned()) { + match into_fields!(regs { rdi, r12, r13, r14, r15 } <- args.iter().cloned()) { Some(mut args) => if args.next().is_some() { panic!("too many arguments") }, diff --git a/src/arch.s b/src/arch.s index 7326511..a360fca 100644 --- a/src/arch.s +++ b/src/arch.s @@ -84,11 +84,12 @@ lwt_bootstrap: ;; places the parameters in unrelated registers, and we frob them into place ;; out here, in assembly-land. below are the parameter registers in order, ;; along with the alternative register used in parentheses, if there is one. -;; rdi, rsi (r13), rdx (r14), rcx (r15), r8, r9 - mov rsi, r13 - mov rdx, r14 - mov rcx, r15 - jmp r12 +;; rdi, rsi (r12), rdx (r13), rcx (r14), r8(r15), r9 + mov rsi, r12 + mov rdx, r13 + mov rcx, r14 + mov r8, r15 + jmp rbx ;; Rust stores a stack limit at [fs:0x70]. These two functions set and retrieve