Principle:0sec labs 0 Decompilation IR Lifting
| Knowledge Sources | |
|---|---|
| Domains | Binary_Analysis, Decompilation, Reverse_Engineering |
| Last Updated | 2026-10-30 00:00 GMT |
Overview
Technique for lifting compiled machine code into an intermediate representation (decompiled C, instruction list, call graph) that enables static and symbolic analysis.
Description
Decompilation and IR lifting is the process of translating native machine code (x86-64, ARM64, MIPS) back into a human-readable and machine-analyzable form. A decompiler backend (Ghidra, rizin, angr) disassembles the binary, reconstructs control flow, recovers data types, and emits pseudo-C code. The resulting intermediate representation includes a decompiled C function map, an instruction list with addresses, a call graph, and recovered sink addresses. This IR is the foundation for all subsequent static analysis — without it, backward taint slicing and bug-class lens application cannot proceed.
Usage
Use this principle when a binary vulnerability pipeline needs to analyze compiled code without source. The backend choice trades off quality (Ghidra produces the best pseudo-C) against freedom (rizin/r2ghidra is fully open-source) and speed (angr's VEX IR is fastest for symbolic execution).
Theoretical Basis
Decompilation involves three core transformations:
- Disassembly: machine bytes → instruction stream (decoded per ISA)
- Control flow recovery: instruction stream → basic blocks → CFG (handling indirect jumps, switch tables)
- Type and structure recovery: stack frame analysis → variable types → structured C (if/while/for)
The IR adapter pattern abstracts over backend differences:
# Abstract interface (NOT real implementation)
adapter = backend.analyze(binary_path)
decompiled_c = adapter.meta.decompiled_c # dict[function_name -> C code]
instructions = adapter.all_insts() # list[Inst] with addr, func, kind
callgraph = adapter.meta.callgraph # dict[caller -> [callees]]