archinfo
archinfo is a Python library providing classes with architecture-specific information essential for cross-architecture tools. It serves as a foundational component within the larger angr binary analysis framework, defining architectural details like register mappings, endianness, and instruction set properties. The library is actively maintained, with frequent minor updates, and is currently at version 9.2.209.
Warnings
- breaking Internal architecture definitions, especially register file offsets and VEX IR assumptions, are tightly coupled with PyVEX. Major updates to PyVEX or the angr framework may introduce breaking changes to how these internal structures are defined or accessed, even if the public archinfo API remains superficially similar.
- gotcha archinfo is a core library within the angr ecosystem. Using mismatched versions of archinfo with other angr components (like pyvex, cle, or claripy) can lead to subtle runtime errors, incorrect architectural interpretations, or crashes due to inconsistent internal representations.
Install
-
pip install archinfo
Imports
- ArchAMD64
from archinfo import ArchAMD64
- get_host_arch
from archinfo import get_host_arch
- Arch
from archinfo.arch import Arch
Quickstart
from archinfo import get_host_arch, ArchAMD64
# Get the architecture of the host machine
host_arch = get_host_arch()
print(f"Host Architecture: {host_arch.name} ({host_arch.bits}-bit, {host_arch.memory_endness.name} endian)")
# Instantiate a specific architecture (e.g., AMD64)
x86_64_arch = ArchAMD64()
print(f"AMD64 Architecture: {x86_64_arch.name} ({x86_64_arch.bits}-bit, {x86_64_arch.memory_endness.name} endian)")
print(f"Instruction Pointer Register: {x86_64_arch.ip_name}")
print(f"Stack Pointer Register: {x86_64_arch.sp_name}")