1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 00:16:17 +04:00

fix clear bss when load user program. 'sh' works!

This commit is contained in:
WangRunji 2018-11-16 00:17:05 +08:00
parent 40b099ed79
commit 9b3294a5f2

View File

@ -80,12 +80,11 @@ impl ContextImpl {
let virt_addr = ph.virtual_addr() as usize;
let offset = ph.offset() as usize;
let file_size = ph.file_size() as usize;
if file_size == 0 {
return;
}
use core::slice;
let target = unsafe { slice::from_raw_parts_mut(virt_addr as *mut u8, file_size) };
target.copy_from_slice(&data[offset..offset + file_size]);
let mem_size = ph.mem_size() as usize;
let target = unsafe { ::core::slice::from_raw_parts_mut(virt_addr as *mut u8, mem_size) };
target[..file_size].copy_from_slice(&data[offset..offset + file_size]);
target[file_size..].iter_mut().for_each(|x| *x = 0);
}
ustack_top = push_args_at_stack(args, ustack_top);
});