Expand description
§Relink (elf_loader)
Relink is a high-performance runtime linker (JIT Linker) tailor-made for the Rust ecosystem. It efficiently parses Various ELF formats, supporting loading from both traditional file systems and direct memory images, and performs flexible dynamic and static hybrid linking.
Whether you are developing OS kernels, embedded systems, JIT compilers, or building plugin-based applications, Relink provides a solid foundation with zero-cost abstractions, high-speed execution, and powerful extensibility.
§Core Features
- 🛡️ Memory Safety: Leverages Rust’s ownership and
Arcto manage library lifetimes and dependencies automatically. - 🔀 Hybrid Linking: Seamlessly mix Relocatable Object files (
.o) and Dynamic Shared Objects (.so). - 🎭 Customization: Deeply intervene in symbol resolution and relocation through
SymbolLookupandRelocationHandler. - ⚡ Performance & Versatility: Optimized for
no_stdenvironments with support for RELR and Lazy Binding.
§Quick Start
use elf_loader::{Loader, input::ElfBinary};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1. Load the library and perform instant linking
let lib = Loader::new().load_dylib(ElfBinary::new("my_lib", &[]))?
.relocator()
.relocate()?; // Complete all relocations
// 2. Safely retrieve and call the function
let awesome_func = unsafe {
lib.get::<fn(i32) -> i32>("awesome_func").ok_or("symbol not found")?
};
let result = awesome_func(42);
Ok(())
}Re-exports§
pub use loader::Loader;
Modules§
- arch
- Architecture-specific definitions and relocation logic.
- elf
- ELF (Executable and Linkable Format) parsing and data structures.
- image
- ELF image management and representation.
- input
- ELF input abstraction and data sources.
- loader
- The core ELF loading orchestration.
- os
- Operating system and environment abstractions.
- relocation
- Symbol relocation and binding logic.
- tls
- Thread Local Storage (TLS) management.
Enums§
- Error
- Error types used throughout the
elf_loaderlibrary. These errors represent various failure conditions that can occur during ELF file loading, parsing, and relocation operations.
Type Aliases§
- Result
- A type alias for
Results returned byelf_loaderfunctions.