Struct lief::elf::binary::Binary

pub struct Binary { /* private fields */ }
Expand description

This is the main interface to read and write ELF binary attributes.

Note that this structure implements the generic::Binary trait from which other generic functions are exposed

Implementations§

§

impl Binary

pub fn parse(path: &str) -> Self

Create a Binary from the given file path

pub fn header(&self) -> Header<'_>

Return the main ELF header

pub fn virtual_size(&self) -> u64

Return the size taken by the binary when loaded (virtual size)

pub fn interpreter(&self) -> String

Return the path to the ELF interpreter that is used to process the ELF information once loaded by the kernel

pub fn sysv_hash(&self) -> Option<Sysv<'_>>

Return sysv-hash information (if present)

pub fn gnu_hash(&self) -> Option<Gnu<'_>>

Return GNU Hash info (if present)

pub fn sections(&self) -> Sections<'_>

Return an iterator over the crate::elf::Section of the binary

pub fn segments(&self) -> Segments<'_>

Return an iterator over the crate::elf::Segment of the binary

pub fn dynamic_entries(&self) -> DynamicEntries<'_>

Return an iterator over the crate::elf::DynamicEntries of the binary

pub fn dynamic_symbols(&self) -> DynamicSymbols<'_>

Return an iterator over the dynamic crate::elf::Symbol of the binary

pub fn exported_symbols(&self) -> ExportedSymbols<'_>

Return an iterator over the exported crate::elf::Symbol of the binary

pub fn imported_symbols(&self) -> ImportedSymbols<'_>

Return an iterator over the imported crate::elf::Symbol of the binary

pub fn symtab_symbols(&self) -> SymtabSymbols<'_>

Return an iterator over the symtab-debug crate::elf::Symbol of the binary

pub fn symbols_version(&self) -> SymbolsVersion<'_>

Return an iterator over the crate::elf::SymbolVersion of the binary

pub fn symbols_version_requirement(&self) -> SymbolsVersionRequirement<'_>

Return an iterator over the crate::elf::SymbolVersionRequirement of the binary

pub fn symbols_version_definition(&self) -> SymbolsVersionDefinition<'_>

Return an iterator over the crate::elf::SymbolVersionDefinition of the binary

pub fn notes(&self) -> ItNotes<'_>

Return an iterator over the crate::elf::Notes of the binary

pub fn pltgot_relocations(&self) -> PltGotRelocations<'_>

Return an iterator over the .plt.got crate::elf::Relocation of the binary

pub fn dynamic_relocations(&self) -> DynamicRelocations<'_>

Return an iterator over the regular crate::elf::Relocation of the binary

pub fn object_relocations(&self) -> ObjectRelocations<'_>

Return an iterator over the object-file (.o) crate::elf::Relocation

pub fn relocations(&self) -> Relocations<'_>

Return an iterator over all crate::elf::Relocation of the binary

pub fn section_by_name(&self, name: &str) -> Option<Section<'_>>

Try to find the ELF section with the given name

pub fn relocation_by_addr(&self, address: u64) -> Option<Relocation<'_>>

Try to find the ELF relocation that takes place at the given address

pub fn relocation_for_symbol(&self, sym_name: &str) -> Option<Relocation<'_>>

Try to find the .plt.got relocation for the given symbol name

pub fn dynamic_symbol_by_name(&self, sym_name: &str) -> Option<Symbol<'_>>

Try to find the symbol with the given name in the dynamic .dynsym table

pub fn symtab_symbol_by_name(&self, sym_name: &str) -> Option<Symbol<'_>>

Try to find the symbol with the given name in the debug .symtab table

pub fn get_library(&self, name: &str) -> Option<Library<'_>>

Try to find the library (DT_NEEDED) with the given name

pub fn section_from_offset( &self, offset: u64, skip_nobits: bool ) -> Option<Section<'_>>

Try to find the section that encompasses the given offset. skip_nobits can be used to include (or not) the SHT_NOTBIT sections

pub fn section_from_virtual_address( &self, address: u64, skip_nobits: bool ) -> Option<Section<'_>>

Try to find the section that encompasses the given virtual address. skip_nobits can be used to include (or not) the SHT_NOTBIT sections

pub fn segment_from_virtual_address(&self, address: u64) -> Option<Segment<'_>>

Try to find the segment that encompasses the given virtual address

pub fn segment_from_offset(&self, offset: u64) -> Option<Segment<'_>>

Try to find the segment that encompasses the given offset

pub fn content_from_virtual_address(&self, address: u64, size: u64) -> &[u8]

Get a slice of the content at the given address.

pub fn virtual_address_to_offset(&self, address: u64) -> Result<u64, Error>

Convert the given virtual address into an offset

pub fn get_relocated_dynamic_array(&self, tag: Tag) -> Vec<u64>

Return the array defined by the given tag (e.g. dynamic::Tag::INIT_ARRAY) with relocations applied (if any)

Trait Implementations§

§

impl Binary for Binary

§

fn entrypoint(&self) -> u64

Binary’s entrypoint
§

fn imagebase(&self) -> u64

Default base address where the binary should be mapped
§

fn is_pie(&self) -> bool

Whether the current binary is an executable and position independent
§

fn has_nx(&self) -> bool

Whether the binary defines a non-executable stack
§

fn original_size(&self) -> u64

Original file size of the binary
§

fn debug_info(&self) -> Option<DebugInfo<'_>>

Return the debug info if present. It can be either a crate::pdb::DebugInfo or crate::dwarf::DebugInfo. Read more
§

impl Debug for Binary

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Binary

§

impl !Send for Binary

§

impl !Sync for Binary

§

impl Unpin for Binary

§

impl UnwindSafe for Binary

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.