Relink: High-Performance Runtime Linking
π Why Relink?
Relink is a high-performance runtime linker (JIT Linker) tailor-made for the Rust ecosystem. It efficiently parses various ELF formatsβnot only from traditional file systems but also directly from 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.
π₯ Key Features
π‘οΈ Memory Safety
Leveraging Rust's ownership system and smart pointers, Relink ensures safety at runtime.
- Lifetime Binding: Symbols retrieved from a library carry lifetime markers. The compiler ensures they do not outlive the library itself, erasing
use-after-freerisks. - Automatic Dependency Management: Uses
Arcto automatically maintain dependency trees between libraries, preventing a required library from being dropped prematurely.
// π‘οΈ The compiler protects you:
let sym = unsafe ;
drop; // If the library is dropped here...
// sym(); // β Compilation Error! The symbol's lifetime ends with the library.
π Hybrid Linking Capability
Relink supports mixing Relocatable Object files (.o) and Dynamic Shared Objects (.so). You can load a .o file just like a dynamic library and link its undefined symbols to the system or other loaded libraries at runtime.
π Deep Customization & Interception
By implementing the SymbolLookup and RelocationHandler traits, users can deeply intervene in the linking process.
- Symbol Interception: Intercept and replace external dependency symbols during loading. Perfect for function mocking, behavioral monitoring, or hot-patching.
- Custom Linking Logic: Take full control over symbol resolution strategies to build highly flexible plugin systems.
β‘ Extreme Performance & Versatility
- Zero-Cost Abstractions: Built with Rust to provide near-native loading and symbol resolution speeds.
no_stdSupport: The core library has no OS dependencies, making it ideal for OS kernels, embedded devices, and bare-metal development.- Modern Features: Supports RELR for modern ELF optimization; supports Lazy Binding to improve cold-start times for large dynamic libraries.
π― Use Cases
| Scenario | The Relink Advantage |
|---|---|
| Plugin Architectures | Enables safer, finer-grained dynamic module loading than dlopen, supporting .o files as direct plugins. |
| JIT Compilers & Runtimes | Instantly link compiled machine code fragments without manual memory offset management. |
| OS/Kernel Development | Provides a high-quality loader prototype for user-space programs or dynamic kernel module loading. |
| Game Engine Hot-Reloading | Dynamically swap game logic modules for a "code-change-to-live-effect" development experience. |
| Embedded & Edge Computing | Securely update firmware modules or combine features dynamically on resource-constrained devices. |
| Security Research | Use the Hook mechanism to non-invasively analyze binary behavior and interactions. |
π Getting Started
Add to your project
[]
= "0.14"
Basic Example: Load and Call a Dynamic Library
use Loader;
// A host function that can be called by the plugin
extern "C"
π Platform Support
Relink is committed to broad cross-platform support.
| Architecture | Dynamic Linking | Lazy Binding | Hybrid Linking (.o) |
|---|---|---|---|
| x86_64 | β | β | β |
| x86 | β | β | πΆ |
| AArch64 | β | β | πΆ |
| Arm | β | β | πΆ |
| RISC-V 64/32 | β | β | πΆ |
| LoongArch64 | β | β | πΆ |
π€ Contributing
If you are interested in low-level systems, binary security, or linker internals, weβd love to have you!
- Open an Issue: Report bugs or propose your next big idea.
- Star the Project: Show your support for the developers! β
- Code Contributions: PRs are always welcomeβhelp us build the ultimate Rust runtime linker.
π License
This project is dual-licensed under:
Choose the one that best suits your needs.
π Contributors
Relink β Empowering your projects with high-performance runtime linking. π