Crate elfio[][src]

Expand description

‘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"),



The constants defined by ELF standard and used by ELFIO trait


An array element

A section data accessor intended to array tables. The accessor is useful for manipulation of such sections as .ctors, .dtors, .init_array and .fini_array

A dynamic table element

A section data accessor intended to dynamic tables

Elfio - the main struct of the library. All access to ELF files attributes starts from this object. The object provides functions to access ELF file header attributes as well as the list of segments and sections of this file.

A section data accessor intended to modinfo tables. The accessor is useful for kernel modules data

A note entry. The note is used by compilers and other tools to mark an object file with special information that has special meaning to a particular tool set.

A section data accessor intended to note sections

A relocation entry. The relocation contains information that describes how to modify section contents, thus allowing executable and shared object files to hold the right information for a process’s program image.

A section data accessor intended to relocation tables

A section data accessor intended to string tables

A struct represents a single symbol from symbol table section

A section data accessor intended to symbol tables


Read/Write access to section properties

Read/Write access to segment properties

A trait for reading ELF file payload from a file or memory. Currently, it is implemented for std::fs::File, std::io::BufReader and std::io::Cursor

Type Definitions

Unsigned program address for 32-bit

Unsigned file offset for 32-bit

Unsigned program address for 64-bit

Unsigned file offset for 64-bit

Unsigned medium integer

Signed large integer

Signed long integer

Unsigned large integer

Unsigned long integer