8000 avoid 32-bit relocation to __BOOTLOADER_CONFIG by Freax13 · Pull Request #428 · rust-osdev/bootloader · GitHub
[go: up one dir, main page]

Skip to content

avoid 32-bit relocation to __BOOTLOADER_CONFIG #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add another level of indirection
This prevents the compiler from optimzing out __BOOTLOADER_CONFIG_REF
in favor of accessing __BOOTLOADER_CONFIG directly.
  • Loading branch information
Freax13 committed Feb 23, 2024
commit b785b6d4f059c5b08a7a1a9cfa95a5ffaa35af9d
4 changes: 2 additions & 2 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ macro_rules! entry_point {
let f: fn(&'static mut $crate::BootInfo) -> ! = $path;

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

f(boot_info)
}
Expand All @@ -139,7 +139,7 @@ macro_rules! entry_point {
}

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