Trait object::read::Object

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

Show 33 methods // Required methods fn architecture(&self) -> Architecture; fn is_little_endian(&self) -> bool; fn is_64(&self) -> bool; fn kind(&self) -> ObjectKind; fn segments(&self) -> Self::SegmentIterator<'_>; fn section_by_name_bytes<'file>( &'file self, section_name: &[u8] ) -> Option<Self::Section<'file>>; fn section_by_index(&self, index: SectionIndex) -> Result<Self::Section<'_>>; fn sections(&self) -> Self::SectionIterator<'_>; fn comdats(&self) -> Self::ComdatIterator<'_>; fn symbol_table(&self) -> Option<Self::SymbolTable<'_>>; fn symbol_by_index(&self, index: SymbolIndex) -> Result<Self::Symbol<'_>>; fn symbols(&self) -> Self::SymbolIterator<'_>; fn dynamic_symbol_table(&self) -> Option<Self::SymbolTable<'_>>; fn dynamic_symbols(&self) -> Self::SymbolIterator<'_>; fn dynamic_relocations(&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(&self) -> u64; fn entry(&self) -> u64; fn flags(&self) -> FileFlags; // Provided methods fn sub_architecture(&self) -> Option<SubArchitecture> { ... } fn endianness(&self) -> Endianness { ... } fn section_by_name(&self, section_name: &str) -> Option<Self::Section<'_>> { ... } fn symbol_by_name<'file>( &'file self, symbol_name: &str ) -> Option<Self::Symbol<'file>> { ... } fn symbol_by_name_bytes<'file>( &'file self, symbol_name: &[u8] ) -> Option<Self::Symbol<'file>> { ... } fn symbol_map(&self) -> SymbolMap<SymbolMapName<'data>> { ... } fn object_map(&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.

This is the primary trait for the unified read API.

Required Associated Types§

source

type Segment<'file>: ObjectSegment<'data> where Self: 'file, 'data: 'file

A loadable segment in the object file.

source

type SegmentIterator<'file>: Iterator<Item = Self::Segment<'file>> where Self: 'file, 'data: 'file

An iterator for the loadable segments in the object file.

source

type Section<'file>: ObjectSection<'data> where Self: 'file, 'data: 'file

A section in the object file.

source

type SectionIterator<'file>: Iterator<Item = Self::Section<'file>> where Self: 'file, 'data: 'file

An iterator for the sections in the object file.

source

type Comdat<'file>: ObjectComdat<'data> where Self: 'file, 'data: 'file

A COMDAT section group in the object file.

source

type ComdatIterator<'file>: Iterator<Item = Self::Comdat<'file>> where Self: 'file, 'data: 'file

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

source

type Symbol<'file>: ObjectSymbol<'data> where Self: 'file, 'data: 'file

A symbol in the object file.

source

type SymbolIterator<'file>: Iterator<Item = Self::Symbol<'file>> where Self: 'file, 'data: 'file

An iterator for symbols in the object file.

source

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

A symbol table in the object file.

source

type DynamicRelocationIterator<'file>: Iterator<Item = (u64, Relocation)> where Self: 'file, 'data: 'file

An iterator for the 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(&self) -> Self::SegmentIterator<'_>

Get an iterator for the loadable segments in the file.

For ELF, this is program headers with type PT_LOAD. For Mach-O, this is load commands with type LC_SEGMENT or LC_SEGMENT_64. For PE, this is all sections.

source

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

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

source

