Search

Lib.rs

› Filesystem | Parser implementations | Embedded development
#elf-file #bin #elf

elfio

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

by Serge Lamikhov-Center

  • Audit
  • Install
  • API reference
  • GitHub repo (serge1)

3 releases

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

#1797 in Filesystem

22 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' 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(())
}

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

  • MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)

  • Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)

Dependencies

~140KB

  • num-traits
  • paste
See also: lddtree, xmas-elf, elf, risc0-build, elfcat, dump_syms, elf_loader, kernel-elf-parser, elf2tab, binstalk-bins, pelite

Lib.rs is an unofficial list of Rust/Cargo crates, created by kornelski. It contains data from multiple sources, including heuristics, and manually curated data. Content of this page is not necessarily endorsed by the authors of the crate. This site is not affiliated with nor endorsed by the Rust Project. If something is missing or incorrect, please file a bug.