pub trait ElfParser<'a>: Sized {
    type ProgramHeader: ElfProgramHeader + 'a;
    type ProgramHeaders: Iterator<Item = &'a Self::ProgramHeader>;
    type SectionHeader: ElfSectionHeader + 'a;
    type SectionHeaders: Iterator<Item = &'a Self::SectionHeader>;
    type Symbol: ElfSymbol + 'a;
    type Symbols: Iterator<Item = Cow<'a, Self::Symbol>>;
    type Relocation: ElfRelocation + 'a;
    type Relocations: Iterator<Item = Cow<'a, Self::Relocation>>;

    // Required methods
    fn parse(data: &'a [u8]) -> Result<Self, ElfError>;
    fn header(&self) -> &Elf64Ehdr;
    fn program_headers(&'a self) -> Self::ProgramHeaders;
    fn section_headers(&'a self) -> Self::SectionHeaders;
    fn section(&self, name: &[u8]) -> Result<Self::SectionHeader, ElfError>;
    fn section_name(&self, sh_name: Elf64Word) -> Option<&[u8]>;
    fn symbols(&'a self) -> Self::Symbols;
    fn symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>;
    fn dynamic_symbol(&self, index: Elf64Word) -> Option<Self::Symbol>;
    fn dynamic_symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>;
    fn dynamic_relocations(&'a self) -> Self::Relocations;
}
Expand description

The common trait implemented by LegacyParser and NewParser.

This is an internal interface used to isolate the ELF parsing bits and to be able to plug the old goblin parser or the new parser depending on config.

The interface is pretty straightforward. The associated types are the types used to represent ELF data. Some return values are Cow<T> since goblin returns some data by value, while the new parser always borrows from the underlying file slice.

Required Associated Types§

source

type ProgramHeader: ElfProgramHeader + 'a

Program header type.

source

type ProgramHeaders: Iterator<Item = &'a Self::ProgramHeader>

Iterator of program headers.

source

type SectionHeader: ElfSectionHeader + 'a

Section header type.

source

type SectionHeaders: Iterator<Item = &'a Self::SectionHeader>

Iterator of section headers

source

type Symbol: ElfSymbol + 'a

Symbol type.

source

type Symbols: Iterator<Item = Cow<'a, Self::Symbol>>

Iterator of symbols.

source

type Relocation: ElfRelocation + 'a

Relocation type.

source

type Relocations: Iterator<Item = Cow<'a, Self::Relocation>>

Iterator of relocations.

Required Methods§

source

fn parse(data: &'a [u8]) -> Result<Self, ElfError>

Parses the ELF data included in the buffer.

source

fn header(&self) -> &Elf64Ehdr

Returns the file header.

source

fn program_headers(&'a self) -> Self::ProgramHeaders

Returns the program headers.

source

fn section_headers(&'a self) -> Self::SectionHeaders

Returns the section headers.

source

fn section(&self, name: &[u8]) -> Result<Self::SectionHeader, ElfError>

Returns the section with the given name.

source

fn section_name(&self, sh_name: Elf64Word) -> Option<&[u8]>

Returns the section name at the given sh_name offset.

source

fn symbols(&'a self) -> Self::Symbols

Returns the symbols included in the symbol table.

source

fn symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>

Returns the symbol name at the given st_name offset.

source

fn dynamic_symbol(&self, index: Elf64Word) -> Option<Self::Symbol>

Returns the symbols included in the dynamic symbol table.

source

fn dynamic_symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>

Returns the dynamic symbol name at the given st_name offset.

source

fn dynamic_relocations(&'a self) -> Self::Relocations

Returns the dynamic relocations.

Object Safety§

This trait is not object safe.

Implementors§