fn section_by_index(&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(&self) -> Self::SectionIterator<'_>

Get an iterator for the sections in the file.

source

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

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

source

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

Get the debugging symbol table, if any.

source

fn symbol_by_index(&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(&self) -> Self::SymbolIterator<'_>

Get an iterator for 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(&self) -> Option<Self::SymbolTable<'_>>

Get the dynamic linking symbol table, if any.

Only ELF has a separate dynamic linking symbol table. Consider using Self::exports or Self::imports instead.

source

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

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

This may skip over symbols that are malformed or unsupported.

Only ELF has dynamic linking symbols. Other file formats will return an empty iterator. Consider using Self::exports or Self::imports instead.

source

fn dynamic_relocations(&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 low level API.

source

fn has_debug_symbols(&self) -> bool

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

source

fn relative_address_base(&self) -> u64

Get the base address used for relative virtual addresses.

Currently this is only non-zero for PE.

source

fn entry(&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 sub_architecture(&self) -> Option<SubArchitecture>

Get the sub-architecture type of the file if known.

A value of None has a range of meanings: the file supports all sub-architectures, the file does not explicitly specify a sub-architecture, or the sub-architecture is currently unrecognized.

source

fn endianness(&self) -> Endianness

Get the endianness of the file.

source

fn section_by_name(&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_by_name<'file>( &'file self, symbol_name: &str ) -> Option<Self::Symbol<'file>>

Get the symbol named symbol_name, if the symbol exists.

source

fn symbol_by_name_bytes<'file>( &'file self, symbol_name: &[u8] ) -> Option<Self::Symbol<'file>>

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

source

fn symbol_map(&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(&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.

Object Safety§

This trait is not object safe.

Implementors§

source§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

source§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type DynamicRelocationIterator<'file> = NoDynamicRelocationIterator where Self: 'file, 'data: 'file

source§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Symbol<'file> = CoffSymbol<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SymbolIterator<'file> = CoffSymbolIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SymbolTable<'file> = CoffSymbolTable<'data, 'file, R> where Self: 'file, 'data: 'file

§

type DynamicRelocationIterator<'file> = NoDynamicRelocationIterator where Self: 'file, 'data: 'file

source§

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

§

type Segment<'file> = Segment<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SegmentIterator<'file> = SegmentIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type Section<'file> = Section<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SectionIterator<'file> = SectionIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type Comdat<'file> = Comdat<'data, 'file, R> where Self: 'file, 'data: 'file

§

type ComdatIterator<'file> = ComdatIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type Symbol<'file> = Symbol<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SymbolIterator<'file> = SymbolIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SymbolTable<'file> = SymbolTable<'data, 'file, R> where Self: 'file, 'data: 'file

§

type DynamicRelocationIterator<'file> = DynamicRelocationIterator<'data, 'file, R> where Self: 'file, 'data: 'file

source§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type DynamicRelocationIterator<'file> = NoDynamicRelocationIterator where Self: 'file, 'data: 'file

source§

impl<'data, R: ReadRef<'data>> Object<'data> for WasmFile<'data, R>

§

type Segment<'file> = WasmSegment<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SegmentIterator<'file> = WasmSegmentIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type Section<'file> = WasmSection<'data, 'file, R> where Self: 'file, 'data: 'file

§

type SectionIterator<'file> = WasmSectionIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type Comdat<'file> = WasmComdat<'data, 'file, R> where Self: 'file, 'data: 'file

§

type ComdatIterator<'file> = WasmComdatIterator<'data, 'file, R> where Self: 'file, 'data: 'file

§

type Symbol<'file> = WasmSymbol<'data, 'file> where Self: 'file, 'data: 'file

§

type SymbolIterator<'file> = WasmSymbolIterator<'data, 'file> where Self: 'file, 'data: 'file

§

type SymbolTable<'file> = WasmSymbolTable<'data, 'file> where Self: 'file, 'data: 'file

§

type DynamicRelocationIterator<'file> = NoDynamicRelocationIterator where Self: 'file, 'data: 'file

source§

impl<'data, Xcoff, R> Object<'data> for XcoffFile<'data, Xcoff, R>
where Xcoff: FileHeader, R: ReadRef<'data>,

§

type Segment<'file> = XcoffSegment<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type SegmentIterator<'file> = XcoffSegmentIterator<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type Section<'file> = XcoffSection<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type SectionIterator<'file> = XcoffSectionIterator<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type Comdat<'file> = XcoffComdat<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type ComdatIterator<'file> = XcoffComdatIterator<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type Symbol<'file> = XcoffSymbol<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type SymbolIterator<'file> = XcoffSymbolIterator<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type SymbolTable<'file> = XcoffSymbolTable<'data, 'file, Xcoff, R> where Self: 'file, 'data: 'file

§

type DynamicRelocationIterator<'file> = NoDynamicRelocationIterator where Self: 'file, 'data: 'file