gtirb.module module¶
- class gtirb.module.Module(*, name, aux_data={}, binary_path='', file_format=FileFormat.Undefined, isa=ISA.Undefined, byte_order=ByteOrder.Undefined, preferred_addr=0, proxies={}, rebase_delta=0, sections={}, symbols={}, entry_point=None, uuid=None, ir=None)[source]¶
Bases:
AuxDataContainerRepresents a loadable object, such as an executable or library.
- Variables:
~.binary_path – The path to the loadable binary object represented by this module. An empty string if not specified. The file represented by this path is indicitave of what file this
Modulewas initially created from; it is not guaranteed to currently exist or have the same contents.~.isa – The ISA of the binary.
~.file_format – The file format of the binary.
~.byte_order – The endianness of the binary.
~.name – The name given to the binary. Some file formats use this for linking and/or symbol resolution purposes. The file name (without directory components) if not specified by the format.
~.preferred_addr – The preferred loading address of the binary.
~.proxies – A set containing all the
gtirb.ProxyBlocks in the binary.~.rebase_delta – The rebase delta of the binary.
~.sections – A set containing all the
gtirb.Sections in the binary.~.symbols – A set containing all the
gtirb.Symbols in the binary.~.entry_point – A
CodeBlockrepresenting where control flow of this module begins at, or None if not present.
- class ByteOrder(value)[source]¶
Bases:
EnumIdentifies the endianness of a
gtirb.Module.- Big = 1¶
Big endian.
- Little = 2¶
Little endian.
- Undefined = 0¶
An unknown or uninitialized endianness.
- class FileFormat(value)[source]¶
Bases:
EnumIdentifies the executable file format of the binary represented by a
gtirb.Module.- COFF = 1¶
The Common Object File Format.
- ELF = 2¶
The Executable and Linkable Format, formerly the Extensible Linking Format.
- IdaProDb32 = 4¶
A 32-bit IDA Pro database file.
- IdaProDb64 = 5¶
A 64-bit IDA Pro database file.
- MACHO = 7¶
A Mach object file.
- PE = 3¶
Microsoft’s Portable Executable format.
- RAW = 8¶
A raw binary file, with no file format.
- Undefined = 0¶
A file format that has not yet been specified. This is for unitialized modules; do not use to refer to file formats without
FileFormatvalues.
- XCOFF = 6¶
The Extended Common Object File Format.
- class ISA(value)[source]¶
Bases:
EnumIdentifies the instruction set architecture (ISA) targeted by a
gtirb.Module.- ARM = 4¶
The Acorn RISC Machine, 32-bit.
- ARM64 = 7¶
The Acorn RISC Machine, 64-bit.
- IA32 = 1¶
The 32-bit Intel Architecture. Also known as i386, x86, or x32.
- MIPS32 = 8¶
Microprocessor without Interlocked Pipelined Stages, 32-bit.
- MIPS64 = 9¶
Microprocessor without Interlocked Pipelined Stages, 64-bit.
- PPC32 = 2¶
IBM’s 32-bit PowerPC (Performance Optimization with Enhanced RISC / Performance Computing) architecture.
- PPC64 = 6¶
IBM’s 64-bit PowerPC (Performance Optimization with Enhanced RISC / Performance Computing) architecture.
- Undefined = 0¶
An ISA that has not yet been specified. This is for unitialized modules; use
gtirb.Module.ISA.ValidButUnsupportedinstead for specifying undefined ISAs.
- ValidButUnsupported = 5¶
An unknown or undefined ISA.
- X64 = 3¶
The 64-bit Intel Architecture. Also known as x86_64.
- __init__(*, name, aux_data={}, binary_path='', file_format=FileFormat.Undefined, isa=ISA.Undefined, byte_order=ByteOrder.Undefined, preferred_addr=0, proxies={}, rebase_delta=0, sections={}, symbols={}, entry_point=None, uuid=None, ir=None)[source]¶
- Parameters:
aux_data (
typing.Union[typing.Mapping[str,gtirb.auxdata.AuxData],typing.Iterable[typing.Tuple[str,gtirb.auxdata.AuxData]]]) – The initial auxiliary data to be associated with the object, as a mapping from names togtirb.AuxData, defaults to an emptydict.binary_path (
str) – The path to the loadable binary object represented by this module.isa (
gtirb.module.Module.ISA) – The ISA of the binary.byte_order (
gtirb.module.Module.ByteOrder) – The endianness of the binary.file_format (
gtirb.module.Module.FileFormat) – The file format of the binary.name (
str) – The name given to the binary.preferred_addr (
int) – The preferred loading address of the binary.proxies (
typing.Iterable[gtirb.block.ProxyBlock]) – A set containing all thegtirb.ProxyBlocks in the binary.rebase_delta (
int) – The rebase delta of the binary.sections (
typing.Iterable[gtirb.section.Section]) – A set containing all thegtirb.Sections in the binary.symbols (
typing.Iterable[gtirb.symbol.Symbol]) – A set containing all thegtirb.Symbols in the binary.entry_point (
typing.Optional[gtirb.block.CodeBlock]) – ACodeBlockrepresenting where control flow of this module begins at, or None if not present.uuid (
typing.Optional[uuid.UUID]) – The UUID of thisModule, or None if a new UUID needs generated viauuid.uuid4(). Defaults to None.ir (
typing.Optional[gtirb.ir.IR]) – TheIRthis module belongs to.
- byte_blocks_at(addrs)[source]¶
Finds all the byte blocks that begin at an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.block.ByteBlock]
- byte_blocks_on(addrs)[source]¶
Finds all the byte blocks that overlap an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.block.ByteBlock]
- property byte_intervals: Iterator[ByteInterval]¶
The
ByteIntervals in this module.
- byte_intervals_at(addrs)[source]¶
Finds all the byte intervals that begin at an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.byteinterval.ByteInterval]
- byte_intervals_on(addrs)[source]¶
Finds all the byte intervals that overlap an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.byteinterval.ByteInterval]
- code_blocks_at(addrs)[source]¶
Finds all the code blocks that begin at an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.block.CodeBlock]
- code_blocks_on(addrs)[source]¶
Finds all the code blocks that overlap an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.block.CodeBlock]
- data_blocks_at(addrs)[source]¶
Finds all the data blocks that begin at an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.block.DataBlock]
- data_blocks_on(addrs)[source]¶
Finds all the data blocks that overlap an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.block.DataBlock]
- deep_eq(other)[source]¶
This overrides
gtirb.Node.deep_eq()to check for AuxData equality.Because the values stored by AuxData are not necessarily amenable to deep checking, the auxiliary data dictionaries stored for
selfandotherare not deeply checked. Instead, they are considered to be equal if their sets of keys are equal.- Return type:
bool
- sections_at(addrs)[source]¶
Finds all the sections that begin at an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.section.Section]
- sections_on(addrs)[source]¶
Finds all the sections that overlap an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[gtirb.section.Section]
- symbolic_expressions_at(addrs)[source]¶
Finds all the symbolic expressions that begin at an address or range of addresses.
- Parameters:
addrs (
typing.Union[int,range]) – Either arangeobject or a single address.- Return type:
typing.Iterable[typing.Tuple[gtirb.byteinterval.ByteInterval,int,gtirb.symbolicexpression.SymbolicExpression]]- Returns:
Yields
(interval, offset, symexpr)tuples for every symbolic expression in the range.
- symbols_named(name)[source]¶
Finds all symbols with a given name.
- Return type:
typing.Iterator[gtirb.symbol.Symbol]