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§
sourcetype Segment<'file>: ObjectSegment<'data>
where
Self: 'file,
'data: 'file
type Segment<'file>: ObjectSegment<'data> where Self: 'file, 'data: 'file
A loadable segment in the object file.
sourcetype SegmentIterator<'file>: Iterator<Item = Self::Segment<'file>>
where
Self: 'file,
'data: 'file
type SegmentIterator<'file>: Iterator<Item = Self::Segment<'file>> where Self: 'file, 'data: 'file
An iterator for the loadable segments in the object file.
sourcetype Section<'file>: ObjectSection<'data>
where
Self: 'file,
'data: 'file
type Section<'file>: ObjectSection<'data> where Self: 'file, 'data: 'file
A section in the object file.
sourcetype SectionIterator<'file>: Iterator<Item = Self::Section<'file>>
where
Self: 'file,
'data: 'file
type SectionIterator<'file>: Iterator<Item = Self::Section<'file>> where Self: 'file, 'data: 'file
An iterator for the sections in the object file.
sourcetype Comdat<'file>: ObjectComdat<'data>
where
Self: 'file,
'data: 'file
type Comdat<'file>: ObjectComdat<'data> where Self: 'file, 'data: 'file
A COMDAT section group in the object file.
sourcetype ComdatIterator<'file>: Iterator<Item = Self::Comdat<'file>>
where
Self: 'file,
'data: 'file
type ComdatIterator<'file>: Iterator<Item = Self::Comdat<'file>> where Self: 'file, 'data: 'file
An iterator for the COMDAT section groups in the object file.
sourcetype Symbol<'file>: ObjectSymbol<'data>
where
Self: 'file,
'data: 'file
type Symbol<'file>: ObjectSymbol<'data> where Self: 'file, 'data: 'file
A symbol in the object file.
sourcetype SymbolIterator<'file>: Iterator<Item = Self::Symbol<'file>>
where
Self: 'file,
'data: 'file
type SymbolIterator<'file>: Iterator<Item = Self::Symbol<'file>> where Self: 'file, 'data: 'file
An iterator for symbols in the object file.
sourcetype SymbolTable<'file>: ObjectSymbolTable<'data, Symbol = Self::Symbol<'file>, SymbolIterator = Self::SymbolIterator<'file>>
where
Self: 'file,
'data: 'file
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.
sourcetype DynamicRelocationIterator<'file>: Iterator<Item = (u64, Relocation)>
where
Self: 'file,
'data: 'file
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§
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(&self) -> Self::SegmentIterator<'_>
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.
sourcefn section_by_name_bytes<'file>(
&'file self,
section_name: &[u8],
) -> Option<Self::Section<'file>>
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.
sourcefn section_by_index(&self, index: SectionIndex) -> Result<Self::Section<'_>>
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.
sourcefn sections(&self) -> Self::SectionIterator<'_>
fn sections(&self) -> Self::SectionIterator<'_>
Get an iterator for the sections in the file.
sourcefn comdats(&self) -> Self::ComdatIterator<'_>
fn comdats(&self) -> Self::ComdatIterator<'_>
Get an iterator for the COMDAT section groups in the file.
sourcefn symbol_table(&self) -> Option<Self::SymbolTable<'_>>
fn symbol_table(&self) -> Option<Self::SymbolTable<'_>>
Get the debugging symbol table, if any.
sourcefn symbol_by_index(&self, index: SymbolIndex) -> Result<Self::Symbol<'_>>
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.
sourcefn symbols(&self) -> Self::SymbolIterator<'_>
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.
sourcefn dynamic_symbol_table(&self) -> Option<Self::SymbolTable<'_>>
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.
sourcefn dynamic_symbols(&self) -> Self::SymbolIterator<'_>
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.
sourcefn dynamic_relocations(&self) -> Option<Self::DynamicRelocationIterator<'_>>
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.
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 low level API.
sourcefn has_debug_symbols(&self) -> bool
fn has_debug_symbols(&self) -> bool
Return true if the file contains DWARF debug information sections, false if not.
sourcefn relative_address_base(&self) -> u64
fn relative_address_base(&self) -> u64
Get the base address used for relative virtual addresses.
Currently this is only non-zero for PE.
Provided Methods§
sourcefn sub_architecture(&self) -> Option<SubArchitecture>
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.
sourcefn endianness(&self) -> Endianness
fn endianness(&self) -> Endianness
Get the endianness of the file.
sourcefn section_by_name(&self, section_name: &str) -> Option<Self::Section<'_>>
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). Similarly, if “.debug_info” is requested for a Mach-O object file, then “__zdebug_info” may be returned.
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_by_name<'file>(
&'file self,
symbol_name: &str,
) -> Option<Self::Symbol<'file>>
fn symbol_by_name<'file>( &'file self, symbol_name: &str, ) -> Option<Self::Symbol<'file>>
Get the symbol named symbol_name
, if the symbol exists.
sourcefn symbol_by_name_bytes<'file>(
&'file self,
symbol_name: &[u8],
) -> Option<Self::Symbol<'file>>
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.
sourcefn symbol_map(&self) -> SymbolMap<SymbolMapName<'data>>
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.
sourcefn object_map(&self) -> ObjectMap<'data>
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.
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.