Trait object::read::Object

source ·
pub trait Object<'data: 'file, 'file>: Sealed {
    type Segment: ObjectSegment<'data>;
    type SegmentIterator: Iterator<Item = Self::Segment>;
    type Section: ObjectSection<'data>;
    type SectionIterator: Iterator<Item = Self::Section>;
    type Comdat: ObjectComdat<'data>;
    type ComdatIterator: Iterator<Item = Self::Comdat>;
    type Symbol: ObjectSymbol<'data>;
    type SymbolIterator: Iterator<Item = Self::Symbol>;
    type SymbolTable: ObjectSymbolTable<'data, Symbol = Self::Symbol, SymbolIterator = Self::SymbolIterator>;
    type DynamicRelocationIterator: Iterator<Item = (u64, Relocation)>;

Show 30 methods // Required methods fn architecture(&self) -> Architecture; fn is_little_endian(&self) -> bool; fn is_64(&self) -> bool; fn kind(&self) -> ObjectKind; fn segments(&'file self) -> Self::SegmentIterator; fn section_by_name_bytes( &'file self, section_name: &[u8], ) -> Option<Self::Section>; fn section_by_index( &'file self, index: SectionIndex, ) -> Result<Self::Section>; fn sections(&'file self) -> Self::SectionIterator; fn comdats(&'file self) -> Self::ComdatIterator; fn symbol_table(&'file self) -> Option<Self::SymbolTable>; fn symbol_by_index(&'file self, index: SymbolIndex) -> Result<Self::Symbol>; fn symbols(&'file self) -> Self::SymbolIterator; fn dynamic_symbol_table(&'file self) -> Option<Self::SymbolTable>; fn dynamic_symbols(&'file self) -> Self::SymbolIterator; fn dynamic_relocations( &'file self, ) -> Option<Self::DynamicRelocationIterator>; fn imports(&self) -> Result<Vec<Import<'data>>>; fn exports(&self) -> Result<Vec<Export<'data>>>; fn has_debug_symbols(&self) -> bool; fn relative_address_base(&'file self) -> u64; fn entry(&'file self) -> u64; fn flags(&self) -> FileFlags; // Provided methods fn endianness(&self) -> Endianness { ... } fn section_by_name(&'file self, section_name: &str) -> Option<Self::Section> { ... } fn symbol_map(&'file self) -> SymbolMap<SymbolMapName<'data>> { ... } fn object_map(&'file self) -> ObjectMap<'data> { ... } fn mach_uuid(&self) -> Result<Option<[u8; 16]>> { ... } fn build_id(&self) -> Result<Option<&'data [u8]>> { ... } fn gnu_debuglink(&self) -> Result<Option<(&'data [u8], u32)>> { ... } fn gnu_debugaltlink(&self) -> Result<Option<(&'data [u8], &'data [u8])>> { ... } fn pdb_info(&self) -> Result<Option<CodeView<'_>>> { ... }
}
Expand description

An object file.

Required Associated Types§

source

type Segment: ObjectSegment<'data>

A segment in the object file.

source

type SegmentIterator: Iterator<Item = Self::Segment>

An iterator over the segments in the object file.

source

type Section: ObjectSection<'data>

A section in the object file.

source

type SectionIterator: Iterator<Item = Self::Section>

An iterator over the sections in the object file.

source

type Comdat: ObjectComdat<'data>

A COMDAT section group in the object file.

source

type ComdatIterator: Iterator<Item = Self::Comdat>

An iterator over the COMDAT section groups in the object file.

source

type Symbol: ObjectSymbol<'data>

A symbol in the object file.

source

type SymbolIterator: Iterator<Item = Self::Symbol>

An iterator over symbols in the object file.

source

type SymbolTable: ObjectSymbolTable<'data, Symbol = Self::Symbol, SymbolIterator = Self::SymbolIterator>

A symbol table in the object file.

source

type DynamicRelocationIterator: Iterator<Item = (u64, Relocation)>

An iterator over dynamic relocations in the file.

The first field in the item tuple is the address that the relocation applies to.

Required Methods§

source

fn architecture(&self) -> Architecture

Get the architecture type of the file.

source

fn is_little_endian(&self) -> bool

Return true if the file is little endian, false if it is big endian.

source

fn is_64(&self) -> bool

Return true if the file can contain 64-bit addresses.

source

fn kind(&self) -> ObjectKind

Return the kind of this object.

source

