Skip to main content

ObjFile

Enum ObjFile 

#[non_exhaustive]
pub enum ObjFile<'data, R = &'data [u8]>
where R: ReadRef<'data>,
{ Coff(CoffFile<'data, R>), CoffBig(CoffFile<'data, R, AnonObjectHeaderBigobj>), Elf32(ElfFile<'data, FileHeader32<Endianness>, R>), Elf64(ElfFile<'data, FileHeader64<Endianness>, R>), MachO32(MachOFile<'data, MachHeader32<Endianness>, R>), MachO64(MachOFile<'data, MachHeader64<Endianness>, R>), Pe32(PeFile<'data, ImageNtHeaders32, R>), Pe64(PeFile<'data, ImageNtHeaders64, R>), Wasm(WasmFile<'data, R>), Xcoff32(XcoffFile<'data, FileHeader32, R>), Xcoff64(XcoffFile<'data, FileHeader64, R>), }
Expand description

An object file that can be any supported file format.

Most functionality is provided by the [Object] trait implementation.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Coff(CoffFile<'data, R>)

§

CoffBig(CoffFile<'data, R, AnonObjectHeaderBigobj>)

§

Elf32(ElfFile<'data, FileHeader32<Endianness>, R>)

§

Elf64(ElfFile<'data, FileHeader64<Endianness>, R>)

§

MachO32(MachOFile<'data, MachHeader32<Endianness>, R>)

§

MachO64(MachOFile<'data, MachHeader64<Endianness>, R>)

§

Pe32(PeFile<'data, ImageNtHeaders32, R>)

§

Pe64(PeFile<'data, ImageNtHeaders64, R>)

§

Wasm(WasmFile<'data, R>)

§

Xcoff32(XcoffFile<'data, FileHeader32, R>)

§

Xcoff64(XcoffFile<'data, FileHeader64, R>)

Implementations§

§

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

pub fn parse(data: R) -> Result<File<'data, R>, Error>

Parse the raw file data.

pub fn parse_dyld_cache_image<'cache, E>( image: &DyldCacheImage<'data, 'cache, E, R>, ) -> Result<File<'data, R>, Error>
where E: Endian,

Parse a Mach-O image from the dyld shared cache.

pub fn format(&self) -> BinaryFormat

Return the file format.

Trait Implementations§

§

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

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

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

§

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

A loadable segment in the object file.
§

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

An iterator for the loadable segments in the object file.
§

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

A section in the object file.
§

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

An iterator for the sections in the object file.
§

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

A COMDAT section group in the object file.
§

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

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

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

A symbol in the object file.
§

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

An iterator for symbols in the object file.
§

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

A symbol table in the object file.
§

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

An iterator for the dynamic relocations in the file. Read more
§

fn architecture(&self) -> Architecture

Get the architecture type of the file.
§

fn sub_architecture(&self) -> Option<SubArchitecture>

Get the sub-architecture type of the file if known. Read more
§

fn is_little_endian(&self) -> bool

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

fn is_64(&self) -> bool

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

fn kind(&self) -> ObjectKind

Return the kind of this object.
§

fn segments(&self) -> SegmentIterator<'data, '_, R> ⓘ

Get an iterator for the loadable segments in the file. Read more
§

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

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

fn section_by_index( &self, index: SectionIndex, ) -> Result<Section<'data, '_, R>, Error>

Get the section at the given index. Read more
§

fn sections(&self) -> SectionIterator<'data, '_, R> ⓘ

Get an iterator for the sections in the file.
§

fn comdats(&self) -> ComdatIterator<'data, '_, R> ⓘ

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

fn symbol_by_index( &self, index: SymbolIndex, ) -> Result<Symbol<'data, '_, R>, Error>

Get the debugging symbol at the given index. Read more
§

fn symbols(&self) -> SymbolIterator<'data, '_, R> ⓘ

Get an iterator for the debugging symbols in the file. Read more
§

fn symbol_table(&self) -> Option<SymbolTable<'data, '_, R>>

Get the debugging symbol table, if any.
§

fn dynamic_symbols(&self) -> SymbolIterator<'data, '_, R> ⓘ

Get an iterator for the dynamic linking symbols in the file. Read more
§

fn dynamic_symbol_table(&self) -> Option<SymbolTable<'data, '_, R>>

Get the dynamic linking symbol table, if any. Read more
§

fn dynamic_relocations(&self) -> Option<DynamicRelocationIterator<'data, '_, R>>

Get the dynamic relocations for this file. Read more
§

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

Construct a map from addresses to symbol names. Read more
§

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

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

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

Get the imported symbols.
§

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

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

fn has_debug_symbols(&self) -> bool

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

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

The UUID from a Mach-O LC_UUID load command.
§

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

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.
§

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

The filename and GUID from the PE CodeView section.
§

fn relative_address_base(&self) -> u64

Get the base address used for relative virtual addresses. Read more
§

fn entry(&self) -> u64

Get the virtual address of the entry point of the binary.
§

fn flags(&self) -> FileFlags

File flags that are specific to each file format.
§

fn endianness(&self) -> Endianness

Get the endianness of the file.
§

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

Get the section named section_name, if such a section exists. Read more
§

fn symbol_by_name<'file>( &'file self, symbol_name: &str, ) -> Option<Self::Symbol<'file>>

Get the symbol named symbol_name, if the symbol exists.
§

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.

Auto Trait Implementations§

§

impl<'data, R> Forget for File<'data, R>

§

impl<'data, R> Freeze for File<'data, R>
where CoffFile<'data, R>: Freeze, CoffFile<'data, R, AnonObjectHeaderBigobj>: Freeze, ElfFile<'data, FileHeader32<Endianness>, R>: Freeze, ElfFile<'data, FileHeader64<Endianness>, R>: Freeze, MachOFile<'data, MachHeader32<Endianness>, R>: Freeze, MachOFile<'data, MachHeader64<Endianness>, R>: Freeze, PeFile<'data, ImageNtHeaders32, R>: Freeze, PeFile<'data, ImageNtHeaders64, R>: Freeze, WasmFile<'data, R>: Freeze, XcoffFile<'data, FileHeader32, R>: Freeze, XcoffFile<'data, FileHeader64, R>: Freeze,

§

impl<'data, R> RefUnwindSafe for File<'data, R>
where CoffFile<'data, R>: RefUnwindSafe, CoffFile<'data, R, AnonObjectHeaderBigobj>: RefUnwindSafe, ElfFile<'data, FileHeader32<Endianness>, R>: RefUnwindSafe, ElfFile<'data, FileHeader64<Endianness>, R>: RefUnwindSafe, MachOFile<'data, MachHeader32<Endianness>, R>: RefUnwindSafe, MachOFile<'data, MachHeader64<Endianness>, R>: RefUnwindSafe, PeFile<'data, ImageNtHeaders32, R>: RefUnwindSafe, PeFile<'data, ImageNtHeaders64, R>: RefUnwindSafe, WasmFile<'data, R>: RefUnwindSafe, XcoffFile<'data, FileHeader32, R>: RefUnwindSafe, XcoffFile<'data, FileHeader64, R>: RefUnwindSafe,

§

impl<'data, R> Send for File<'data, R>
where CoffFile<'data, R>: Send, CoffFile<'data, R, AnonObjectHeaderBigobj>: Send, ElfFile<'data, FileHeader32<Endianness>, R>: Send, ElfFile<'data, FileHeader64<Endianness>, R>: Send, MachOFile<'data, MachHeader32<Endianness>, R>: Send, MachOFile<'data, MachHeader64<Endianness>, R>: Send, PeFile<'data, ImageNtHeaders32, R>: Send, PeFile<'data, ImageNtHeaders64, R>: Send, WasmFile<'data, R>: Send, XcoffFile<'data, FileHeader32, R>: Send, XcoffFile<'data, FileHeader64, R>: Send,

§

impl<'data, R> Sync for File<'data, R>
where CoffFile<'data, R>: Sync, CoffFile<'data, R, AnonObjectHeaderBigobj>: Sync, ElfFile<'data, FileHeader32<Endianness>, R>: Sync, ElfFile<'data, FileHeader64<Endianness>, R>: Sync, MachOFile<'data, MachHeader32<Endianness>, R>: Sync, MachOFile<'data, MachHeader64<Endianness>, R>: Sync, PeFile<'data, ImageNtHeaders32, R>: Sync, PeFile<'data, ImageNtHeaders64, R>: Sync, WasmFile<'data, R>: Sync, XcoffFile<'data, FileHeader32, R>: Sync, XcoffFile<'data, FileHeader64, R>: Sync,

§

impl<'data, R> Unpin for File<'data, R>
where CoffFile<'data, R>: Unpin, CoffFile<'data, R, AnonObjectHeaderBigobj>: Unpin, ElfFile<'data, FileHeader32<Endianness>, R>: Unpin, ElfFile<'data, FileHeader64<Endianness>, R>: Unpin, MachOFile<'data, MachHeader32<Endianness>, R>: Unpin, MachOFile<'data, MachHeader64<Endianness>, R>: Unpin, PeFile<'data, ImageNtHeaders32, R>: Unpin, PeFile<'data, ImageNtHeaders64, R>: Unpin, WasmFile<'data, R>: Unpin, XcoffFile<'data, FileHeader32, R>: Unpin, XcoffFile<'data, FileHeader64, R>: Unpin,

§

impl<'data, R> UnsafeUnpin for File<'data, R>
where CoffFile<'data, R>: UnsafeUnpin, CoffFile<'data, R, AnonObjectHeaderBigobj>: UnsafeUnpin, ElfFile<'data, FileHeader32<Endianness>, R>: UnsafeUnpin, ElfFile<'data, FileHeader64<Endianness>, R>: UnsafeUnpin, MachOFile<'data, MachHeader32<Endianness>, R>: UnsafeUnpin, MachOFile<'data, MachHeader64<Endianness>, R>: UnsafeUnpin, PeFile<'data, ImageNtHeaders32, R>: UnsafeUnpin, PeFile<'data, ImageNtHeaders64, R>: UnsafeUnpin, WasmFile<'data, R>: UnsafeUnpin, XcoffFile<'data, FileHeader32, R>: UnsafeUnpin, XcoffFile<'data, FileHeader64, R>: UnsafeUnpin,

§

impl<'data, R> UnwindSafe for File<'data, R>
where CoffFile<'data, R>: UnwindSafe, CoffFile<'data, R, AnonObjectHeaderBigobj>: UnwindSafe, ElfFile<'data, FileHeader32<Endianness>, R>: UnwindSafe, ElfFile<'data, FileHeader64<Endianness>, R>: UnwindSafe, MachOFile<'data, MachHeader32<Endianness>, R>: UnwindSafe, MachOFile<'data, MachHeader64<Endianness>, R>: UnwindSafe, PeFile<'data, ImageNtHeaders32, R>: UnwindSafe, PeFile<'data, ImageNtHeaders64, R>: UnwindSafe, WasmFile<'data, R>: UnwindSafe, XcoffFile<'data, FileHeader32, R>: UnwindSafe, XcoffFile<'data, FileHeader64, R>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.