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::ET_REL => println!("Object ELF file"),
        elfio::ET_EXEC => println!("Executable ELF file"),
        elfio::ET_DYN => println!("Shared library ELF file"),
        elfio::ET_CORE => println!("Core ELF file"),
        _ => println!("ELF type is not recognized"),
    }

    Ok(())
}

Structs

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 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 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

Constants

ABI version

File class

Data encoding

File identification

File identification

File identification

File identification

Size of e_ident[]

OS/ABI identification

Start of padding bytes

File version

32-bit objects

64-bit objects

Invalid class

The least significant byte occupying the lowest address

The most significant byte occupying the lowest address

Invalid data encoding

Identification value

Identification value

Identification value

Identification value

Core file

Shared object file

Executable file

No file type

Relocatable object file

Current version

Invalid version

Segment’s Unspecified flag

Segment’s Unspecified flag

Segment’s Read flag

Segment’s Write flag

Segment’s Execute flag

The array element specifies dynamic linking information

Values in this inclusive range are reserved for operating system-specific semantics

Values in this inclusive range are reserved for processor-specific semantics

The array element specifies the location and size of a null-terminated path name to invoke as an interpreter

The array element specifies a loadable segment, described by p_filesz and p_memsz

Values in this inclusive range are reserved for operating system-specific semantics

Values in this inclusive range are reserved for processor-specific semantics

The array element specifies the location and size of auxiliary information

The array element is unused; other members’ values are undefined

The array element, if present, specifies the location and size of the program header table itself

This segment type is reserved but has unspecified semantics

The array element specifies the Thread-Local Storage template

The section occupies memory during process execution

The section contains executable machine instructions

This section is a member (perhaps the only one) of a section group

The sh_info field of this section header holds a section header table index

This flag adds special ordering requirements for link editors

All bits included in this mask are reserved for operating system-specific semantics

All bits included in this mask are reserved for processor-specific semantics

The data in the section may be merged to eliminate duplication

This section requires special OS-specific processing

The data elements in the section consist of null-terminated character strings

This section holds Thread-Local Storage

The section contains data that should be writable during process execution

This value specifies absolute values for the corresponding reference

Symbols defined relative to this section are common symbols

Operational system specific high index

Values in this inclusive range are reserved for processor-specific semantics

This value specifies the upper bound of the range of reserved indexes.

Operational system specific low index

Values in this inclusive range are reserved for processor-specific semantics

This value specifies the lower bound of the range of reserved indexes

This value marks an undefined, missing, irrelevant, or otherwise meaningless section reference.

This value specifies the upper bound of the range of reserved indexes.

The section holds information for dynamic linking

These sections hold a symbol table.

This section contains an array of pointers to termination functions

This section defines a section group

The section holds a symbol hash table

Values in this inclusive range are reserved for operating system-specific semantics

Values in this inclusive range are reserved for processor-specific semantics

This value specifies the upper bound of the range of indexes reserved for application programs

This section contains an array of pointers to initialization functions

Values in this inclusive range are reserved for operating system-specific semantics

Values in this inclusive range are reserved for processor-specific semantics

This value specifies the lower bound of the range of indexes reserved for application programs

A section of this type occupies no space in the file but otherwise resembles SHT_PROGBITS

This section holds information that marks the file in some way

This value marks the section header as inactive; it does not have an associated section

This section contains an array of pointers to functions that are invoked before all other initialization functions

The section holds information defined by the program, whose format and meaning are determined solely by the program

The section holds relocation entries without explicit addends

The section holds relocation entries with explicit addends

This section type is reserved but has unspecified semantics

The section holds a string table

These sections hold a symbol table

The section header index of the associated symbol table section

Global symbol, visible to all object files

Environment-specific use

Processor-specific use

Not visible outside the object file

Environment-specific use

Processor-specific use

Global scope, but with lower precedence than global symbols

The symbol labels a common block that has not yet been allocated.

Source file associated with the object file

Function entry point

Environment-specific use

Values in this inclusive range are reserved for processor-specific semantics

Environment-specific use

Values in this inclusive range are reserved for processor-specific semantics

No type specified (e.g., an absolute symbol)

Data object

Symbol is associated with a section

Traits

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