Skip to content

Implement FromStr / something that allows storing byte slices / yoke for KernelObject #36

@n0toose

Description

@n0toose

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:

hermit-entry/src/elf.rs

Lines 32 to 35 in 5c87198

/// 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions