Expand description
The dopen_rs crate supports loading dynamic libraries from memory and files,
supports no_std environments, and does not rely on the dynamic linker ldso
There is currently no support for using backtrace in loaded dynamic library code, and there is no support for debugging loaded dynamic libraries using gdb
§Examples
use dlopen_rs::ELFLibrary;
use std::path::Path;
let path = Path::new("./target/release/libexample.so");
let libc = ELFLibrary::ldso_load("libc.so.6").unwrap();
let libgcc = ELFLibrary::ldso_load("libgcc_s.so.1").unwrap();
let libexample = ELFLibrary::from_file(path)
.unwrap()
.relocate(&[libgcc, libc])
.unwrap();
let f = unsafe {
libexample
.get::<extern "C" fn(i32) -> i32>("c_fun_add_two")
.unwrap()
};
println!("{}", f(2));
let f = unsafe {
libexample
.get::<extern "C" fn()>("c_fun_print_something_else")
.unwrap()
};
f();