Expand description
Support for reading ELF files.
Traits are used to abstract over the difference between 32-bit and 64-bit ELF.
The primary trait for this is FileHeader.
§High level API
ElfFile implements the Object trait for ELF files.
ElfFile is parameterised by FileHeader to allow reading both 32-bit and
64-bit ELF. There are type aliases for these parameters (ElfFile32 and
ElfFile64).
§Low level API
The FileHeader trait can be directly used to parse both elf::FileHeader32
and elf::FileHeader64.
§Example for low level API
use object::elf;
use object::read::elf::{FileHeader, Sym};
use std::error::Error;
use std::fs;
/// Reads a file and displays the name of each symbol.
fn main() -> Result<(), Box<dyn Error>> {
let data = fs::read("path/to/binary")?;
let elf = elf::FileHeader64::<object::Endianness>::parse(&*data)?;
let endian = elf.endian()?;
let sections = elf.sections(endian, &*data)?;
let symbols = sections.symbols(endian, &*data, elf::SHT_SYMTAB)?;
for symbol in symbols.iter() {
let name = symbol.name(endian, symbols.strings())?;
println!("{}", String::from_utf8_lossy(name));
}
Ok(())
}Structs§
- An iterator over the indices in an
AttributesSubsubsection. - A parser for the attributes in an
AttributesSubsubsection. - An ELF attributes section.
- A subsection in an
AttributesSection. - An iterator for the subsections in an
AttributesSection. - A sub-subsection in an
AttributesSubsection. - An iterator for the sub-subsections in an
AttributesSubsection. - A COMDAT section group in an
ElfFile. - An iterator for the COMDAT section groups in an
ElfFile. - An iterator for the sections in a COMDAT section group in an
ElfFile. - An iterator for the dynamic relocations in an
ElfFile. - A partially parsed ELF file.
- A section in an
ElfFile. - An iterator for the sections in an
ElfFile. - An iterator for the relocations for an
ElfSection. - A segment in an
ElfFile. - An iterator for the segments in an
ElfFile. - A symbol in an
ElfFile. - An iterator for the symbols in an
ElfFile. - A symbol table in an
ElfFile. - A GNU symbol hash table in an ELF file.
- A property in a
elf::NT_GNU_PROPERTY_TYPE_0note. - An iterator for the properties in a
elf::NT_GNU_PROPERTY_TYPE_0note. - A SysV symbol hash table in an ELF file.
- A parsed
NoteHeader. - An iterator over the notes in an ELF section or segment.
- A mapping from section index to associated relocation sections.
- An iterator over the relative relocations in an ELF
SHT_RELRsection. - The table of section headers in an ELF file.
- A table of symbol entries in an ELF file.
- An iterator for the auxiliary records for an entry in an ELF
elf::SHT_GNU_VERDEFsection. - An iterator for the entries in an ELF
elf::SHT_GNU_VERDEFsection. - An iterator for the auxiliary records for an entry in an ELF
elf::SHT_GNU_VERNEEDsection. - An iterator for the entries in an ELF
elf::SHT_GNU_VERNEEDsection. - A version definition or requirement.
- A version index.
- A table of version definitions and requirements.
Traits§
- A trait for generic access to
elf::CompressionHeader32andelf::CompressionHeader64. - A trait for generic access to
elf::Dyn32andelf::Dyn64. - A trait for generic access to
elf::FileHeader32andelf::FileHeader64. - A trait for generic access to
elf::NoteHeader32andelf::NoteHeader64. - A trait for generic access to
elf::ProgramHeader32andelf::ProgramHeader64. - A trait for generic access to
elf::Rel32andelf::Rel64. - A trait for generic access to
elf::Rela32andelf::Rela64. - A trait for generic access to
elf::Relr32andelf::Relr64. - A trait for generic access to
elf::SectionHeader32andelf::SectionHeader64. - A trait for generic access to
elf::Sym32andelf::Sym64.
Type Aliases§
- A COMDAT section group in an
ElfFile32. - A COMDAT section group in an
ElfFile64. - An iterator for the COMDAT section groups in an
ElfFile32. - An iterator for the COMDAT section groups in an
ElfFile64. - An iterator for the sections in a COMDAT section group in an
ElfFile32. - An iterator for the sections in a COMDAT section group in an
ElfFile64. - An iterator for the dynamic relocations in an
ElfFile32. - An iterator for the dynamic relocations in an
ElfFile64. - A 32-bit ELF object file.
- A 64-bit ELF object file.
- A section in an
ElfFile32. - A section in an
ElfFile64. - An iterator for the sections in an
ElfFile32. - An iterator for the sections in an
ElfFile64. - An iterator for the relocations for an
ElfSection32. - An iterator for the relocations for an
ElfSection64. - A segment in an
ElfFile32. - A segment in an
ElfFile64. - An iterator for the segments in an
ElfFile32. - An iterator for the segments in an
ElfFile64. - A symbol in an
ElfFile32. - A symbol in an
ElfFile64. - An iterator for the symbols in an
ElfFile32. - An iterator for the symbols in an
ElfFile64. - A symbol table in an
ElfFile32. - A symbol table in an
ElfFile32.