|
|
@ -158,15 +158,12 @@ impl Thread {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Make a new user process from ELF `data`
|
|
|
|
/// Make a new user process from ELF `data`
|
|
|
|
pub fn new_user<'a, Iter>(
|
|
|
|
pub fn new_user(
|
|
|
|
data: &[u8],
|
|
|
|
data: &[u8],
|
|
|
|
exec_path: &str,
|
|
|
|
exec_path: &str,
|
|
|
|
args: Iter,
|
|
|
|
mut args: Vec<String>,
|
|
|
|
envs: Vec<String>,
|
|
|
|
envs: Vec<String>,
|
|
|
|
) -> Box<Thread>
|
|
|
|
) -> Box<Thread> {
|
|
|
|
where
|
|
|
|
|
|
|
|
Iter: Iterator<Item = &'a str>,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Parse ELF
|
|
|
|
// Parse ELF
|
|
|
|
let elf = ElfFile::new(data).expect("failed to read elf");
|
|
|
|
let elf = ElfFile::new(data).expect("failed to read elf");
|
|
|
|
|
|
|
|
|
|
|
@ -185,12 +182,11 @@ impl Thread {
|
|
|
|
debug!("using loader {}", &loader_path);
|
|
|
|
debug!("using loader {}", &loader_path);
|
|
|
|
// Elf loader should not have INTERP
|
|
|
|
// Elf loader should not have INTERP
|
|
|
|
// No infinite loop
|
|
|
|
// No infinite loop
|
|
|
|
let mut new_args: Vec<&str> = args.collect();
|
|
|
|
args.insert(0, loader_path.into());
|
|
|
|
new_args.insert(0, loader_path);
|
|
|
|
args.insert(1, exec_path.into());
|
|
|
|
new_args.insert(1, exec_path);
|
|
|
|
args.remove(2);
|
|
|
|
new_args.remove(2);
|
|
|
|
warn!("loader args: {:?}", args);
|
|
|
|
warn!("loader args: {:?}", new_args);
|
|
|
|
return Thread::new_user(buf.as_slice(), exec_path, args, envs);
|
|
|
|
return Thread::new_user(buf.as_slice(), exec_path, new_args.into_iter(), envs);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
warn!("loader specified as {} but failed to read", &loader_path);
|
|
|
|
warn!("loader specified as {} but failed to read", &loader_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -219,7 +215,7 @@ impl Thread {
|
|
|
|
|
|
|
|
|
|
|
|
// Make init info
|
|
|
|
// Make init info
|
|
|
|
let init_info = ProcInitInfo {
|
|
|
|
let init_info = ProcInitInfo {
|
|
|
|
args: args.map(|s| String::from(s)).collect(),
|
|
|
|
args,
|
|
|
|
envs,
|
|
|
|
envs,
|
|
|
|
auxv: {
|
|
|
|
auxv: {
|
|
|
|
let mut map = BTreeMap::new();
|
|
|
|
let mut map = BTreeMap::new();
|
|
|
|