Skip to main content

Crate elf_loader

Crate elf_loader 

Source
Expand description

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 Arc to 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 SymbolLookup and RelocationHandler.
  • ⚡ Performance & Versatility: Optimized for no_std environments 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_loader library. 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 by elf_loader functions.