Skip to content

Commit d0d10fe

Browse files
committed
don't call slice::as_ptr
We want to avoid directly accessing the data in the .bootloader-config section and slice::as_ptr gets a pointer to that data. Instead we cast a reference to a reference to the data in .bootloader-config to an address and pass that to the asm! block. The problem with as_ptr was that it's a method on the slice and not the reference and so by calling slice::as_ptr, we once again directly accessed the slice when we only meant to access the reference to the reference to the data.
1 parent b785b6d commit d0d10fe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

api/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ macro_rules! entry_point {
140140

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

0 commit comments

Comments
 (0)