ElfLinker

Struct ElfLinker 

Source
pub struct ElfLinker { /* private fields */ }
Expand description

Loader which links together multiple Elf files.

Can do some rudimentary linking of binaries.

Implementations§

Source§

impl ElfLinker

Source

pub fn new( filename: PathBuf, do_relocations: bool, just_interpreter: bool, ld_paths: Option<Vec<PathBuf>>, ) -> Result<ElfLinker, Error>

Create a new ElfLinker.

It is recommended you use ElfLinkerBuilder to build an ElfLinker.

Source

pub fn loaded(&self) -> &BTreeMap<String, Elf>

Get the ELFs loaded and linked in this loader

Source

pub fn filename(&self) -> &Path

Get the filename of the ELF we’re loading

Source

pub fn load_elf( &mut self, filename: &Path, base_address: u64, ) -> Result<(), Error>

Takes the path to an Elf, and a base address the Elf should be loaded at. Loads the Elf, all it’s dependencies (DT_NEEDED), and then handles the supported relocations.

Source

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

Get the Elf for the primary elf loaded.

Source

pub fn get_interpreter(&self) -> Result<Option<&Elf>, Error>

If the primary Elf we’re loading has an interpreter designated in its dynamic sectino, get the Elf for the interpreter.

Source

pub fn add_user_function(&mut self, address: u64)

Inform the linker of a function at the given address.

This function will be added to calls to function_entries and will be automatically lifted when calling to_program.

Trait Implementations§

Source§

impl Debug for ElfLinker

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Loader for ElfLinker

Source§

fn memory(&self) -> Result<Memory, Error>

Get a model of the memory contained in the binary
Source§

fn function_entries(&self) -> Result<Vec<FunctionEntry>, Error>

Get addresses for known function entries
Source§

fn program_entry(&self) -> u64

The address program execution should begin at
Source§

fn architecture(&self) -> &dyn Architecture

Get the architecture of the binary
Source§

fn as_any(&self) -> &dyn Any

Cast loader to Any
Source§

fn symbols(&self) -> Vec<Symbol>

Get the symbols for this loader
Source§

fn function(&self, address: u64) -> Result<Function, Error>

Lift just one function from the executable
Source§

fn function_extended( &self, address: u64, options: &Options, ) -> Result<Function, Error>

Lift just one function from the executable, while also supplying translator options.
Source§

fn symbols_map(&self) -> HashMap<u64, Symbol>

Get the symbols as a hashmap by address
Source§

fn program(&self) -> Result<Program, Error>

Lift executable into an il::Program. Read more
Source§

fn program_verbose( &self, options: &Options, ) -> Result<(Program, Vec<(FunctionEntry, Error)>), Error>

Lift executable into an il::Program. Read more
Source§

fn program_recursive(&self) -> Result<Program, Error>

Lift executable into an il::Program, while recursively resolving branch targets into functions. Read more
Source§

fn program_recursive_verbose( &self, options: &Options, ) -> Result<(Program, Vec<(FunctionEntry, Error)>), Error>

Lift executable into an il::Program, while recursively resolving branch targets into functions. 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> 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.