Load ELF from memory using memfd_create

This commit is contained in:
Michael Mikovsky
2025-11-24 13:13:06 -07:00
parent 0c538e9dcf
commit dae1d524bc
14 changed files with 340 additions and 21 deletions
+11 -2
View File
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fs::File;
use std::{collections::HashMap, io::Read};
use lazy_static::lazy_static;
use unshell_lib::{
@@ -38,7 +39,15 @@ fn main() {
let mut modules = Vec::new();
for arg in args.skip(1) {
debug!("Loading module: {}", arg);
modules.push(Module::new(&arg)?)
let mut file = File::open(arg).map_err(|e| ModuleError::Error(e.to_string().into()))?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)
.map_err(|e| ModuleError::Error(e.to_string().into()))?;
modules.push(Module::new_bytes(&buffer)?)
// modules.push(Module::new(&arg)?)
}
// Run the manager, this is blocking.