Expand description
A pure-rust library designed for loading ELF dynamic libraries from memory or from files.
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)
Additional, it integrates seamlessly with the system’s dynamic linker in std environments when the ldso feature is enabled.
Currently, it supports x86_64, 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, None)
.unwrap()
.relocate(&[libgcc, libc])
.finish()
.unwrap();
let add = unsafe {
libexample
.get::<fn(i32, i32) -> i32>("add")
.unwrap()
};
println!("{}", add(1,1));Structs§
- An unrelocated dynamic library
- A dynamic library that has been relocated
- A symbol from dynamic library
Enums§
- dlopen-rs error type