Commit graph

508 commits

Author SHA1 Message Date
Yan Shoshitaishvili
2c95eb92e6
CFG: Warn when the regions to analyze cover no bytes. (#6825) 2026-08-13 17:26:22 -05:00
Fish
b80f4cf2af
Outliner: Rebuild phi statements; update output phis; return only region-defined vvars. (#6831)
* Rebuild phi statements instead of mutating them in place

* Update the phis of every dispatcher target

* Return only the variables the outlined region defines
2026-08-13 13:51:21 -07:00
Fish
41a7db2f17
SLiveness: propagate to predecessors instead of re-walking the graph (#6830) 2026-08-13 12:38:23 -07:00
Yan Shoshitaishvili
2bfaa7e8f7
CFGModel: Stop aborting when tidying a data reference at an unmapped address (#6811)
Fix #6770.
2026-08-11 13:27:06 -07:00
Fish
0c293dc0de
Phoenix: Fix incorrect virtualization of orphaned edges. (#6790) 2026-08-09 02:00:48 -07:00
Fish
ede5faf162
Decompiler: Add edits layer; add more tools to MCP. (#6789) 2026-08-09 01:48:07 -07:00
Fish
bdc1321845
RustCodeGen: Add more handlers. (#6788) 2026-08-08 09:28:22 -07:00
Fish
666fadabc5
Dephication: Keep the remapped assignment destination with source is not a vvar. (#6787) 2026-08-07 23:50:03 -07:00
Fish
fdd66945ea
CFGTransformationMixin: Rebuild conditional jumps when replacing branch targets. (#6786) 2026-08-07 23:46:34 -07:00
Fish
b0e3541dfd
SwitchClusterSimplifier: Do not merge different default nodes. (#6782) 2026-08-07 19:13:10 -07:00
Fish
780a80de79
Phoenix: Correct Loop.continue_addr. (#6785) 2026-08-07 18:41:56 -07:00
Fish
08c7e48d5b
CFGFast: Mark bad blocks found by complete scanning as nodecode. (#6781) 2026-08-07 14:16:21 -07:00
Fish
0f4be85db4
Make CallSiteMaker a normal class instead of an Analysis. (#6776) 2026-08-06 08:44:29 -04:00
Fish
7d3c7c82ce
AILSimplifier: De-quadratify _unify_local_variables. (#6772) 2026-08-05 22:33:55 -04:00
Fish
7c2e3501e6
SimStruct: Remove _arch_memo to fix the cache leak. (#6757)
* SimStruct: Remove _arch_memo to fix the cache leak.

* Fix the comment

* Better typing.

* Fix RustSimTypes.

* More fixes.

* Fix caching for anonymous structs.

* SimUnion: Cache alignment.

* Convert returnty to a arch-ed returnty.

* RustSimType: Do not shadow SimType.with_arch.

* Rust: Bind an arch to types before they reach the type solver.

* RustSimType: Make it a subclass of SimType.
2026-08-05 01:12:55 -07:00
Yan Shoshitaishvili
f160178837
reaching_definitions: reject mismatched conversion widths (#6749)
* reaching_definitions: reject mismatched conversion widths

* Tests: satisfy RDA lint and type checks
2026-08-05 00:26:01 -07:00
Fish
71bf42c9b8
Decompiler: Test common C conditions. (#6762)
* Decompiler: Test common C conditions.

* Improve c-style null compatison implementation

* Make order-sensitive

---------

Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
2026-08-04 18:27:09 -07:00
Fish
551df09fc5
Decompiler: Fix duplicate struct defs for pre-defined structs. (#6756) 2026-08-03 22:12:47 -07:00
Yibo Liu
0f8e082f9a
Clinic: recover variable-length arrays (VLAs) (#6634) 2026-08-01 13:41:12 -07:00
Kevin Phoenix
49434bc3fc
Render truncations to non-C widths as masks instead of casts (#6741) 2026-07-31 17:05:47 -07:00
pre-commit-ci[bot]
d38cc5a019
[pre-commit.ci] pre-commit autoupdate (#6721)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.15.22 → v0.16.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.22...v0.16.0)

* Apply fixes

* Add values()

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
2026-07-29 13:46:11 -07:00
Fish
7cedfbfa8b
Dephication: Correctly consider phi congruence classes. (#6735) 2026-07-29 01:53:02 -07:00
Ati Priya
6933b065f0
Decompiler: rewrite CondBE and CondNB ccalls on amd64 (#6645)
* Decompiler: rewrite CondBE and CondNB ccalls on amd64

* Decompiler: fix inverted CondZ/CondNZ over G_CC_OP_COPY on amd64

* tests: add binary-driven regressions for CondBE/CondNB ccall recovery
2026-07-29 01:11:09 -07:00
Fish
6b2637c446
Dephication: Consider the vvar used in block-end jumps during intersection. (#6733)
* Dephication: Consider the vvar used in block-end jumps during intersection.

This is a subtlety in the Sreedhar et. al. paper.

* Fix test cases.
2026-07-29 00:42:21 -07:00
Fish
a7ae033c69
EagerEval: Fix broken expression type comparison. (#6734)
This is a bug introduced by the Rusty AIL migration.
2026-07-29 00:05:07 -07:00
Fish
659f3d7f5d
CCodeGen: Fix the display of negative offsets. (#6730)
* CCodeGen: Fix the display of negative offsets.

* Fix a test case.
2026-07-28 22:29:12 -07:00
Fish
22613f4a0a
CompleteCallingConventions: fail loudly when all workers die. (#6718) 2026-07-27 18:20:59 -07:00
Fish
1a5eedf622
Decompiler: Speed up AIL block simplifications. (#6712)
- Make SPropagator, SRDA, and BlockSimplifier normal classes instead of Analysis classes.

- Share peephole optimizer instances across BlockSimplifiers.

- BlockSimplifier: Skip unnecessary peephole passes; avoid block-level comparisons for fixpoint determination.

- Add a runtime-only peephole_optimized flag to AIL statements so we skip running peephole optimizations on already optimized statements.
2026-07-27 16:34:10 -07:00
Fish
651d9cccc2
Tests: Speed up decompiler-related test cases (strike 1). (#6713) 2026-07-27 01:56:24 -07:00
Fish
787c2c7d8e
SimpleSolver: Memoize least common ancestors on type lattices. (#6707) 2026-07-26 17:17:09 -07:00
Fish
b37cca0101
VRA: Register the Reference stack variable against its atom. (#6705) 2026-07-26 07:58:06 -07:00
Fish
fc7ff8e62c
CFGFast: Linear scan heuristics for monotonic byte ramps and floats. (#6701) 2026-07-26 00:35:43 -07:00
Yan Shoshitaishvili
83d0061e12
Calling conventions: ignore stack canary comparisons as returns (#6699)
* Calling conventions: ignore stack canary comparisons as returns
2026-07-24 16:34:21 -07:00
Yan Shoshitaishvili
f74d1c5c1e
Typehoon: index subtype constraint components (#6696)
* Typehoon: index subtype constraint components

* Refactor the code to eliminate weird terminology.

* Fix test cases.

---------

Co-authored-by: Fish <fishw@asu.edu>
2026-07-24 16:26:47 -07:00
Ati Priya
db21fb0fee
Rewrite the amd64 CondO/CondNO ccall (#6693)
* Rewrite the amd64 CondO/CondNO ccall family

amd64g_calculate_condition with cond CondO/CondNO had no rewrite arm at
all, so every jo/jno/seto/cmovno site leaked into the decompilation as an
uncompilable _ccall(0|1, cc_op, ...).

Add arms for the cc_op families that define OF:

  LOGIC{B,W,L,Q}  and/or/xor always clear OF -> constant 0 / 1
  ADD{B,W,L,Q}    -> __OFADD__(dep_1, dep_2)
  SUB{B,W,L,Q}    -> __OFSUB__(dep_1, dep_2)
  UMUL{B,W,L,Q}   -> __OFUMUL__(dep_1, dep_2)
  SMUL{B,W,L,Q}   -> __OFSMUL__(dep_1, dep_2)
  INC{B,W,L,Q}    result == signed minimum
  DEC{B,W,L,Q}    result == signed maximum
  COPY            test the stored OF bit

The overflow helpers follow the existing __CFADD__ arm: a named usercall
whose operands carry the operation width. CondNO reuses the same helper
and compares it against zero.

Unsigned multiply overflow is defined as "the high half of the full
2N-bit product is nonzero", i.e. the product does not fit in N unsigned
bits. Note this is NOT the threshold used by the x86 rewriter, which
compares the product against 1 << (N - 1) -- that is the signed
threshold, half the correct unsigned one, and it reports overflow for
every product in [2^(N-1), 2^N - 1] even though those fit. At 8 bits it
misclassifies 820 of 65536 operand pairs, all false positives.

pc_actions_UMUL in the VEX ccall helpers is itself wrong here: it
multiplies two N-bit values without widening, so its `>> nbits` is
always zero and its CF/OF do not agree with the hardware. The rewrite
arm follows the hardware and pc_actions_SMUL's (correct) structure
instead; fixing the helper is left alone.

Every arm was checked exhaustively at 8 bits against
pc_calculate_condition, and the ADD/SUB/UMUL/SMUL arms additionally
against real setcc results.

* Drop the synthetic CondO fixture test

The real gzip and file fixtures already cover the CondO arms; a purpose
built binary added nothing that the unit tests do not already check.

* Cover the CondNO overflow path with a real binary

tar's argp helper guards a multiply with 'mul %rbp; jno', exercising the
CondNO side of UMULQ that gzip and file do not reach. Other cc_op
families still leak a ccall in that function, so only the OF conditions
are asserted.

* Cover the CondO overflow arms with three more real binaries

coreutils cat, grep and zlib's minigzip each carry the xalloc /
__builtin_mul_overflow idiom, between them exercising CondO against
ADDQ, SMULQ and UMULQ across three separate projects. Verified symbols
and addresses are cited on each test.

* Correct the tar overflow test to CondO

The jno there is canonicalized into CondO with an inverted branch, so the
ccall reaching the rewriter carries cond 0, not cond 1. The negation seen
in the output is the structurer's, not the condition's.
2026-07-24 11:28:39 -07:00
Yan Shoshitaishvili
fe434a049b
Decompiler: reject float constants in string simplifiers (#6682)
* Decompiler: reject float constants in string simplifiers

* Tests: allow private simplifier coverage
2026-07-24 00:28:36 -07:00
Yan Shoshitaishvili
208ec719a6
Decompiler: disambiguate Extract condition placeholders (#6677) 2026-07-23 22:33:21 -07:00
Yan Shoshitaishvili
8b98c5ad6c
Keep eager evaluation integer-only (#6681) 2026-07-23 22:30:15 -07:00
Yan Shoshitaishvili
2dd6cb393b
Typehoon: preserve standard SimTypeNum types (#6678) 2026-07-23 21:15:18 -07:00
Yan Shoshitaishvili
cf54c35b9b
AIL: handle HAddV operations (#6680)
* AIL: handle HAddV operations

* Fix HAddV CI diagnostics
2026-07-23 21:10:10 -07:00
Vedant Soni
1808e7fadd
Migrate rust demangling to pydemumble (#6663)
* use pydemumble to demangle rust symbols

* update tests

* remove rust_demangle and unpin pydemumble from pyproject

* pin pydemumble to latest version
2026-07-23 17:32:00 -07:00
Fish
75500dd271
VRA: Copy over integer signedness to type constraints during Convert. (#6672)
* VRA: Copy over integer signedness to type constraints during Convert.

* Adjust a test case.
2026-07-23 15:57:26 -07:00
Fish
85d77f0301
RemoveRedundantShifts: Retain sign extensions. (#6671)
`(x << N) >> N` was rewritten into a Convert-of-Convert pair whose outer Convert
zero-extended for BOTH logical (Shr) and arithmetic (Sar) right shifts. For Sar
this is unsound: the idiom sign-extends the low (M-N) bits, but the zero-extending
Convert rendered as a bitmask, so e.g. `(int)(x << 20) >> 20` decompiled to
`x & 0xfff` (and the 64-bit twin to `x & 0xffffffffff`), which drops the
sign bit.
2026-07-23 14:43:45 -07:00
Fish
0849ddb03c
CFGFast: Tolerate leading null bytes during string scanning. (#6670)
* CFGFast: Tolerate a single leading null byte when scanning for strings.

* CFGFast: Scan for mixed pointers in high-based images during complete scanning.

* Tests: Add a regression test for data detection in a PE32 with data tables in .text.
2026-07-23 14:43:32 -07:00
Fish
8dc3772762
tests: CFG resolves delay-load import calls to named imports. (#6666) 2026-07-23 14:16:54 -07:00
Fish
2f8266bdda
CFGFast: Constant-fold AMD64 PE IAT calls. (#6667)
* CFGFast: constant-fold AMD64 PE IAT jumps/calls, bypassing the resolver

* CFGFast: fold delay-load IAT calls too, matching MemoryLoadResolver

* tests: update lwip xrefs for corrected RO-region ordering
2026-07-22 03:55:07 -07:00
Fish
02c374b5b4
DecompilationCache: Serialization support. (#6624)
Also,

- Refactored variable_kb into kb.dec_variables.

- Spill decompilation cache into RuntimeDb.

- Save decompilation cache into angrDb. Decompilation results can be preserved across runs.

- No longer check in _pb2.py files; they are generated during build.
2026-07-22 03:03:40 -07:00
Ati Priya
e8858b82cd
typehoon: type pointer-to-array locals as pointers (#6620)
* typehoon: type function-scope pointer-to-array locals as element pointers (T*) so they render as pointers, not arrays

c_repr drops the "*" for pointer-to-array, so such locals were declared
as arrays and assignments to them were invalid C. Flatten T (*)[N] to
T * for function-scope variables; globals and plain arrays unchanged.

* tests: accept element-pointer rendering in reverting-switch-lowering test

Locals typed as element pointers render "ptr = p + 1;" instead of
"ptr = &p[1];"; both are equivalent. Accept either form.
2026-07-22 02:28:25 -07:00
Yan Shoshitaishvili
bcf5902d07
Keep entry jumps inside sized function symbols (#6651)
* Keep entry jumps within sized function symbols

* Narrow CFG regression symbol type

* Use committed binary for CFG entry-jump regression
2026-07-22 01:52:32 -07:00
Yan Shoshitaishvili
21cea3815f
Refine C++ symbol prototypes with machine ABI facts (#6652)
* Refine C++ symbol prototypes with machine ABI facts

* Preserve explicit C++ calling conventions

* Use prebuilt C++ calling-convention fixture
2026-07-22 01:50:12 -07:00