Crate dlopen_rs

source ·
Expand description

The elf crate provides a pure-safe-rust interface for reading ELF object files. 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::load_self("libc").unwrap();
let libgcc = ELFLibrary::load_self("libgcc").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();

Structs§

Enums§

Traits§

Type Aliases§