pub struct File<R: ReadBytesAt> {
pub ehdr: FileHeader,
/* private fields */
}Fields
ehdr: FileHeaderImplementations
sourceimpl<R: ReadBytesAt> File<R>
impl<R: ReadBytesAt> File<R>
pub fn open_stream(reader: R) -> Result<File<R>, ParseError>
sourcepub fn segments(&mut self) -> Result<SegmentTable<'_>, ParseError>
pub fn segments(&mut self) -> Result<SegmentTable<'_>, ParseError>
Get an lazy-parsing table for the Segments (ELF Program Headers) in the file.
The underlying ELF bytes backing the program headers table are read all at once when the table is requested, but parsing is deferred to be lazily parsed on demand on each table.get() call or table.iter().next() call.
Returns a ParseError if the data bytes for the segment table cannot be read i.e. if the ELF FileHeader’s e_phnum, e_phoff, e_phentsize are invalid and point to a range in the file data that does not actually exist.
sourcepub fn section_headers(&mut self) -> Result<SectionHeaderTable<'_>, ParseError>
pub fn section_headers(&mut self) -> Result<SectionHeaderTable<'_>, ParseError>
Get an lazy-parsing table for the Section Headers in the file.
The underlying ELF bytes backing the section headers table are read all at once when the table is requested, but parsing is deferred to be lazily parsed on demand on each table.get() call or table.iter().next() call.
Returns a ParseError if the data bytes for the section table cannot be read i.e. if the ELF FileHeader’s e_shnum, e_shoff, e_shentsize are invalid and point to a range in the file data that does not actually exist.
sourcepub fn section_headers_with_strtab(
&mut self
) -> Result<(SectionHeaderTable<'_>, StringTable<'_>), ParseError>
pub fn section_headers_with_strtab(
&mut self
) -> Result<(SectionHeaderTable<'_>, StringTable<'_>), ParseError>
Get an lazy-parsing table for the Section Headers in the file and its associated StringTable.
The underlying ELF bytes backing the section headers table and string table are read all at once when the table is requested, but parsing is deferred to be lazily parsed on demand on each table.get(), strtab.get(), or table.iter().next() call.
Returns a ParseError if the data bytes for these tables cannot be read i.e. if the ELF FileHeader’s e_shnum, e_shoff, e_shentsize, e_shstrndx are invalid and point to a ranges in the file data that does not actually exist.
sourcepub fn section_data(
&mut self,
shdr: &SectionHeader
) -> Result<(&[u8], Option<CompressionHeader>), ParseError>
pub fn section_data(
&mut self,
shdr: &SectionHeader
) -> Result<(&[u8], Option<CompressionHeader>), ParseError>
Read the section data for the given SectionHeader. Returns both the secion data and an optional CompressionHeader.
No compression header signals that the section contents are uncompressed and can be used as-is.
Some(chdr) signals that the section contents are compressed and need to be uncompressed via the compression algorithm described in ch_type. The returned buffer represents the compressed section bytes as found in the file, without the CompressionHeader.
It is up to the user to perform the decompression themselves with the compression library of their choosing.
SHT_NOBITS sections yield an empty slice.
sourcepub fn section_data_as_strtab(
&mut self,
shdr: &SectionHeader
) -> Result<StringTable<'_>, ParseError>
pub fn section_data_as_strtab(
&mut self,
shdr: &SectionHeader
) -> Result<StringTable<'_>, ParseError>
Read the section data for the given SectionHeader and interpret it in-place as a StringTable.
Returns a ParseError if the sh_type is not SHT_STRTAB.
sourcepub fn symbol_table(
&mut self
) -> Result<Option<(SymbolTable<'_>, StringTable<'_>)>, ParseError>
pub fn symbol_table(
&mut self
) -> Result<Option<(SymbolTable<'_>, StringTable<'_>)>, ParseError>
Get the symbol table (section of type SHT_SYMTAB) and its associated string table.
The GABI specifies that ELF object files may have zero or one sections of type SHT_SYMTAB.
sourcepub fn dynamic_symbol_table(
&mut self
) -> Result<Option<(SymbolTable<'_>, StringTable<'_>)>, ParseError>
pub fn dynamic_symbol_table(
&mut self
) -> Result<Option<(SymbolTable<'_>, StringTable<'_>)>, ParseError>
Get the dynamic symbol table (section of type SHT_DYNSYM) and its associated string table.
The GABI specifies that ELF object files may have zero or one sections of type SHT_DYNSYM.
sourcepub fn dynamic_section(&mut self) -> Result<Option<DynIterator<'_>>, ParseError>
pub fn dynamic_section(&mut self) -> Result<Option<DynIterator<'_>>, ParseError>
Get the .dynamic section/segment contents.
sourcepub fn symbol_version_table(
&mut self
) -> Result<Option<SymbolVersionTable<'_>>, ParseError>
pub fn symbol_version_table(
&mut self
) -> Result<Option<SymbolVersionTable<'_>>, ParseError>
Read the section data for the various GNU Symbol Versioning sections (if any) and return them in a SymbolVersionTable that which can interpret them in-place to yield SymbolRequirements and SymbolDefinitions
This is a GNU extension and not all objects use symbol versioning. Returns an empty Option if the object does not use symbol versioning.
sourcepub fn section_data_as_rels(
&mut self,
shdr: &SectionHeader
) -> Result<RelIterator<'_>, ParseError>
pub fn section_data_as_rels(
&mut self,
shdr: &SectionHeader
) -> Result<RelIterator<'_>, ParseError>
Read the section data for the given SectionHeader and interpret it in-place as a RelIterator.
Returns a ParseError if the sh_type is not SHT_REL.
sourcepub fn section_data_as_relas(
&mut self,
shdr: &SectionHeader
) -> Result<RelaIterator<'_>, ParseError>
pub fn section_data_as_relas(
&mut self,
shdr: &SectionHeader
) -> Result<RelaIterator<'_>, ParseError>
Read the section data for the given SectionHeader and interpret it in-place as a RelaIterator.
Returns a ParseError if the sh_type is not SHT_RELA.
sourcepub fn section_data_as_notes(
&mut self,
shdr: &SectionHeader
) -> Result<NoteIterator<'_>, ParseError>
pub fn section_data_as_notes(
&mut self,
shdr: &SectionHeader
) -> Result<NoteIterator<'_>, ParseError>
Read the section data for the given SectionHeader and interpret it in-place as a NoteIterator.
Returns a ParseError if the sh_type is not SHT_RELA.
sourcepub fn segment_data_as_notes(
&mut self,
phdr: &ProgramHeader
) -> Result<NoteIterator<'_>, ParseError>
pub fn segment_data_as_notes(
&mut self,
phdr: &ProgramHeader
) -> Result<NoteIterator<'_>, ParseError>
Read the segment data for the given Segment and interpret it in-place as a NoteIterator.
Returns a ParseError if the p_type is not PT_RELA.