gtirb.section module¶
- class gtirb.section.Section(*, name='', byte_intervals=(), flags={}, uuid=None, module=None)[source]¶
Bases:
NodeRepresents a named section of the binary.
Does not directly store the contents of the section, which are kept in a
gtirb.ImageByteMap.- Variables:
~.name – The section name (E.g. “.text”, “.bss”, etc).
~.byte_intervals – The
ByteIntervals in this section.~.flags – The
Section.Flags this section has.
- class Flag(value)[source]¶
Bases:
EnumA flag representing a known property of a section.
- Executable = 3¶
This section contains executable code.
- Initialized = 5¶
This section has bytes allocated to it in the binary file.
- Loaded = 4¶
This section is present in memory at runtime.
- Readable = 1¶
This section can be read from at runtime.
- ThreadLocal = 6¶
This section is created in memory once per thread.
- Undefined = 0¶
This value is defined for Protobuf compatibility. Do not use.
- Writable = 2¶
This section can be written to at runtime.
- __init__(*, name='', byte_intervals=(), flags={}, uuid=None, module=None)[source]¶
- Parameters:
name (
str) – The name of this section.byte_intervals (
typing.Iterable[gtirb.byteinterval.ByteInterval]) – TheByteIntervals in this section.flags (
typing.Iterable[gtirb.section.Section.Flag]) – TheSection.Flags this section has.uuid (
typing.Optional[uuid.UUID]) – The UUID of thisSection, or None if a new UUID needs generated viauuid.uuid4(). Defaults to None.module (
typing.Optional[gtirb.module.Module]) – TheModulethis section belongs to.
- property address: int | None¶
Get the address of this section, if known.
The address is calculated from the
ByteIntervalobjects in this section. More specifically, if the address of all byte intervals in this section are fixed, then it will return the address of the interval lowest in memory. If any one interval does not have an address then this will beNone, as the address is not calculable in that case. Note that a section with no intervals in it has no address or size, so it will beNonein that case.
- 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]
- 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]¶
Check: is
selfstructurally equal toother?This method should be used only when deep structural equality checks are actually needed, and not for all equality checks. Typically the default implmentation of __eq__, which checks pointer equality, is sufficient; Nodes are cached such that references to two Nodes with the same UUID refer to the same exact object. Use this method when you have manually constructed Nodes that may share the same UUID despite being different objects, and you need to check for structural equality.
- Return type:
bool
- property size: int | None¶
Get the size of this section, if known.
The address is calculated from the
ByteIntervalobjects in this section. More specifically, if the address of all byte intervals in this section are fixed, then it will return the difference between the lowest and highest address among the intervals. If any one interval does not have an address, then this will beNone, as the size is not calculable in that case. Note that a section with no intervals in it has no address or size, so it will beNonein that case.
- 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.