Trait solana_rbpf::elf_parser_glue::ElfParser
source · 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§
sourcetype ProgramHeader: ElfProgramHeader + 'a
type ProgramHeader: ElfProgramHeader + 'a
Program header type.
sourcetype ProgramHeaders: Iterator<Item = &'a Self::ProgramHeader>
type ProgramHeaders: Iterator<Item = &'a Self::ProgramHeader>
Iterator of program headers.
sourcetype SectionHeader: ElfSectionHeader + 'a
type SectionHeader: ElfSectionHeader + 'a
Section header type.
sourcetype SectionHeaders: Iterator<Item = &'a Self::SectionHeader>
type SectionHeaders: Iterator<Item = &'a Self::SectionHeader>
Iterator of section headers
sourcetype Relocation: ElfRelocation + 'a
type Relocation: ElfRelocation + 'a
Relocation type.
sourcetype Relocations: Iterator<Item = Cow<'a, Self::Relocation>>
type Relocations: Iterator<Item = Cow<'a, Self::Relocation>>
Iterator of relocations.
Required Methods§
sourcefn program_headers(&'a self) -> Self::ProgramHeaders
fn program_headers(&'a self) -> Self::ProgramHeaders
Returns the program headers.
sourcefn section_headers(&'a self) -> Self::SectionHeaders
fn section_headers(&'a self) -> Self::SectionHeaders
Returns the section headers.
sourcefn section(&self, name: &[u8]) -> Result<Self::SectionHeader, ElfError>
fn section(&self, name: &[u8]) -> Result<Self::SectionHeader, ElfError>
Returns the section with the given name
.
sourcefn section_name(&self, sh_name: Elf64Word) -> Option<&[u8]>
fn section_name(&self, sh_name: Elf64Word) -> Option<&[u8]>
Returns the section name at the given sh_name
offset.
sourcefn symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>
fn symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>
Returns the symbol name at the given st_name
offset.
sourcefn dynamic_symbol(&self, index: Elf64Word) -> Option<Self::Symbol>
fn dynamic_symbol(&self, index: Elf64Word) -> Option<Self::Symbol>
Returns the symbols included in the dynamic symbol table.
sourcefn dynamic_symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>
fn dynamic_symbol_name(&self, st_name: Elf64Word) -> Option<&[u8]>
Returns the dynamic symbol name at the given st_name
offset.
sourcefn dynamic_relocations(&'a self) -> Self::Relocations
fn dynamic_relocations(&'a self) -> Self::Relocations
Returns the dynamic relocations.