elf_loader 0.16.0

A no_std-friendly ELF loader and runtime linker for Rust.
Documentation
#[path = "common/mod.rs"]
mod fixture_support;

use elf_loader::{Loader, Relocator};
use std::{fs::File, io::Read};

const LOADER: Loader = Loader::new();

fn main() {
    unsafe { std::env::set_var("RUST_LOG", "trace") };
    env_logger::init();
    let fixtures = fixture_support::ensure_all();
    let mut file = File::open(&fixtures.liba).unwrap();
    let mut bytes = Vec::new();
    file.read_to_end(&mut bytes).unwrap();
    let a = Relocator::new()
        .run(LOADER.load_dylib(&bytes).unwrap())
        .relocate()
        .unwrap();
    let f = unsafe { a.get::<fn() -> i32>("a").unwrap() };
    println!("{}", f());
}