kernel: handle no BSS

This commit is contained in:
Sebastien Bourdeauducq 2020-04-28 19:01:53 +08:00
parent 826368205f
commit 21ae674510
1 changed files with 8 additions and 5 deletions

View File

@ -118,12 +118,15 @@ pub fn main_core1() {
Message::LoadRequest(data) => { Message::LoadRequest(data) => {
match dyld::Library::load(&data, &mut image, &resolve) { match dyld::Library::load(&data, &mut image, &resolve) {
Ok(library) => { Ok(library) => {
let __bss_start = library.lookup(b"__bss_start").unwrap(); let bss_start = library.lookup(b"__bss_start");
let _end = library.lookup(b"_end").unwrap(); let end = library.lookup(b"_end");
let __modinit__ = library.lookup(b"__modinit__").unwrap(); if let Some(bss_start) = bss_start {
let end = end.unwrap();
unsafe { unsafe {
ptr::write_bytes(__bss_start as *mut u8, 0, (_end - __bss_start) as usize); ptr::write_bytes(bss_start as *mut u8, 0, (end - bss_start) as usize);
} }
}
let __modinit__ = library.lookup(b"__modinit__").unwrap();
current_modinit = Some(__modinit__); current_modinit = Some(__modinit__);
debug!("kernel loaded"); debug!("kernel loaded");
core1_tx.send(Message::LoadCompleted) core1_tx.send(Message::LoadCompleted)