#elf-file #elf #binary-format #bin #reading #file-format #intended

elfio

ELFIO is a Rust library intended for reading and generating files in the ELF binary format

3 releases

0.3.3 Jul 30, 2021
0.3.2 Jul 9, 2021
0.3.1 Jul 5, 2021

#753 in Filesystem

Download history 35/week @ 2024-02-26 1/week @ 2024-03-11 54/week @ 2024-04-01

55 downloads per month

MIT/Apache

98KB
1.5K SLoC

Contains (ELF exe/lib, 70KB) tests/files/hello_ppc64, (ELF exe/lib, 5KB) tests/files/hello_32, (ELF exe/lib, 7KB) tests/files/hello_64, (ELF exe/lib, 7KB) tests/files/hello_ppc, (ELF exe/lib, 14KB) tests/files/i2c-gpio.ko

ELFIO

ELFIO is a Rust library intended for reading and generating files in the ELF binary format. The library supports processing of ELF files for 32- and 64-bit architectures regardless of their endianess

ELFIO is a Rust language port of the corresponding C++ library also called ELFIO

Status

Work in progress. Only ELF file reader is implemented so far. Your contribution is welcomed!

Documentation and Tutorial

Use cargo to produce the library documentation:

cargo doc

Tutorial is available as an example source code. To compile the tutorial use the following cargo command:

cargo test --example tutorial

Licensed under either of these


lib.rs:

'elfio' is a Rust library intended for reading and generation files in the ELF binary format. The library supports processing of ELF files for 32- and 64-bit architectures regardless of their endianess

For example:

use std::fs::File;
use std::io;
use std::io::BufReader;

use elfio::Elfio;

fn main() -> io::Result<()> {
    let elf_file = File::open("tests/files/hello_64")?;
    let mut file_reader = BufReader::new(elf_file);

    let mut elf = elfio::Elfio::new();

    elf.load(&mut file_reader)?;

    match elf.get_type() {
        elfio::constant::ET_REL => println!("Object ELF file"),
        elfio::constant::ET_EXEC => println!("Executable ELF file"),
        elfio::constant::ET_DYN => println!("Shared library ELF file"),
        elfio::constant::ET_CORE => println!("Core ELF file"),
        _ => println!("ELF type is not recognized"),
    }

    Ok(())
}

Dependencies

~160KB