yggdrasil-elf/README.md
2022-10-10 22:28:41 -07:00

1.0 KiB

Build Status

rust-elf

Pure-Rust library for parsing ELF files

Documentation

Example:

extern crate elf;

fn main() {
    let path: std::path::PathBuf = From::from("some_file");
    let mut io = match std::fs::File::open(path) {
        Ok(f) => f,
        Err(e) => panic!("Error: {:?}", e),
    };

    let elf_file = match elf::File::open_stream(&mut io) {
        Ok(f) => f,
        Err(e) => panic!("Error: {:?}", e),
    };

    println!("ELF: {}", elf_file.ehdr);

    let text_scn = match elf_file.get_section(".text") {
        Some(s) => s,
        None => panic!("Failed to find .text section"),
    };

    println!("{:?}", text_scn.data);
}