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§
sourcetype Segment: ObjectSegment<'data>
type Segment: ObjectSegment<'data>
A segment in the object file.
sourcetype SegmentIterator: Iterator<Item = Self::Segment>
type SegmentIterator: Iterator<Item = Self::Segment>
An iterator over the segments in the object file.
sourcetype Section: ObjectSection<'data>
type Section: ObjectSection<'data>
A section in the object file.
sourcetype SectionIterator: Iterator<Item = Self::Section>
type SectionIterator: Iterator<Item = Self::Section>
An iterator over the sections in the object file.
sourcetype Comdat: ObjectComdat<'data>
type Comdat: ObjectComdat<'data>
A COMDAT section group in the object file.
sourcetype ComdatIterator: Iterator<Item = Self::Comdat>
type ComdatIterator: Iterator<Item = Self::Comdat>
An iterator over the COMDAT section groups in the object file.
sourcetype Symbol: ObjectSymbol<'data>
type Symbol: ObjectSymbol<'data>
A symbol in the object file.
sourcetype SymbolIterator: Iterator<Item = Self::Symbol>
type SymbolIterator: Iterator<Item = Self::Symbol>
An iterator over symbols in the object file.
sourcetype SymbolTable: ObjectSymbolTable<'data, Symbol = Self::Symbol, SymbolIterator = Self::SymbolIterator>
type SymbolTable: ObjectSymbolTable<'data, Symbol = Self::Symbol, SymbolIterator = Self::SymbolIterator>
A symbol table in the object file.
sourcetype DynamicRelocationIterator: Iterator<Item = (u64, Relocation)>
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§
sourcefn architecture(&self) -> Architecture
fn architecture(&self) -> Architecture
Get the architecture type of the file.
sourcefn is_little_endian(&self) -> bool
fn is_little_endian(&self) -> bool
Return true if the file is little endian, false if it is big endian.
sourcefn kind(&self) -> ObjectKind
fn kind(&self) -> ObjectKind
Return the kind of this object.
sourcefn segments(&'file self) -> Self::SegmentIterator
fn segments(&'file self) -> Self::SegmentIterator
Get an iterator over the segments in the file.
sourcefn section_by_name_bytes(
&'file self,
section_name: &[u8],
) -> Option<Self::Section>
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.
sourcefn section_by_index(&'file self, index: SectionIndex) -> Result<Self::Section>
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.
sourcefn sections(&'file self) -> Self::SectionIterator
fn sections(&'file self) -> Self::SectionIterator
Get an iterator over the sections in the file.
sourcefn comdats(&'file self) -> Self::ComdatIterator
fn comdats(&'file self) -> Self::ComdatIterator
Get an iterator over the COMDAT section groups in the file.
sourcefn symbol_table(&'file self) -> Option<Self::SymbolTable>
fn symbol_table(&'file self) -> Option<Self::SymbolTable>
Get the symbol table, if any.
sourcefn symbol_by_index(&'file self, index: SymbolIndex) -> Result<Self::Symbol>
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.
sourcefn symbols(&'file self) -> Self::SymbolIterator
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.
sourcefn dynamic_symbol_table(&'file self) -> Option<Self::SymbolTable>
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.
sourcefn dynamic_symbols(&'file self) -> Self::SymbolIterator
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.
sourcefn dynamic_relocations(&'file self) -> Option<Self::DynamicRelocationIterator>
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.
sourcefn exports(&self) -> Result<Vec<Export<'data>>>
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.
sourcefn has_debug_symbols(&self) -> bool
fn has_debug_symbols(&self) -> bool
Return true if the file contains debug information sections, false if not.
sourcefn relative_address_base(&'file self) -> u64
fn relative_address_base(&'file self) -> u64
Get the base address used for relative virtual addresses.
Currently this is only non-zero for PE.
Provided Methods§
sourcefn endianness(&self) -> Endianness
fn endianness(&self) -> Endianness
Get the endianness of the file.
sourcefn section_by_name(&'file self, section_name: &str) -> Option<Self::Section>
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.
sourcefn symbol_map(&'file self) -> SymbolMap<SymbolMapName<'data>>
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.
sourcefn object_map(&'file self) -> ObjectMap<'data>
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.
sourcefn build_id(&self) -> Result<Option<&'data [u8]>>
fn build_id(&self) -> Result<Option<&'data [u8]>>
The build ID from an ELF NT_GNU_BUILD_ID
note.
sourcefn gnu_debuglink(&self) -> Result<Option<(&'data [u8], u32)>>
fn gnu_debuglink(&self) -> Result<Option<(&'data [u8], u32)>>
The filename and CRC from a .gnu_debuglink
section.