Skip to content

Commit

Permalink
fix: Leave .bss initialization of loader to firmware
Browse files Browse the repository at this point in the history
Overriding the own bss after load is problematic if items are already in
use. The firmware that loads and jumps into the loader should zero the
.bss already.

Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Aug 10, 2023
1 parent c03ecd0 commit 0ea9038
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/arch/aarch64/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ SECTIONS
*(.data.*)
} :segment_rw
.bss : ALIGN(8) {
bss_start = .;
*(.bss)
*(.bss.*)
bss_end = .;
} :segment_rw
. = ALIGN(4K); /* Align to page boundary */
/***********************************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions src/arch/x86_64/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ SECTIONS
*(.data.*)
}
.bss ALIGN(4096) : AT(ADDR(.bss)) {
bss_start = .;
*(.bss)
*(.bss.*)
}
bss_end = .;
kernel_end = .;
}
2 changes: 0 additions & 2 deletions src/arch/x86_64/link_fc.ld
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ SECTIONS
*(.data.*)
}
.bss ALIGN(4096) : AT(ADDR(.bss)) {
bss_start = .;
*(.bss)
*(.bss.*)
}
bss_end = .;
kernel_end = .;
}
15 changes: 0 additions & 15 deletions src/none.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::fmt::Write;
use core::mem::MaybeUninit;
use core::ptr::addr_of_mut;
use core::slice;

use hermit_entry::elf::KernelObject;
Expand All @@ -17,7 +16,6 @@ extern "C" {
/// (called from entry.asm or entry.rs)
#[no_mangle]
unsafe extern "C" fn loader_main() -> ! {
init_bss();
arch::message_output_init();
crate::log::init();

Expand All @@ -38,19 +36,6 @@ unsafe extern "C" fn loader_main() -> ! {
arch::boot_kernel(kernel_info)
}

unsafe fn init_bss() {
extern "C" {
static mut bss_start: MaybeUninit<u8>;
static mut bss_end: MaybeUninit<u8>;
}

let start_ptr = addr_of_mut!(bss_start);
let end_ptr = addr_of_mut!(bss_end);
let len = end_ptr.offset_from(start_ptr).try_into().unwrap();
let slice = slice::from_raw_parts_mut(start_ptr, len);
slice.fill(MaybeUninit::new(0));
}

#[panic_handler]
fn panic(info: &core::panic::PanicInfo<'_>) -> ! {
// We can't use `println!` or related macros, because `_print` unwraps a result and might panic again
Expand Down

0 comments on commit 0ea9038

Please sign in to comment.