Struct ELFParser

Source
pub struct ELFParser<'a> { /* private fields */ }
Expand description

A wrapper for the ELF file data with some useful methods.

Implementations§

Source§

impl<'a> ELFParser<'a>

Source

pub fn new( elf: &'a ElfFile<'_>, interp_base: usize, bias: Option<isize>, uspace_base: usize, ) -> Result<Self, &'static str>

Create a new ELFInfo instance.

§Arguments
  • elf - The ELF file data
  • interp_base - Address of the interpreter if the ELF file is a dynamic executable
  • bias - Bias for the base address of the PIE executable.
  • uspace_base - The lowest address of the user space
§Note

If the ELF file is a dynamic executable, the interp_base should be the address of the interpreter, and the address of the ELF file will be elf.base_addr() + bias.

Source

pub fn entry(&self) -> usize

The entry point of the ELF file.

Source

pub fn phnum(&self) -> usize

The number of program headers in the ELF file.

Source

pub fn phent(&self) -> usize

The size of the program header table entry in the ELF file.

Source

pub fn phdr(&self) -> usize

The offset of the program header table in the ELF file.

Source

pub fn base(&self) -> usize

The base address of the ELF file loaded into the memory.

Source

pub fn elf(&self) -> &ElfFile<'_>

The ref of the ELF file data.

Source

pub fn auxv_vector(&self, pagesz: usize) -> [AuxvEntry; 17]

Part of auxiliary vectors from the ELF file.

§Arguments
  • pagesz - The page size of the system

Details about auxiliary vectors are described in https://articles.manugarg.com/aboutelfauxiliaryvectors.html

Source

pub fn ph_load(&self) -> Vec<ELFPH>

Read all self::ELFPH with LOAD type of the elf file.

Auto Trait Implementations§

§

impl<'a> Freeze for ELFParser<'a>

§

impl<'a> RefUnwindSafe for ELFParser<'a>

§

impl<'a> Send for ELFParser<'a>

§

impl<'a> Sync for ELFParser<'a>

§

impl<'a> Unpin for ELFParser<'a>

§

impl<'a> UnwindSafe for ELFParser<'a>

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.