Struct ElfBinary

Source
pub struct ElfBinary<'s> {
    pub file: ElfFile<'s>,
    pub dynamic: Option<DynamicInfo>,
}
Expand description

Abstract representation of a loadable ELF binary.

Fields§

§file: ElfFile<'s>

The ELF file in question.

§dynamic: Option<DynamicInfo>

Parsed information from the .dynamic section (if the binary has it).

Implementations§

Source§

impl<'s> ElfBinary<'s>

Source

pub fn new(region: &'s [u8]) -> Result<ElfBinary<'s>, ElfLoaderErr>

Create a new ElfBinary.

Source

pub fn is_pie(&self) -> bool

Returns true if the binary is compiled as position independent code or false otherwise.

For the binary to be PIE it needs to have a .dynamic section with PIE set in the flags1 field.

Source

pub fn interpreter(&'s self) -> Option<&'s str>

Returns the dynamic loader if present.

readelf -x .interp

For a statically compiled binary this will return None

Source

pub fn get_arch(&self) -> Machine

Returns the target architecture

Source

pub fn entry_point(&self) -> u64

Return the entry point of the ELF file.

Note this may be zero in case of position independent executables.

Source

pub fn program_headers(&self) -> ProgramIter<'_, '_>

Create a slice of the program headers.

Source

pub fn symbol_name(&self, symbol: &'s dyn Entry) -> &'s str

Get the name of the sectione

Source

pub fn for_each_symbol<F: FnMut(&'s dyn Entry)>( &self, func: F, ) -> Result<(), ElfLoaderErr>

Enumerate all the symbols in the file

Source

pub fn load(&self, loader: &mut dyn ElfLoader) -> Result<(), ElfLoaderErr>

Processing the program headers and issue commands to loader.

Will tell loader to create space in the address space / region where the header is supposed to go, then copy it there, and finally relocate it.

Trait Implementations§

Source§

impl<'s> Debug for ElfBinary<'s>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> Freeze for ElfBinary<'s>

§

impl<'s> RefUnwindSafe for ElfBinary<'s>

§

impl<'s> Send for ElfBinary<'s>

§

impl<'s> Sync for ElfBinary<'s>

§

impl<'s> Unpin for ElfBinary<'s>

§

impl<'s> UnwindSafe for ElfBinary<'s>

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> 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, 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.