Skip to main content

ProgramImage

Struct ProgramImage 

Source
pub struct ProgramImage {
    pub elf_type: u16,
    pub entry_pc: u64,
    pub segments: Vec<LoadSegment>,
    pub symbols: BTreeMap<String, ProgramSymbol>,
    pub imports: Vec<ImportedSymbol>,
    pub interp: Option<String>,
    pub brk_base: u64,
    pub elf_phdr_addr: Option<u64>,
    pub elf_phent_size: u16,
    pub elf_phnum: u16,
}
Expand description

Stores parsed ELF data in a form that the MMU can map without parsing again.

Fields§

§elf_type: u16

Gives the ELF object type, such as ET_EXEC or ET_DYN.

§entry_pc: u64

Gives the main executable entry address before interpreter selection.

§segments: Vec<LoadSegment>

Owns the loadable segments that define the initial process image.

§symbols: BTreeMap<String, ProgramSymbol>

Maps each retained ELF symbol name to its metadata.

§imports: Vec<ImportedSymbol>

Lists RISC-V jump-slot relocations for future import connection.

§interp: Option<String>

Names the guest dynamic loader from PT_INTERP, when present.

§brk_base: u64

Gives the page-aligned initial heap end after all load segments.

§elf_phdr_addr: Option<u64>

Gives the mapped program-header address used for AT_PHDR.

§elf_phent_size: u16

Gives one program-header entry size used for AT_PHENT.

§elf_phnum: u16

Gives the program-header count used for AT_PHNUM.

Implementations§

Source§

impl ProgramImage

Source

pub fn from_segments(entry_pc: u64, segments: Vec<LoadSegment>) -> Self

Builds a synthetic image from caller-supplied segments.

Source

pub fn from_elf_bytes(bytes: &[u8]) -> Result<Self, Box<dyn Error>>

Accepts only RISC-V ELF64 little-endian input because the current process ABI is RV64.

Source

pub fn exec_region_containing(&self, pc: u64) -> Option<(u64, &[u8])>

Limits lifting to file-backed executable bytes so data and BSS are not decoded as code.

Source

pub fn find_symbol(&self, name: &str) -> Option<&ProgramSymbol>

Finds one symbol by its exact ELF name for entry and register setup.

Source

pub fn symbol_at(&self, address: u64) -> Option<&ProgramSymbol>

Finds the closest defined symbol at or below a mapped guest address.

Source

pub fn imports(&self) -> &[ImportedSymbol]

Borrows sorted jump-slot imports without exposing the owned vector for changes.

Trait Implementations§

Source§

impl Clone for ProgramImage

Source§

fn clone(&self) -> ProgramImage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProgramImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.