1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! # 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 `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
//!
//! ```rust,no_run
//! 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(())
//! }
//! ```
extern crate alloc;
/// Compile-time check for supported architectures
compile_error!;
pub use *;
pub use Error;
pub use Loader;
/// A type alias for `Result`s returned by `elf_loader` functions.
///
/// This is a convenience alias that eliminates the need to repeatedly specify
/// the `Error` type in function signatures.
pub type Result<T> = Result;