Struct Elf

Source
pub struct Elf {
    pub header: Header,
    pub segments: ProgramHeader,
    pub sections: SectionHeader,
    /* private fields */
}
Expand description

ELF file.

Fields§

§header: Header

File header.

§segments: ProgramHeader

Program header (file segment list).

§sections: SectionHeader

Section header (file section list).

Implementations§

Source§

impl Elf

Source

pub fn read_unchecked<R: ElfRead + ElfSeek>( reader: &mut R, page_size: u64, ) -> Result<Self, Error>

Read ELF from reader without validation.

Source

pub fn read<R: ElfRead + ElfSeek>( reader: &mut R, page_size: u64, ) -> Result<Self, Error>

Read ELF from reader with validation.

Page size is used during the validation.

Source

pub fn write<W: ElfWrite + ElfSeek>(self, writer: &mut W) -> Result<(), Error>

Validate and write ELF to writer.

Source

pub fn write_unchecked<W: ElfWrite + ElfSeek>( self, writer: &mut W, ) -> Result<(), Error>

Write ELF to writer without checking.

Source

pub fn check(&self) -> Result<(), Error>

Check consistency of the data.

Validates consistency of sections, segments and their contents.

Source

pub fn read_section_names<F: ElfRead + ElfSeek>( &self, file: &mut F, ) -> Result<Option<StringTable>, Error>

Read string table containing section names.

Source

pub fn read_dynamic_table<F: ElfRead + ElfSeek>( &self, file: &mut F, ) -> Result<Option<DynamicTable>, Error>

Read dynamic table.

Source

pub fn read_dynamic_string_table<F: ElfRead + ElfSeek>( &self, file: &mut F, ) -> Result<Option<StringTable>, Error>

Read dynamic string table.

Source

pub fn read_interpreter<F: ElfRead + ElfSeek>( &self, file: &mut F, ) -> Result<Option<CString>, Error>

Read the interpreter.

Source

pub fn read_section<R: ElfRead + ElfSeek>( &self, name: &CStr, names: &StringTable, file: &mut R, ) -> Result<Option<Vec<u8>>, Error>

Read the contents of the specified by name.

Source

pub fn page_size(&self) -> u64

Get page size specified on creation.

Trait Implementations§

Source§

impl Debug for Elf

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Elf

§

impl RefUnwindSafe for Elf

§

impl Send for Elf

§

impl Sync for Elf

§

impl Unpin for Elf

§

impl UnwindSafe for Elf

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.