From 21ae674510a7bb7cb1cc24002bee06ced6026044 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 28 Apr 2020 19:01:53 +0800 Subject: [PATCH] kernel: handle no BSS --- runtime/src/kernel.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/runtime/src/kernel.rs b/runtime/src/kernel.rs index 9dfb157..a1ce03e 100644 --- a/runtime/src/kernel.rs +++ b/runtime/src/kernel.rs @@ -118,12 +118,15 @@ pub fn main_core1() { Message::LoadRequest(data) => { match dyld::Library::load(&data, &mut image, &resolve) { Ok(library) => { - let __bss_start = library.lookup(b"__bss_start").unwrap(); - let _end = library.lookup(b"_end").unwrap(); - let __modinit__ = library.lookup(b"__modinit__").unwrap(); - unsafe { - ptr::write_bytes(__bss_start as *mut u8, 0, (_end - __bss_start) as usize); + let bss_start = library.lookup(b"__bss_start"); + let end = library.lookup(b"_end"); + if let Some(bss_start) = bss_start { + let end = end.unwrap(); + unsafe { + 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__); debug!("kernel loaded"); core1_tx.send(Message::LoadCompleted)