Expand description
Interface for reading object files.
§Unified read API
The Object
trait provides a unified read API for accessing common features of
object files, such as sections and symbols. There is an implementation of this
trait for File
, which allows reading any file format, as well as implementations
for each file format:
ElfFile
, MachOFile
, CoffFile
,
PeFile
, WasmFile
, XcoffFile
.
§Low level read API
The submodules for each file format define helpers that operate on the raw structs. These can be used instead of the unified API, or in conjunction with it to access details that are not available via the unified API.
See the submodules for examples of the low level read API.
§Naming Convention
Types that form part of the unified API for a file format are prefixed with the name of the file format.
§Example for unified read API
use object::{Object, ObjectSection};
use std::error::Error;
use std::fs;
/// Reads a file and displays the name of each section.
fn main() -> Result<(), Box<dyn Error>> {
let data = fs::read("path/to/binary")?;
let file = object::File::parse(&*data)?;
for section in file.sections() {
println!("{}", section.name()?);
}
Ok(())
}
Modules§
- Support for reading Windows COFF files.
- Support for reading ELF files.
- Support for reading Mach-O files.
- Support for reading PE files.
- Support for reading AIX XCOFF files.
Structs§
- A newtype for byte slices.
- PDB information from the debug directory in a PE file.
- A COMDAT section group in a
File
. - An iterator for the COMDAT section groups in a
File
. - An iterator for the sections in a
Comdat
. - Data that may be compressed.
- A range in a file that may be compressed.
- An iterator for the dynamic relocation entries in a
File
. - The error type used within the read module.
- An exported symbol.
- An imported symbol.
- An iterator for files that don’t have dynamic relocations.
- A map from addresses to symbol names and object files.
- A symbol in an
ObjectMap
. - An object file name in an
ObjectMap
. - An implementation of
ReadRef
for data in a stream that implementsRead + Seek
. - An implementation of
ReadRef
for a range of data in a stream that implementsRead + Seek
. - A relocation entry.
- A map from section offsets to relocation information.
- A section in a
File
. - The index used to identify a section in a file.
- An iterator for the sections in a
File
. - An iterator for the relocation entries in a
Section
. - A loadable segment in a
File
. - An iterator for the loadable segments in a
File
. - A table of zero-terminated strings.
- An symbol in a
SymbolTable
. - The index used to identify a symbol in a symbol table.
- An iterator for the symbols in a
SymbolTable
. - A map from addresses to symbol information.
- The type used for entries in a
SymbolMap
that maps from addresses to names. - A symbol table in a
File
.
Enums§
- The size of an address value for an architecture.
- A CPU architecture.
- A binary file format.
- The selection kind for a COMDAT section group.
- A data compression format.
- An object file that can be any supported file format.
- File flags that are specific to each file format.
- A file format kind.
- An object kind.
- Information about how the result of the relocation operation is encoded in the place.
- Relocation fields that are specific to each file format and architecture.
- The operation used to calculate the result of the relocation.
- The target referenced by a
Relocation
. - Section flags that are specific to each file format.
- The kind of a section.
- Segment flags that are specific to each file format.
- A CPU sub-architecture.
- Symbol flags that are specific to each file format.
- The kind of a symbol.
- A symbol scope.
- The section where an
ObjectSymbol
is defined.
Traits§
- An object file.
- A COMDAT section group in an
Object
. - A section in an
Object
. - A loadable segment in an
Object
. - A symbol table entry in an
Object
. - A symbol table in an
Object
. - Operations required to implement
ReadCache
. - A trait for reading references to
Pod
types from a block of data. - An entry in a
SymbolMap
.
Type Aliases§
- The native executable file for the target platform.
- The result type used within the read module.