Crate dlopen_rs

source ·
Expand description

dlopen-rs supports loading dynamic libraries from both memory and files, and is compatible with the no_std environment. This gives you greater flexibility in loading and managing dynamic libraries, offering a viable option for using them in no_std contexts. Additionally, it integrates seamlessly with the system’s dynamic linker in std environments. Currently, it supports x86_64, x86, RV64, and AArch64 architectures.

§Examples

use dlopen_rs::ELFLibrary;
use std::path::Path;
let path = Path::new("./target/release/libexample.so");
   let libc = ELFLibrary::sys_load("libc.so.6").unwrap();
   let libgcc = ELFLibrary::sys_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));

Structs§

Enums§

Traits§

Type Aliases§