optimize sys_exec: only read ELF header

master
WangRunji 6 years ago
parent c885ea6d77
commit bc1bad3060

@ -20,6 +20,7 @@ use crate::memory::{
use crate::sync::{Condvar, SpinNoIrqLock as Mutex}; use crate::sync::{Condvar, SpinNoIrqLock as Mutex};
use super::abi::{self, ProcInitInfo}; use super::abi::{self, ProcInitInfo};
use core::mem::uninitialized;
use rcore_fs::vfs::INode; use rcore_fs::vfs::INode;
// TODO: avoid pub // TODO: avoid pub
@ -138,9 +139,11 @@ impl Thread {
mut args: Vec<String>, mut args: Vec<String>,
envs: Vec<String>, envs: Vec<String>,
) -> Result<(MemorySet, usize, usize), &'static str> { ) -> Result<(MemorySet, usize, usize), &'static str> {
// Read data // Read ELF header
let data = inode // 0x3c0: magic number from ld-musl.so
.read_as_vec() let mut data: [u8; 0x3c0] = unsafe { uninitialized() };
inode
.read_at(0, &mut data)
.map_err(|_| "failed to read from INode")?; .map_err(|_| "failed to read from INode")?;
// Parse ELF // Parse ELF

Loading…
Cancel
Save