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 <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed Aug 10, 2023
1 parent c03ecd0 commit caa42d7
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 19 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 = .;
}
13 changes: 0 additions & 13 deletions src/none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,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 caa42d7

Please sign in to comment.