Skip to content

Commit 3135058

Browse files
committed
use #[used]
1 parent e791ee5 commit 3135058

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

api/src/lib.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,20 @@ macro_rules! entry_point {
115115
($path:path, config = $config:expr) => {
116116
const _: () = {
117117
#[unsafe(link_section = ".bootloader-config")]
118+
#[used]
118119
pub static __BOOTLOADER_CONFIG: [u8; $crate::BootloaderConfig::SERIALIZED_LEN] = {
119120
// validate the type
120121
let config: &$crate::BootloaderConfig = $config;
121122
config.serialize()
122123
};
123124

124-
// Workaround for https://github.com/rust-osdev/bootloader/issues/427
125-
static __BOOTLOADER_CONFIG_REF: &[u8; $crate::BootloaderConfig::SERIALIZED_LEN] =
126-
&__BOOTLOADER_CONFIG;
127-
128125
#[unsafe(export_name = "_start")]
129126
pub extern "C" fn __impl_start(boot_info: &'static mut $crate::BootInfo) -> ! {
130127
// validate the signature of the program entry point
131128
let f: fn(&'static mut $crate::BootInfo) -> ! = $path;
132129

133-
// ensure that the config is used so that the linker keeps it
134-
$crate::__force_use(&__BOOTLOADER_CONFIG_REF);
135-
136130
f(boot_info)
137131
}
138132
};
139133
};
140-
}
141-
142-
#[doc(hidden)]
143-
#[cfg(target_arch = "x86_64")]
144-
pub fn __force_use(slice: &&[u8; BootloaderConfig::SERIALIZED_LEN]) {
145-
let force_use = slice as *const _ as usize;
146-
unsafe { core::arch::asm!("add {0}, 0", in(reg) force_use, options(nomem, nostack)) };
147-
}
134+
}

0 commit comments

Comments
 (0)