From a706317769553d1f1c3c4425bf0e107dde4da78f Mon Sep 17 00:00:00 2001 From: David Brown Date: Tue, 25 Jun 2024 10:00:31 -0600 Subject: [PATCH] sim: Increase jmpbuf size Increase the size of the jmpbuf to accomodate other architectures. Unfortunately, the size of this is not available in the libc crate. Increase this so encompass any platforms we wish to support, including aarch64 on both Linux and MacOS. Increasing an array beyond 32 means there is no default offered, so implement this manually. Signed-off-by: David Brown --- sim/mcuboot-sys/src/api.rs | 16 ++++++++++++++-- sim/mcuboot-sys/src/c.rs | 4 +--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sim/mcuboot-sys/src/api.rs b/sim/mcuboot-sys/src/api.rs index 7014d5c83..0a098ffb3 100644 --- a/sim/mcuboot-sys/src/api.rs +++ b/sim/mcuboot-sys/src/api.rs @@ -90,7 +90,7 @@ impl Default for FlashContext { } #[repr(C)] -#[derive(Debug, Default)] +#[derive(Debug)] pub struct CSimContext { pub flash_counter: libc::c_int, pub jumped: libc::c_int, @@ -99,7 +99,19 @@ pub struct CSimContext { // NOTE: Always leave boot_jmpbuf declaration at the end; this should // store a "jmp_buf" which is arch specific and not defined by libc crate. // The size below is enough to store data on a x86_64 machine. - pub boot_jmpbuf: [u64; 16], + pub boot_jmpbuf: [u64; 48], +} + +impl Default for CSimContext { + fn default() -> Self { + CSimContext { + flash_counter: 0, + jumped: 0, + c_asserts: 0, + c_catch_asserts: 0, + boot_jmpbuf: [0; 48], + } + } } pub struct CSimContextPtr { diff --git a/sim/mcuboot-sys/src/c.rs b/sim/mcuboot-sys/src/c.rs index 284cac04b..9d2a321b7 100644 --- a/sim/mcuboot-sys/src/c.rs +++ b/sim/mcuboot-sys/src/c.rs @@ -81,10 +81,8 @@ pub fn boot_go(multiflash: &mut SimMultiFlash, areadesc: &AreaDesc, None => 0, Some(ref c) => **c as libc::c_int }, - jumped: 0, - c_asserts: 0, c_catch_asserts: if catch_asserts { 1 } else { 0 }, - boot_jmpbuf: [0; 16], + .. Default::default() }; let mut rsp = api::BootRsp { br_hdr: std::ptr::null(),