Skip to content

Commit b785b6d

Browse files
committed
add another level of indirection
This prevents the compiler from optimzing out __BOOTLOADER_CONFIG_REF in favor of accessing __BOOTLOADER_CONFIG directly.
1 parent 6652010 commit b785b6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

api/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ macro_rules! entry_point {
130130
let f: fn(&'static mut $crate::BootInfo) -> ! = $path;
131131

132132
// ensure that the config is used so that the linker keeps it
133-
$crate::__force_use(__BOOTLOADER_CONFIG_REF);
133+
$crate::__force_use(&__BOOTLOADER_CONFIG_REF);
134134

135135
f(boot_info)
136136
}
@@ -139,7 +139,7 @@ macro_rules! entry_point {
139139
}
140140

141141
#[doc(hidden)]
142-
pub fn __force_use(slice: &[u8]) {
142+
pub fn __force_use(slice: &&[u8; BootloaderConfig::SERIALIZED_LEN]) {
143143
let force_use = slice.as_ptr() as usize;
144144
unsafe { core::arch::asm!("add {0}, 0", in(reg) force_use, options(nomem, nostack)) };
145145
}

0 commit comments

Comments
 (0)