fn segments(&'file self) -> Self::SegmentIterator

Get an iterator over the segments in the file.

source

fn section_by_name_bytes( &'file self, section_name: &[u8], ) -> Option<Self::Section>

Like Self::section_by_name, but allows names that are not UTF-8.

source

fn section_by_index(&'file self, index: SectionIndex) -> Result<Self::Section>

Get the section at the given index.

The meaning of the index depends on the object file.

For some object files, this requires iterating through all sections.

Returns an error if the index is invalid.

source

fn sections(&'file self) -> Self::SectionIterator

Get an iterator over the sections in the file.

source

fn comdats(&'file self) -> Self::ComdatIterator

Get an iterator over the COMDAT section groups in the file.

source

fn symbol_table(&'file self) -> Option<Self::SymbolTable>

Get the symbol table, if any.

source

fn symbol_by_index(&'file self, index: SymbolIndex) -> Result<Self::Symbol>

Get the debugging symbol at the given index.

The meaning of the index depends on the object file.

Returns an error if the index is invalid.

source

fn symbols(&'file self) -> Self::SymbolIterator

Get an iterator over the debugging symbols in the file.

This may skip over symbols that are malformed or unsupported.

For Mach-O files, this does not include STAB entries.

source

fn dynamic_symbol_table(&'file self) -> Option<Self::SymbolTable>

Get the dynamic linking symbol table, if any.

Only ELF has a separate dynamic linking symbol table.

source

fn dynamic_symbols(&'file self) -> Self::SymbolIterator

Get an iterator over the dynamic linking symbols in the file.

This may skip over symbols that are malformed or unsupported.

Only ELF has separate dynamic linking symbols. Other file formats will return an empty iterator.

source

fn dynamic_relocations(&'file self) -> Option<Self::DynamicRelocationIterator>

Get the dynamic relocations for this file.

Symbol indices in these relocations refer to the dynamic symbol table.

Only ELF has dynamic relocations.

source

fn imports(&self) -> Result<Vec<Import<'data>>>

Get the imported symbols.

source

fn exports(&self) -> Result<Vec<Export<'data>>>

Get the exported symbols that expose both a name and an address.

Some file formats may provide other kinds of symbols, that can be retrieved using the lower-level API.

source

fn has_debug_symbols(&self) -> bool

Return true if the file contains debug information sections, false if not.

source

fn relative_address_base(&'file self) -> u64

Get the base address used for relative virtual addresses.

Currently this is only non-zero for PE.

source

fn entry(&'file self) -> u64

Get the virtual address of the entry point of the binary

source

fn flags(&self) -> FileFlags

File flags that are specific to each file format.

Provided Methods§

source

fn endianness(&self) -> Endianness

Get the endianness of the file.

source

fn section_by_name(&'file self, section_name: &str) -> Option<Self::Section>

Get the section named section_name, if such a section exists.

If section_name starts with a ‘.’ then it is treated as a system section name, and is compared using the conventions specific to the object file format. This includes:

  • if “.debug_str_offsets” is requested for a Mach-O object file, then the actual section name that is searched for is “__debug_str_offs”.
  • if “.debug_info” is requested for an ELF object file, then “.zdebug_info” may be returned (and similarly for other debug sections).

For some object files, multiple segments may contain sections with the same name. In this case, the first matching section will be used.

This method skips over sections with invalid names.

source

fn symbol_map(&'file self) -> SymbolMap<SymbolMapName<'data>>

Construct a map from addresses to symbol names.

The map will only contain defined text and data symbols. The dynamic symbol table will only be used if there are no debugging symbols.

source

fn object_map(&'file self) -> ObjectMap<'data>

Construct a map from addresses to symbol names and object file names.

This is derived from Mach-O STAB entries.

source

fn mach_uuid(&self) -> Result<Option<[u8; 16]>>

The UUID from a Mach-O LC_UUID load command.

source

fn build_id(&self) -> Result<Option<&'data [u8]>>

The build ID from an ELF NT_GNU_BUILD_ID note.

The filename and CRC from a .gnu_debuglink section.

The filename and build ID from a .gnu_debugaltlink section.

source

fn pdb_info(&self) -> Result<Option<CodeView<'_>>>

The filename and GUID from the PE CodeView section

Implementors§

source§

impl<'data, 'file, Elf, R> Object<'data, 'file> for ElfFile<'data, Elf, R>
where Elf: FileHeader, R: 'file + ReadRef<'data>, 'data: 'file,

§

type Segment = ElfSegment<'data, 'file, Elf, R>

§

type SegmentIterator = ElfSegmentIterator<'data, 'file, Elf, R>

§

type Section = ElfSection<'data, 'file, Elf, R>

§

type SectionIterator = ElfSectionIterator<'data, 'file, Elf, R>

§

type Comdat = ElfComdat<'data, 'file, Elf, R>

§

type ComdatIterator = ElfComdatIterator<'data, 'file, Elf, R>

§

type Symbol = ElfSymbol<'data, 'file, Elf, R>

§

type SymbolIterator = ElfSymbolIterator<'data, 'file, Elf, R>

§

type SymbolTable = ElfSymbolTable<'data, 'file, Elf, R>

§

type DynamicRelocationIterator = ElfDynamicRelocationIterator<'data, 'file, Elf, R>

source§

impl<'data, 'file, Mach, R> Object<'data, 'file> for MachOFile<'data, Mach, R>
where Mach: MachHeader, R: 'file + ReadRef<'data>, 'data: 'file,

§

type Segment = MachOSegment<'data, 'file, Mach, R>

§

type SegmentIterator = MachOSegmentIterator<'data, 'file, Mach, R>

§

type Section = MachOSection<'data, 'file, Mach, R>

§

type SectionIterator = MachOSectionIterator<'data, 'file, Mach, R>

§

type Comdat = MachOComdat<'data, 'file, Mach, R>

§

type ComdatIterator = MachOComdatIterator<'data, 'file, Mach, R>

§

type Symbol = MachOSymbol<'data, 'file, Mach, R>

§

type SymbolIterator = MachOSymbolIterator<'data, 'file, Mach, R>

§

type SymbolTable = MachOSymbolTable<'data, 'file, Mach, R>

§

type DynamicRelocationIterator = NoDynamicRelocationIterator

source§

impl<'data, 'file, Pe, R> Object<'data, 'file> for PeFile<'data, Pe, R>
where Pe: ImageNtHeaders, R: 'file + ReadRef<'data>, 'data: 'file,

§

type Segment = PeSegment<'data, 'file, Pe, R>

§

type SegmentIterator = PeSegmentIterator<'data, 'file, Pe, R>

§

type Section = PeSection<'data, 'file, Pe, R>

§

type SectionIterator = PeSectionIterator<'data, 'file, Pe, R>

§

type Comdat = PeComdat<'data, 'file, Pe, R>

§

type ComdatIterator = PeComdatIterator<'data, 'file, Pe, R>

§

type Symbol = CoffSymbol<'data, 'file, R>

§

type SymbolIterator = CoffSymbolIterator<'data, 'file, R>

§

type SymbolTable = CoffSymbolTable<'data, 'file, R>

§

type DynamicRelocationIterator = NoDynamicRelocationIterator

source§

impl<'data, 'file, R> Object<'data, 'file> for File<'data, R>
where R: 'file + ReadRef<'data>, 'data: 'file,

§

type Segment = Segment<'data, 'file, R>

§

type SegmentIterator = SegmentIterator<'data, 'file, R>

§

type Section = Section<'data, 'file, R>

§

type SectionIterator = SectionIterator<'data, 'file, R>

§

type Comdat = Comdat<'data, 'file, R>

§

type ComdatIterator = ComdatIterator<'data, 'file, R>

§

type Symbol = Symbol<'data, 'file, R>

§

type SymbolIterator = SymbolIterator<'data, 'file, R>

§

type SymbolTable = SymbolTable<'data, 'file, R>

§

type DynamicRelocationIterator = DynamicRelocationIterator<'data, 'file, R>

source§

impl<'data, 'file, R, Coff> Object<'data, 'file> for CoffFile<'data, R, Coff>
where R: 'file + ReadRef<'data>, Coff: CoffHeader, 'data: 'file,

§

type Segment = CoffSegment<'data, 'file, R, Coff>

§

type SegmentIterator = CoffSegmentIterator<'data, 'file, R, Coff>

§

type Section = CoffSection<'data, 'file, R, Coff>

§

type SectionIterator = CoffSectionIterator<'data, 'file, R, Coff>

§

type Comdat = CoffComdat<'data, 'file, R, Coff>

§

type ComdatIterator = CoffComdatIterator<'data, 'file, R, Coff>

§

type Symbol = CoffSymbol<'data, 'file, R, Coff>

§

type SymbolIterator = CoffSymbolIterator<'data, 'file, R, Coff>

§

type SymbolTable = CoffSymbolTable<'data, 'file, R, Coff>

§

type DynamicRelocationIterator = NoDynamicRelocationIterator