sim: Don't take address of movable struct
This struct was having addresses taken of fields within it, and then being
returned. It is platform-specific whether this causes a move. It seems to be
working on x86_64, but causes a segfault on aarch64. Box the struct so that it
isn't moved after being initialized.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/mcuboot-sys/src/c.rs b/sim/mcuboot-sys/src/c.rs
index 483ca8f..284cac0 100644
--- a/sim/mcuboot-sys/src/c.rs
+++ b/sim/mcuboot-sys/src/c.rs
@@ -13,6 +13,8 @@
#[allow(unused)]
use std::sync::Once;
+use std::borrow::Borrow;
+
/// The result of an invocation of `boot_go`. This is intentionally opaque so that we can provide
/// accessors for everything we need from this.
#[derive(Debug)]
@@ -90,12 +92,13 @@
image_off: 0,
};
let result: i32 = unsafe {
+ let adesc = areadesc.get_c();
match image_index {
None => raw::invoke_boot_go(&mut sim_ctx as *mut _,
- &areadesc.get_c() as *const _,
+ adesc.borrow() as *const _,
&mut rsp as *mut _, -1) as i32,
Some(i) => raw::invoke_boot_go(&mut sim_ctx as *mut _,
- &areadesc.get_c() as *const _,
+ adesc.borrow() as *const _,
&mut rsp as *mut _,
i as i32) as i32
}