Struct elf::file::File

source · []
pub struct File<R: ReadBytesAt> {
    pub ehdr: FileHeader,
    /* private fields */
}

Fields

ehdr: FileHeader

Implementations

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.

Get an iterator over the Section Headers in the file.

The underlying ELF bytes backing the section headers 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.

Read and parse the SectionHeader at the given index into the section table.

Get an iterator over the Section Headers and its associated StringTable.

The underlying ELF bytes backing the section headers and string table are read all at once as part of this method. Parsing of section headers and names from the string table are deferred to be done lazily on demand on each Iterator::next() and StringTable.get() 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.

👎Deprecated: Deprecated in favor of File::section_data()

Read the section data for the given SectionHeader.

This returns the data as-is from the file. SHT_NOBITS sections yield an empty slice.

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.

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.

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().

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.

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.

Get the .dynamic section/segment contents.

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.

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.

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.

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.

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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.