Initialize sp value for each threads (temporary workaround)
This commit is contained in:
@ -308,16 +308,18 @@ pub enum LoaderError {
|
||||
|
||||
impl Loader {
|
||||
|
||||
pub fn new(path: &str, machine: &mut Machine, start_index: usize) -> Result<Self, LoaderError> {
|
||||
pub fn new(path: &str, machine: &mut Machine, start_index: usize) -> Result<(Self, u64), LoaderError> {
|
||||
let loader = Self::load_and_parse(path)?;
|
||||
loader.load_into_machine(machine, start_index)?;
|
||||
Ok(loader)
|
||||
let end_alloc = loader.load_into_machine(machine, start_index)?;
|
||||
Ok((loader, end_alloc))
|
||||
}
|
||||
|
||||
fn load_into_machine(&self, machine: &mut Machine, start_index: usize) -> Result<u64, LoaderError>{
|
||||
fn load_into_machine(&self, machine: &mut Machine, start_index: usize) -> Result<u64, LoaderError> {
|
||||
let mut end_index = 0;
|
||||
for i in 0..self.sections.len() {
|
||||
let section = &self.sections[i];
|
||||
if section.does_flag_contains_key(FlagValue::ShfAlloc) {
|
||||
end_index = section.virt_addr + section.section_size;
|
||||
// Can allocate to machine memory
|
||||
for j in (0..section.section_size as usize).step_by(4) {
|
||||
let mut buf: [u8; 4] = [0; 4];
|
||||
@ -328,8 +330,7 @@ impl Loader {
|
||||
}
|
||||
}
|
||||
}
|
||||
let last = self.sections.last().ok_or(LoaderError::ParsingError)?;
|
||||
Ok(start_index as u64 + last.virt_addr + last.section_size)
|
||||
Ok(start_index as u64 + end_index)
|
||||
}
|
||||
|
||||
fn load_and_parse(path: &str) -> Result<Self, LoaderError> {
|
||||
|
Reference in New Issue
Block a user