Currently, KernelObject could be used like this:
let elf = fs::read(&kernel_path)?;
let object =
KernelObject::parse(&elf).map_err(...)?;
However, I asked around (after having worked on hermit-os/uhyve#725) as to how I could prevent the "use-after-free" warning that prevented me from storing the object object in the UhyveVm struct - and the problem seems to be that we depend on references that get "destroyed" soon afterwards:
|
/// A parsed kernel object ready for loading. |
|
pub struct KernelObject<'a> { |
|
/// The raw bytes of the parsed ELF file. |
|
elf: &'a [u8], |
A potential solution could be implementing something similar to the following trait: https://doc.rust-lang.org/std/str/trait.FromStr.html