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<SegmentIterator<'_>, ParseError>
pub fn segments(&mut self) -> Result<SegmentIterator<'_>, ParseError>
Get an iterator over the Segments (ELF Program Headers) in the file
The underlying ELF bytes backing the segment table is read all at once when the iterator is requested, but parsing is deferred to be lazily parsed on demand on each Iterator::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<SectionHeaderIterator<'_>, ParseError>
pub fn section_headers(
&mut self
) -> Result<SectionHeaderIterator<'_>, ParseError>
Get an iterator over the Section Headers in the file.
The underlying ELF bytes backing the segment table are read all at once when the iterator is requested, but parsing is deferred to be lazily parsed on demand on each Iterator::next() call.
Returns a ParseError if the data bytes for the segment 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_header_by_index(
&mut self,
index: usize
) -> Result<SectionHeader, ParseError>
pub fn section_header_by_index(
&mut self,
index: usize
) -> Result<SectionHeader, ParseError>
Read and parse the SectionHeader at the given index into the section table.
sourcepub fn section_data_for_header(
&mut self,
shdr: &SectionHeader
) -> Result<&[u8], ParseError>
pub fn section_data_for_header(
&mut self,
shdr: &SectionHeader
) -> Result<&[u8], ParseError>
Read the section data for the given SectionHeader.
This returns the data as-is from the file. 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 section_strtab(&mut self) -> Result<StringTable<'_>, ParseError>
pub fn section_strtab(&mut self) -> Result<StringTable<'_>, ParseError>
Read and return the string table for the section headers.
If the file has no section header string table, then an empty StringTable is returned.
This is a convenience wrapper for interpreting the section at FileHeader.e_shstrndx as a StringTable via section_data_as_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.