Skip to content

Commit

Permalink
Add new engine based on Ghidra's P-Code IR (angr#2328)
Browse files Browse the repository at this point in the history
This patch adds a new engine to angr that uses Ghidra's P-Code
intermediate representation. Lifting is handled by the SLEIGH library,
with bindings to Python via pypcode. Symbolic execution is supported for
a majority of ops.
  • Loading branch information
mborgerson authored Oct 26, 2020
1 parent 8883c20 commit b8c43fc
Show file tree
Hide file tree
Showing 8 changed files with 3,146 additions and 0 deletions.
9 changes: 9 additions & 0 deletions angr/analyses/cfg/indirect_jump_resolvers/jumptable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
from ....exploration_techniques.explorer import Explorer
from ....utils.constants import DEFAULT_STATEMENT
from .resolver import IndirectJumpResolver
from ....misc.ux import once

try:
from ....engines import pcode
except ImportError:
pcode = None

l = logging.getLogger(name=__name__)

Expand Down Expand Up @@ -521,6 +526,10 @@ def __init__(self, project):
self._find_bss_region()

def filter(self, cfg, addr, func_addr, block, jumpkind):
if pcode is not None and isinstance(block.vex, pcode.lifter.IRSB):
if once('pcode__indirect_jump_resolver'):
l.warning('JumpTableResolver does not support P-Code IR yet; CFG may be incomplete.')
return False

if is_arm_arch(self.project.arch):
# For ARM, we support both jump tables and "call tables" (because of how crazy ARM compilers are...)
Expand Down
6 changes: 6 additions & 0 deletions angr/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
class UberEngine(SimEngineFailure, SimEngineSyscall, HooksMixin, SimEngineUnicorn, SuperFastpathMixin, TrackActionsMixin, SimInspectMixin, HeavyResilienceMixin, SootMixin, HeavyVEXMixin):
pass

try:
from .pcode import HeavyPcodeMixin
class UberEnginePcode(SimEngineFailure, SimEngineSyscall, HooksMixin, HeavyPcodeMixin): # pylint:disable=abstract-method
pass
except ImportError:
pass
1 change: 1 addition & 0 deletions angr/engines/pcode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .engine import HeavyPcodeMixin
Loading

0 comments on commit b8c43fc

Please sign in to comment.