Struct dlopen_rs::ELFLibrary

source ·
pub struct ELFLibrary { /* private fields */ }

Implementations§

source§

impl ELFLibrary

source

pub fn load_self(name: &str) -> Result<RelocatedLibrary>

Load the dynamic library used by the current program itself, you can load it using the name of the library

§Examples
let libc = ELFLibrary::load_self("libc").unwrap();
source§

impl ELFLibrary

source

pub fn relocate( self, internal_libs: &[RelocatedLibrary], ) -> Result<RelocatedLibrary>

use internal dependent libraries to relocate the current library

§Examples
let libc = ELFLibrary::load_self("libc").unwrap();
let libgcc = ELFLibrary::load_self("libgcc").unwrap();
let lib = ELFLibrary::from_file("/path/to/awesome.module")
	.unwrap()
	.relocate(&[libgcc, libc])
	.unwrap();
source

pub fn relocate_with( self, internal_libs: &[RelocatedLibrary], external_libs: Option<Vec<Box<dyn ExternLibrary + 'static>>>, ) -> Result<RelocatedLibrary>

use internal and external dependency libraries to relocate the current library

source§

impl ELFLibrary

source

pub fn from_file<P: AsRef<OsStr>>(path: P) -> Result<ELFLibrary>

Find and load a elf dynamic library from path.

The filename argument may be either:

  • A library filename;
  • The absolute path to the library;
  • A relative (to the current working directory) path to the library.
§Examples
let lib = ELFLibrary::from_file("/path/to/awesome.module")
	.unwrap();
source

pub fn from_binary(bytes: &[u8]) -> Result<ELFLibrary>

load a elf dynamic library from bytes

§Examples
let path = Path::new("/path/to/awesome.module");
let bytes = std::fs::read(path).unwrap();
let lib = ELFLibrary::from_binary(&bytes).unwarp();
source

pub fn needed_libs(&self) -> &Vec<&str>

Trait Implementations§

source§

impl Debug for ELFLibrary

source§

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

Formats the value using the given formatter. 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>,

§

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

§

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.