angr.knowledge_plugins.key_definitions.atoms

class angr.knowledge_plugins.key_definitions.atoms.AtomKind

Bases: Enum

An enum indicating the class of an atom

REGISTER = 1
MEMORY = 2
TMP = 3
GUARD = 4
CONSTANT = 5
class angr.knowledge_plugins.key_definitions.atoms.Atom

Bases: object

This class represents a data storage location manipulated by IR instructions.

It could either be a Tmp (temporary variable), a Register, a MemoryLocation.

__init__(size)
Parameters:

size – The size of the atom in bytes

size
property bits: int
static from_ail_expr(expr, arch, full_reg=False)
Return type:

Register

Parameters:
static from_argument(argument, arch, full_reg=False, sp=None)

Instantiate an Atom from a given argument.

Parameters:
  • argument (SimFunctionArgument) – The argument to create a new atom from.

  • arch (Arch) – The argument representing archinfo architecture for argument.

  • full_reg – Whether to return an atom indicating the entire register if the argument only specifies a slice of the register.

  • sp (int | None) – The current stack offset. Optional. Only used when argument is a SimStackArg.

Return type:

Register | MemoryLocation

static reg(thing, size=None, arch=None)

Create a Register atom.

Parameters:
  • thing (str | RegisterOffset) – The register offset (e.g., project.arch.registers[“rax”][0]) or the register name (e.g., “rax”).

  • size (int | None) – Size of the register atom. Must be provided when creating the atom using a register offset.

  • arch (Arch | None) – The architecture. Must be provided when creating the atom using a register name.

Return type:

Register

Returns:

The Register Atom object.

static register(thing, size=None, arch=None)

Create a Register atom.

Parameters:
  • thing (str | RegisterOffset) – The register offset (e.g., project.arch.registers[“rax”][0]) or the register name (e.g., “rax”).

  • size (int | None) – Size of the register atom. Must be provided when creating the atom using a register offset.

  • arch (Arch | None) – The architecture. Must be provided when creating the atom using a register name.

Return type:

Register

Returns:

The Register Atom object.

static mem(addr, size, endness=None)

Create a MemoryLocation atom,

Parameters:
  • addr (SpOffset | HeapAddress | int) – The memory location. Can be an SpOffset for stack variables, an int for global memory variables, or a HeapAddress for items on the heap.

  • size (int) – Size of the atom.

  • endness (Endness | None) – Optional, either “Iend_LE” or “Iend_BE”.

Return type:

MemoryLocation

Returns:

The MemoryLocation Atom object.

static memory(addr, size, endness=None)

Create a MemoryLocation atom,

Parameters:
  • addr (SpOffset | HeapAddress | int) – The memory location. Can be an SpOffset for stack variables, an int for global memory variables, or a HeapAddress for items on the heap.

  • size (int) – Size of the atom.

  • endness (Endness | None) – Optional, either “Iend_LE” or “Iend_BE”.

Return type:

MemoryLocation

Returns:

The MemoryLocation Atom object.

class angr.knowledge_plugins.key_definitions.atoms.GuardUse

Bases: Atom

Implements a guard use.

target
class angr.knowledge_plugins.key_definitions.atoms.ConstantSrc

Bases: Atom

Represents a constant.

value: int
class angr.knowledge_plugins.key_definitions.atoms.Tmp

Bases: Atom

Represents a variable used by the IR to store intermediate values.

tmp_idx
class angr.knowledge_plugins.key_definitions.atoms.Register

Bases: Atom

Represents a given CPU register.

As an IR abstracts the CPU design to target different architectures, registers are represented as a separated memory space. Thus a register is defined by its offset from the base of this memory and its size.

Variables:
  • reg_offset (int) – The offset from the base to define its place in the memory bloc.

  • size (int) – The size, in number of bytes.

reg_offset
arch
property name: str
class angr.knowledge_plugins.key_definitions.atoms.VirtualVariable

Bases: Atom

Represents a virtual variable.

varid
category
oident
property was_reg: bool
property was_stack: bool
property was_parameter: bool
property was_tmp: bool
property reg_offset: int | None
property stack_offset: int | None
property tmp_idx: int | None
class angr.knowledge_plugins.key_definitions.atoms.MemoryLocation

Bases: Atom

Represents a memory slice.

It is characterized by its address and its size.

__init__(addr, size, endness=None)
Parameters:
  • addr (SpOffset | HeapAddress | int) – The address of the beginning memory location slice.

  • size (int) – The size of the represented memory location, in bytes.

  • endness (Endness | None)

addr: SpOffset | int | BV
endness
property is_on_stack: bool

True if this memory location is located on the stack.

property symbolic: bool