Expand description
A Rust library that implements a series of interfaces such as dlopen and dlsym, consistent with the behavior of libc,
providing robust support for dynamic library loading and symbol resolution.
This library serves four purposes:
- Provide a pure Rust alternative to musl ld.so or glibc ld.so.
- Provide loading ELF dynamic libraries support for
#![no_std]targets. - Easily swap out symbols in shared libraries with your own custom symbols at runtime
- Faster than
ld.soin most cases (loading dynamic libraries and getting symbols)
Currently, it supports x86_64, RV64, and AArch64 architectures.
§Examples
fn main(){
let path = "./target/release/libexample.so";
let libexample = ElfLibrary::dlopen(path, OpenFlags::RTLD_LOCAL | OpenFlags::RTLD_LAZY).unwrap();
let add = unsafe {
libexample.get::<fn(i32, i32) -> i32>("add").unwrap()
};
println!("{}", add(1,1));
}Re-exports§
pub use crate::api::dlsym::dlsym_default;pub use crate::api::dlsym::dlsym_next;
Modules§
- api
- c interface
Macros§
Structs§
- ElfLibrary
- Represents a successfully loaded and relocated dynamic library.
- Open
Flags - Flags that control how dynamic libraries are loaded and resolved.
- Symbol
- A typed symbol retrieved from a loaded ELF module.
Enums§
- Error
- Errors that can occur during dynamic library loading or symbol resolution.