Skip to content

Releases

v0.1.17

Choose a tag to compare

@github-actions github-actions released this 31 Oct 21:16
v0.1.17
5d3b8d2

What's Changed

Changed

  • Redundant parentheses around atoms are gone. A two-step load used to render as mem((local_m10), 0x17); it now reads mem(local_m10, 0x17). The root cause was two defects stacked in the register-substitution path: every replacement was wrapped in parentheses unconditionally, and the "pure alias, skip the substitution" heuristic split candidate text on non-alphanumeric characters — so local_m10's underscore made it count as two tokens and, unlike x0, it took the substitution path and the parentheses.

    Atoms are now recognised by shape and left bare: a bare identifier, and a single postfix call (mem(x0, 7), mem(mem(x, 7), 0xf)). Everything else keeps its parentheses, because precedence can change the parse — f(a) + b, f(a) * 2 and f(a).b all still get wrapped.

    // before
    x0 = (mem((mem((local_m10), 0x17)), 0xf)) >> 1; // 0x480910
    // after
    x0 = mem(mem(local_m10, 0x17), 0xf) >> 1; // 0x480910

    Measured on full exports against v0.1.16:

    corpus mem(( ((mem parenthesised local
    sample_arm64 2 723 → 898 2 144 → 413 1 814 → 0
    Reqable (compressed-pointer Android) 71 947 → 39 769 50 782 → 11 512 6 324 → 0

    The parentheses that remain are the ones that carry meaning (mem((x0 + (x1 << 3)), 0xf) and (a >> b) & c compositions).

Notes

  • No semantic change. Instruction-address sequences are identical file by file (sample_arm64 15/15 files / 41 634 addresses; Reqable 1 734/1 734 / 1 122 366), and block and statement counts are unchanged on both.
  • Verification: 80 tests / 0 failed (default features), 52 / 0 with --no-default-features, clippy 0, regress_all 25/25, check_profiles 47/47, full_scorecard 26 samples / 24 497 functions / 0 dart analyze errors, and 0 dart analyze errors on the full 2.98 M-line Reqable output as well.
  • A unit test pins both directions: six atoms stay bare, and eight shapes that must keep their parentheses do keep them.

Full Changelog: v0.1.16...v0.1.17

v0.1.16

Choose a tag to compare

@github-actions github-actions released this 31 Oct 15:02
v0.1.16
d17c2aa

What's Changed

Fixed

  • publish.yml was left on Node 20 action runtimes. The v0.1.14 action bump only touched release.yml, so this workflow still used actions/checkout@v4 and actions-rust-lang/setup-rust-toolchain@v1 — the exact lines GitHub is force-running on Node 24 with a deprecation warning. Both now match release.yml: checkout@v7, setup-rust-toolchain@v2 with build-warnings: deny (v2 drops v1's default RUSTFLAGS=-D warnings, and cargo publish builds the crate locally, so that flag would otherwise have been lost here too). Found by auditing every workflow rather than the one being edited.

Changed

  • Dependency audit, no upgrades needed. serde 1.0.229, serde_json 1.0.154, mimalloc 0.1.52, clap 4.6.7 and capstone 0.14.0 are each already at their latest stable release on crates.io, and cargo update reports nothing left to move. Cargo.lock is unchanged in this release.

Notes

  • No exported artifact changed. dart/, asm/, ide/r2 scripts, text/ dumps and the call graph are byte-identical to v0.1.15 for the same input.
  • Verification on the tagged tree: 79 tests / 0 failed (default features), 52 / 0 with --no-default-features, clippy 0, regress_all 25/25, check_profiles 47/47 (incl. 21 compressed variants), full_scorecard 26 samples / 291 files / 24 497 functions / 0 dart analyze errors.
  • Four real Android apps re-tested end to end — Reqable 3.3.4, Lark 3.6.1, ChatGLM 3.11.6, Weibo 2.19.6: all export with 0 dart analyze errors and 0 non-ASCII artifacts, and their function/naming counts match the recorded baselines exactly.

Full Changelog: v0.1.15...v0.1.16

v0.1.15

Choose a tag to compare

@github-actions github-actions released this 30 Oct 06:13
v0.1.15
213cd0e

一处改动:大立即数重新用十六进制渲染。

缺陷

v0.1.14 把 capstone 升到 0.14 后,它把 orr Xd, xzr, #imm 规范成 mov Xd, #imm。这去掉了一层无意义的 xzr |,但同时暴露了 Expr::Imm 是 format!("{v}")——纯十进制:

// v0.1.13
x2 = xzr | 0x3fffffff;
// v0.1.14(修掉了 OR,但变成十进制)
x2 = 1073741823;
// v0.1.15
x2 = 0x3fffffff;

在这个产物里,地址、位移、对象池偏移全都是十六进制,唯独立即数是十进制——而逆向读者恰恰读不出十进制位型。

阈值 0x100 是量出来的,不是拍脑袋

抽样 sample_arm64 的立即数分布:

  • ≥ 256 的全部是位型/掩码/码点:0xdc00、0xfffd、0xffff、0x7ffff、0x3fffffff、0x7fffffffffffffff;
  • < 256 的全部是 0..11 这类计数;
  • 0x100–0xfff 这一带几乎是一条步长 8 的等差数列:0x107、0x10f、0x117 … 0x407——字段偏移,正是最该用十六进制的值。

负数保持十进制,无论多大:Rust 的 {:#x} 对带符号整数印的是补码,-4096 会变成 0xfffffffffffff000——那不是更精确,是换了一种误导。

规则只写在 imm_text() 一处,两个渲染点(Expr::text 与发射时的折枝路径)共用。各写一遍就只会改一处,本仓库在 edges_resolved 上已经吃过这个亏。

影响面

sample_arm64 181 处、Reqable 104 812 处:

x17 = 15776;   →  x17 = 0x3da0;
x17 = 524256;  →  x17 = 0x7ffe0;
x2  = 1073741823; →  x2 = 0x3fffffff;

只有 dart/ 变(Reqable 1734 个文件里 227 个受影响),asm/ 不走这个渲染器。

验证(就在打 tag 的这棵树上)

地址序列改前改后逐一一对一:sample_arm64 15/15 文件、41 634 条;Reqable 1734/1734 文件、1 122 366 条。79 测试 + 52 个 --no-default-features 测试全绿、clippy 0、regress_all 25/25、check_profiles 47/47、full_scorecard 26 样本 / 291 文件 / 24 497 函数 / dart analyze 0 错误;sample_arm64 与 298 万行的 Reqable 全量产物 dart analyze 均 0 错误。

一条测量记录:中途有一次 regress_all 报 19 个失败,是假警报——那次跑的是 cargo test --no-default-features 留下的二进制(没有 asm feature,不产出 asm/)。先用默认 features 重建再跑就是 25/25。同一个坑本仓库踩过不止一次,已在 memory 里标为「跑产物门禁前必须先确认二进制是默认构建」。

顺带说明:cure 0.3.1 的 Dart 后端(本版无代码改动)

ejfkdev/cure 现在有 Dart 后端了。实测:它能完整解析 dae 的方言(sample_arm64 15/15、Reqable 1734/1734 文件,0 解析错误),行尾 // 0xADDR 地址注释一处不少且地址序列逐一一对一,dart analyze 在两份产物上都是 0 错误,幂等(二次运行 0 次编辑),Reqable 298 万行只要 2.0 秒;实际应用了 paren_removal、const_fold、assign_compound、else_after_terminal、empty_then 等规则,结构节点 −1.1%。

但它会重排格式:超过行宽的语句会把行尾地址注释折到下一行(+0.2% 语句),于是「一行 = 一条语句 + 它的地址」这个形状不再成立——而 dae 的多条门禁与 25 份 regress 存档都建立在这个形状上。所以它没有接进导出流水线,保持为一个可选的外部后处理:

dae decompile app.so -o out
cure --lang dart -o out-cured out/dart   # 可选

v0.1.14

Choose a tag to compare

@github-actions github-actions released this 25 Oct 05:42
v0.1.14
5532dcd

维护版:依赖与 CI 升级。只有一处用户可见的改进,来自更新的反汇编器。

1. capstone 0.12 → 0.14:arm64 不再产出无意义表达式

先查了它到底影响哪里:dae 只用 mnemonic() / op_str() / address() / bytes() 加 disasm_all / disasm_count,并且是 detail(false),从没调过 insn_detail() / arch_detail() / operands()。所以 0.14 的破坏性变更(RegAccessType→AccessType、regs_read 返回值变多、Insn Display 去掉尾空格)碰不到这份代码。

真正变的是内置的 capstone C 库,而它在 arm64 上是净收益:新解码器把 orr Xd, xzr, #imm 规范成 mov Xd, #imm,于是伪代码不再输出没有意义的表达式:

-  x2 = xzr | 0x3fffffff;   // orr x2, xzr, #0x3fffffff
+  x2 = 1073741823;          // mov x2, #0x3fffffff
-  x1 = xzr | 0xfffffffffffffffe;
+  x1 = -2;

实测(与已发布的 v0.1.13 二进制做全量导出 diff -rq):

语料 变化文件 方向
sample_arm64(macho arm64) 5 / 33,全在 dart/ 89 处 orr → mov
h212keep(elf arm64) 8 / 35,全在 dart/ 122 处 orr → mov;另有 raw 反汇编块不再在 0x00000000 处只吐一条 .byte 就停,而是按 udf #0 继续解码
hello_3.12.2(x64) 0 / 32 x64 完全不受影响
Reqable(压缩指针安卓) 68 / 3471(asm/ 31 + dart/ 37) 同一方向;语句数 2 978 220 → 2 978 219(一条立即数被折进使用处)

没有任何退步:unmapped 在所有语料上仍是 0;其余摘要数字逐一相同(h212keep 两版都是 1259 函数 / 17087 块 / 82634 语句 / 964 structured / 295 unstructured);全部语料含 Reqable 的 dart analyze 0 错误;regress_all 25/25(存档里是 text/、ida_script/、r2_script/、frida.js、callgraph.dot,都不来自反汇编器);full_scorecard 0 错误;78 + 52 测试全绿、clippy 0。

cargo update 顺带取回补丁级更新(serde_json 1.0.151 → 1.0.154、cc / indexmap / libc / syn / unicode-ident,新增 foldhash)。serde、mimalloc、clap 本来就是最新。

二进制体积因此涨了约 1 MB(6 个资产各自从 12.3–14.7 MB 涨到 13.5–15.7 MB,UPX 压过的两个从 2.4/2.0 MB 涨到 2.5/2.1 MB)——来自 capstone 0.14 更大的 C 库。

2. CI:四个 action 全部落后一个大版本

每次发版的日志都在告警:

Node.js 20 is deprecated. The following actions target Node.js 20 but are being
forced to run on Node.js 24: actions/checkout@v4, crazy-max/ghaction-upx@v3,
softprops/action-gh-release@v2.

已升:checkout v4 → v7、ghaction-upx v3 → v4、action-gh-release v2 → v3、setup-rust-toolchain v1 → v2。每个都先查了破坏性变更再升:

  • checkout v7——那一线的破坏性变更是 pull_request_target 的 allow-unsafe-pr-checkout;本工作流由 tag 推送触发、用 fetch-depth: 0,不涉及。(该变更也回移到了 v4 线,所以原地不动同样躲不过。)
  • ghaction-upx v4——只有运行时/ESM 依赖升级,files / file / args / version / install-only 五个输入在两个 ref 上逐个比对过、名称未变。这是最需要盯的一个:files: 必须精确指向产物本体(曾经用 dae* 通配吞掉 dae.d 导致流水线失败;而压错文件会静默发出 12 MB 的未压缩资产)。
  • action-gh-release v3——仅 Node 20 → 24 运行时,输入未变。
  • setup-rust-toolchain v2——这一项会悄悄少掉一道守护:v1 默认注入 RUSTFLAGS=-D warnings,v2 改成依赖 cargo 1.97+ 的 build.warnings。两处调用都已显式写 build-warnings: deny,把「出现新警告就让 CI 红」保住。

本版即是这次升级的验证——工作流只在打 tag 时运行。结果是 6 个 build + publish-crates 全绿、Node 20 警告消失、UPX 两个资产仍是 2.5 / 2.1 MB。

3. members 的库筛选不作用于字段,改成在运行时说一声

dae members --lib dart_core 返回 411 个 dart_core 的方法加上全部 60 个字段(跨所有库),两种行在输出里长得一模一样。不对称本身是有意的——字段走 field_rows(),快照的 Field 记录只有类/名/偏移、不带库归属,所以 --lib / --exclude-lib / --no-sdk / --app 对它无从生效;dae help members 里也写了。但帮助只在被问到时才看到,所以现在恰好在该情形下往 stderr 说一声:

dae: note -- library filters apply to methods only; the 60 matched fields are
unfiltered (Field records carry no library attribution)

措辞讲「命中的字段数」而不是「上面的行」,因为默认 -n 200 时字段行可能被全部截掉,而摘要里那 60 个字段同样是未筛的。只走 stderr,stdout 仍是干净的数据通道。门禁 members_lib_filter_note_goes_to_stderr 断言「有筛选才出现 / 无筛选不出现 / --field --no-sdk 也出现 / 只在 stderr」,并带防空过断言。已负测。

验证(就在打 tag 的这棵树上)

默认 features 78 passed / 0 failed、--no-default-features 52 passed / 0 failed / 0 warning、clippy 0、full_scorecard 26 样本 / 291 文件 / 24 497 函数 / dart analyze 0 错误、regress_all 25/25、check_profiles 47/47(含 21 份压缩变体)。

v0.1.13

Choose a tag to compare

@github-actions github-actions released this 04 Oct 00:16
v0.1.13
9f65eea

命令行帮助专版。导出产物零变化:sample_arm64(macho arm64)、hello_3.12.2(macho x64)、h212keep(elf arm64)与 Reqable(压缩指针安卓)四份语料的全量导出,与从发布页下载的 v0.1.12 二进制逐字节一致。

1. dae <命令> -h 对全部 22 条命令都是坏的

$ dae libs -h
error: usage error (`dae help` lists every command and option)
error: the following required arguments were not provided:
  <BINARY>

Usage: dae libs --help <BINARY> [PATTERN]
$ echo $?
2

零 stdout、退出码 2。根因:clap 的必填位置参数校验发生在解析阶段、早于 handler,所以 -h 这个 flag 永远轮不到执行。

而 dae help libs 一直是好的——因为 help 自己没有必填位置参数。这正是它能发布出去的原因:唯一覆盖「每条命令的帮助」的门禁跑的是 help "$c"(它的注释还写着「每条命令的 -h 都要有内容」),而末尾那条真的跑 <cmd> -h 的 cmp_one 总是把位置参数一起给全,于是「缺位置参数时 -h 失效」这个对 22 条命令都成立的缺陷正好从两个漏洞之间漏了过去。

修法:位置参数一律声明成 Option<String>,由 handler 侧的 need() 校验,报双语用法错误、退出码 2。顺带消掉上面那条更难看的诊断——clap 把我们的 -h 当成一个名叫 help 的普通 flag,于是它生成的 usage 行印成 dae libs --help <BINARY> [PATTERN],看起来像 --help 是必填项。

⚠️ 改成 Option 之后必须自己补校验,否则漏参数会静默变成空结果;已用 missing_positional_still_parses_but_is_incomplete 钉住。

2. 顶层帮助此前有两份

main.rs 里有一份 50 行的 print_help(无参数 / -h / --help 走它),cli.rs::help 里另有一份 64 行的指南(dae help 走它)。完整的子命令表只在后者里,所以用户按 -h 看不到命令清单。print_help 已删除,四种形态现在打印同一份文本(门禁断言逐字节相同)。

这与 edges_resolved 那次是同一个形状:同一份东西写两遍,就只会更新一遍。

3. 退出码的两处更正

  • 无参数:2 → 0。它不是一个失败的调用,而是「我想知道怎么用」,与 -h 语义相同。
  • dae help <不存在的命令>:0 → 2。此前它走 help_for 的 _ => 兜底臂、把整份指南打出来并返回 0,于是 dae help libss 看起来像成功了——拼写错误被藏起来。现在报用法错误、列出 22 个有效命令名、stdout 为空。

4. 文案

按 man-page 体例重写分节:USAGE / ARGUMENTS / COMMANDS / OPTIONS / OUTPUT / NAMING / EXIT STATUS / EXAMPLES(中文:用法 / 参数 / 命令 / 选项 / 输出 / 命名口径 / 退出码 / 示例)。分组名去掉口语(get oriented → Overview、find things → Search、decompile one → Decompilation),逐条命令的说明同样书面化。

顺带修掉两个表现层缺陷:帮助文本里有 33 行 markdown **(终端不渲染,只是噪声)、12 行把制表符印成两个字符 \t;fields 那条还混用了真 tab 转义,于是同一份帮助里同一个意思有两种写法。现在统一成「列(制表符分隔):a, b, c」。

用法行两种语言都保持 ASCII:SYNOPSIS 按 man-page 惯例不翻译。翻成 [选项] 会让 {:<N} 的补宽在终端里对不齐——它按字符数补,而 CJK 是双宽。英文最长行 117 → 100 列(export 那条命令串曾 42 字符撞穿 40 列补宽、与说明粘连)。

$ dae help
dae v0.1.13 -- static exporter of Dart AOT snapshot debug information
Supports Dart 2.7-3.14b; containers Mach-O, ELF and PE; architectures x64 and arm64.
https://github.com/ejfkdev/dae

USAGE
  dae <binary> <out_dir> [options]        export all artifacts (shortcut form)
  dae export <binary> <out_dir> [options] export all artifacts (explicit form; equivalent)
  dae <command> <binary> [arguments]      run one query or decompilation command
  dae help [command]                      print this text, or the help of one command
  dae version                             print the version

  Running dae with no argument prints this text. Every command accepts -h and --help.
...
COMMANDS
  Overview
    dae info      <binary>                      snapshot, SDK and size summary
    dae libs      <binary> [pattern]            libraries with class and function counts
    ...

5. README 的命令表已经漂移,而且漂成了一个已知为假的说法

README 里内嵌了一份命令表副本,其中 stubs 一行写着 "instruction-table entries with no Code object"——那是 v0.1.12 已经在四处改正过的假说法(dae 算的是「没有被任何 Function 对象引用」的补集,从不查 Code 对象;而且它不是前缀)。当时中文 README 改了、英文这份副本漏了,于是发布出去的文档里留着一个已经定性为错误的说法。

两份 README 的命令表现在直接由 dae help 的 COMMANDS 一节生成,并加了门禁 readme_command_table_matches_help 逐字节比对——副本不能再自己漂移。

门禁(三条,都已负测)

门禁 盯什么 负测方式
help_flag_parses_without_positionals(单元) 22 条命令 × -h/--help 在没有位置参数时必须解析成功且带出 help 标记 给 Query.binary 加 #[arg(required = true)](类型不变,只让 clap 层面必填)⇒ 两条测试报红
help_is_consistent_and_lists_every_command(集成,不吃语料) 四种顶层形态逐字节相同且 rc=0;66 种逐命令形态逐字节相同且 rc=0;顶层帮助逐条列出 22 个命令名;未知命令 rc=2 且 stdout 为空;帮助里不许出现 ** 与字面量 \t;中英各跑一遍 把无参数改回 exit(2) ⇒ 报红
readme_command_table_matches_help 两份 README 的命令表 == dae help 的对应一节 篡改表中一行 ⇒ 报红

它的 help_flag() 辅助函数故意不写 _ => 兜底:将来新增一条命令而忘了给它 help 标记,会直接编译不过,而不是让测试静默放过。

集成门禁不依赖语料这一点是刻意的:旧的 help 断言嵌在 progressive_cli 里,而那条整体挂在 testing/decompiler_corpus/ 的存在性上——新克隆里它直接跳过。

scripts/cmp_cli.sh 里那段也改了:现在真的跑 <cmd> -h 与 <cmd> --help、不给位置参数、覆盖 22 条命令、比退出码与逐字节一致性(3/3 通过)。

⚠️ 做第一条负测时我自己犯了一个错,记在这里:第一版负测把字段类型改回 String,结果连编译都过不了(别的单元测试在用 .unwrap()/.as_deref()),cargo test 因此一行 test result 都没打;而我把同一条命令链里还原之后那次成功的输出误读成了负测结果,得出「负测没报红」的错误结论。⇒ 看测试输出要确认它是哪一条命令产出的。

验证(就在打 tag 的这棵树上)

默认 features 77 passed / 0 failed、--no-default-features 51 passed / 0 failed / 0 warning、clippy 0、full_scorecard 26 样本 / 291 文件 / 24497 函数 / dart analyze 0 错误、regress_all 25/25、check_profiles 47/47(含 21 份压缩变体)。

产物侧:四份语料的全量导出与已发布的 v0.1.12 二进制逐字节一致,stdout 摘要只差输出目录名——帮助是纯 CLI 层。

v0.1.12

Choose a tag to compare

@github-actions github-actions released this 02 Oct 13:09
v0.1.12
6ac9b08

这一版是正确性专版:修掉五个缺陷,每一个都配了门禁、且每条门禁都做过负测;另外查出一个把指标灌水一倍的统计 bug。没有新功能。

1. 有名字没函数体(影响面最大)

code_size 里还留着旧的 idx < first_entry 守卫,于是此前那次「恢复函数名」的修复只做了一半:entry_for 放行了这些下标(名字与入口地址回到了 functions.txt),而 code_size 对它们返回 0 ⇒ code_range 因 size <= eo 返回 None ⇒ 函数体一条指令也没反汇编、没反编译。

指令表里 first_entry_with_code 之前的条目并不是没有代码——是它们的 Code 对象被丢弃了(SDK app_snapshot.cc 写入侧断言 !IsDiscarded || not_discarded_count == 0,所以丢弃的全排在前面;读取侧对 code_index < first_entry_with_code 照样返回入口点,只把 Code 换成 StubCode::UnknownDartCode())。字节还在,相邻 pc_offset 之差照样是它的长度。

同一个缺陷的第二半:「下一条」不等于「下一个不同的 offset」。Dart 2.12–2.15 会合并字节相同的 Instructions,于是连续多个表条目共享同一个 pc_offset,只有 run 的最后一条能算出长度。实测 hello_2.12.4:174 个 0 增量、最长 run 16、73 个地址被 2..16 个函数共享——而共享者语义上就是同一个函数体(9 个 get_elementSizeInBytes、16 个布尔开关 getter、9 个错误类 ctor),所以去重是产物的事实,不是解码错位。2.16.2 起 0 增量个数为 0,故对那些版本本改动恒等。

影响面(idx < first_entry / 函数总数):Reqable 11207/13371 = 83.8%、飞书 19921/25183 = 79.1%。

⚠️ 26 份桌面语料与全部 25 份 regress 存档的 first_entry 都是 0,守卫从不触发,所以没有任何既有门禁能看见这个缺陷——与「语料全是 no-dwarf 所以地址错位测不出」是同一类盲区。新增的 tests/code_coverage.rs 直接断言孤儿数为 0,并自带负对照(一种门禁有两种失效模式时,每个对照只能含一个,否则归因会串)。

2. 压缩指针构建整体错位 8 字节

SDK runtime/vm/thread.h 里 heap_base_ 是 Thread 中唯一被 #if defined(DART_COMPRESSED_POINTERS) 包着的条件字段,而 profiles/struct/ 下 48 份头文件对此不一致(2.13.4–2.19.6 的 14 份已含,其余 34 份没有)。dae 原样把它们发给 IDA/r2 当结构体、并用它们查 stub 命名,于是每一个压缩指针目标——也就是每一个移动端 Flutter 产物——从 write_barrier_mask 之后整体错位 8 字节。

 __int64 write_barrier_mask;
+__int64 heap_base;          // ← 压缩构建里必须在这一点插入
 __int64 top;

连带后果:本次开发早先给 Reqable / 飞书发出的 ArrayWriteBarrierStub_* 是编造的名字,真名是 WriteBarrierStub_*。三处代码实测钉死了修复(Reqable 3.3.4:stack_limit 0x38 / top 0x50 / write_barrier_entry_point 0x1e8 全部对得上)。

这个错误能存活,是因为我最早验的两份语料恰好都是对的(material_3_demo 非压缩;微博的头本就含 heap_base)。修完之后这两份的具名数一动没动——这是幂等的证据——而 Reqable 31625→40548、飞书 36622→43182、ChatGLM 127663→142415。

通用教训:任何 per-version 布局表都必须拿一个「目标代码自己写出来的偏移」对账。最便宜的锚点是栈溢出守卫里的 stack_limit。

3. arm64 的 CODE_REG 标在了错的寄存器上

平台 profile 的 register_aliases 把 CODE_REG 标在 x23,而同一份 profile 的 registers.code_reg 写的是 x24。SDK constants_arm64.h 从 2.12.4 到 3.13.0 每一版都是 const Register CODE_REG = R24;,R23 只是 kAbiPreservedCpuRegs 里一个没有名字角色的普通被保留寄存器。渲染用的是别名表,所以每一份 arm64 产物都在错标:material_3_demo 实测 asm/ 里 1010 处、dart/ 里 3014 处把 x23 印成 CODE_REG,同时真正的 CODE_REG(x24)被印成裸寄存器(559 / 2834 处)。顺带删掉同样没有依据的 x18: ARG2 别名。

4. 空的 if 在静默丢控制流边

if (x1 >= x0) {
}
x0 = local_m18; // 0x480ab0

机器码是 cmp x1, x0; b.hs 0x480afc,而 0x480afc(RangeErrorSharedWithoutFpuRegsStub)就在同一个文件里、挂在另一条分支下。产物等于在说「x1 >= x0 时什么都不发生」——假的,而且被丢掉的那一支上还可能带着 store/call 这类有副作用的语句。修复前实测:sample_arm64 109 处、h212keep 1596 处、五份真实应用合计 9817 处。

根因不是靠读产物找到的(两种情形在文本上一模一样),而是给 6 个 Node::If 构造点加临时插桩、按代码路径归类:seq 返回空有两种完全不同的原因——① 目标就是区域终点,它的代码紧接着 if 发射,留空是对的;② 目标已发射过(共享块)或在区域外,那一支的语句被整段跳过。109 处的分布是 52 / 39(其中 37 处 stop == ti)/ 14 / 4。

修法是三档,按「能证明的优先」:目标就是紧随其后的块 ⇒ 留空;目标是共享块且到汇合点是直线段 ⇒ 尾复制回来(dup_to_join,既有 dup_tail 的姊妹,IDA/LLVM 对共享尾块同样做复制,函数仍算 structured);抄不了 ⇒ 如实写 gotoLabel(0x<目标>)(地址取自指令表=事实,纪律同 RuntimeCallStub_0x…:保留地址而不编 entry 名)。外加一次真结构化:terminates(ti) && stop == ti && terminates(fi) 时两支同归,改成镜像发射。

if (x1 >= x0) {
  // duplicated branch body (target 0x480afc terminates; the same code is emitted below)
  RangeErrorSharedWithoutFpuRegsStub_0x4c3f80() /* 0x4c3f80 */; // 0x480afc
}

三个容易做错的点:镜像支必须带 terminates(fi)(走到那支说明 find_join 返回 None,即两支无共同后继,「同归 stop」并不自动成立,否则会把一条二进制里不存在的边写进产物);不可归约支的 fallthrough 是 None(它发完 if 紧接着是假支的 goto,档位①前提不成立);空的 els 也要补(只补 then 的第一版在 h212keep 留下 483 处沉默)。

语料 / 应用 无 else 空 if 结构化率 dart/ 字节
sample_arm64 109 → 5 90.21% → 90.04% +0.5%
h212keep (elf arm64) 1596 → 737 88.40% → 76.57% +2.8%
material_3_demo 1929 → 62 92.47% → 91.96% —
Reqable 504 → 2 97.14% → 96.97% —
飞书 1203 → 15 94.79% → 94.48% —
微博 2972 → 67 91.08% → 90.23% —
ChatGLM 3209 → 70 91.95% → 91.48% —

结构化率下降是「重新分类」,不是退化:Node::Goto 会把整个函数记成 unstructured,而那些函数过去被算作 structured,靠的正是把这条边藏起来。只用 goto 兜底时 h212keep 会掉到 61.2%、撞穿 0.70 门禁;是尾复制把它买回 76.6% 的,所以门禁下限没有下调。残留 5 处逐一对照 raw 反汇编证明是对的:3 处是 ti == fi(b.eq #0x4b10e0 而下一条指令就是 0x4b10e0,两支同归、if 本就是内联后剩下的空操作),2 处是外层 if 的档位①。

5. 两处「说法与事实不符」

  • edges_resolved 报 94.7%,真值是 46.6%——sub_0x 占位名被当成了名字。同一个数字此前已在反编译器侧修过(7ea269a),这边没修:同一逻辑写两份,就只会修一份。另外 call_edges.txt 的命名函数只调 alloc_stub_name,所以 RuntimeCallStub 的名字从没进过它。
  • text/stubs.txt 的表头一直写「without a Code object (stub prefix)」,两半都错:dae 算的是「没有被任何 Function 对象引用」的补集、从不查 Code 对象;而且它不是前缀(Reqable 有 7798 条下标 ≥ first_entry_with_code,同时 9530 个已命名函数的下标 < 它)。这句话发布在四个地方(文件头、导出摘要、dae help stubs、中英 README),四处都已改成如实说法。

具名直接调用的总进展

material_3_demo:40485(46.6%)→ 53909(RuntimeCallStub)→ 58478(写屏障)→ 69796(CODE_REG 身份)→ 77071 / 86825 = 88.8%;微博 108194 / 123659 = 87.5%。

性能

修 stub 命名时一度让导出慢 11–25 倍(飞书 4.83 → 119.6 s),而 71 个测试 + regress 25/25 + scorecard 全绿——根因是 stub_entry_size 每地址全表线扫(O(n²),飞书约 47 亿次)加 disasm_all 每地址最多解码 4 KiB。这套测试对性能零覆盖。 换成预建有序索引二分 + disasm_count(.., 64) 之后,飞书 2.68 s、Reqable 2.38 s,都快过命名工作开始前的基线,且产物逐字节一致。

下面每个数字都是本版二进制交替 A/B 三轮的中位数(单次墙钟在本项目能摆动 ±35%):--decompile 在 material_3_demo 0.82 s、微博 1.25 s、ChatGLM 2.00 s、Reqable 2.64 s、飞书 2.91 s,峰值 RSS 151–834 MB。第 4 项的代价是最大那份语料约 3%、其余在噪声内。

--no-default-features 此前根本编译不过

tests/field_names.rs 与 tests/source_truth.rs 无条件引用 dae::decompiler,而该模块只在 asm feature 下存在——于是这个配置下所有其它问题都被挡在第一个报错后面。修好编译后又冒出 16 个失败,全是在这个配置产不出的反编译产物上做断言。现在默认 73 passed / 0 failed / clippy 0,no-asm 47 passed / 0 failed / 0 warning,二进制仍正常导出。没人跑的配置会静默腐烂,而腐烂藏在第一个报错后面。

门禁

新增 tests/code_coverage.rs(孤儿函数体,自带负对照)、tests/stub_names.rs(29 份语料跨版本编造扫描,从 dae disasm 文本独立重推)。两条既有棘轮重基并各自负测:

  • empty_if_without_else_does_not_grow:上限 109 → 5,并新增尾复制数下限 40(实测 85),防「一次重构把三档静默退化成一律留空、数字看起来没变」。负测:把 dup_to_join 改成 return None ⇒ 85→25 触下限;把 goto_if_empty 改成空操作 ⇒ 尾复制不变而无 else 空 if 5→43 触上限。
  • post_index_stack_slots_do_not_regress:判据改成按 (文件, 机器地址) 去重,942 → 926,base 与本版都给 926(裸计数分别 942 / 943)。多出来那次是既有语句的副本,不是命名退步——计数棘轮会被「同一条语句多抄一遍」推动,不改判据就得每次重基。另加下限 500 防空过。

本版验证(就在打 tag 的这棵树上)

73 测试 / 0 失败、clippy 0、full_scorecard 26 样本 / 291 文件 / 24497 函数 / dart analyze 0 错误、regress_all 25/25、check_profiles 47/47(含 21 份压缩变体)、五份真实应用各 0 analyze 错误、14797 个产物文件零非 ASCII。

发版前另拿 v0.1.11 的 worktree 二进制做全量导出 diff -rq 对账(三份语料):没有任何文件新增或消失;桌面语料只有 dart/、text/call_edges.txt、text/stubs.txt、callgraph.dot 变化;移动端另有 asm/、IDA 脚本、两份结构头各 +1 行 heap_base;三份语料的 text/fields.txt 全部逐字节相同(访问器推断内部会调 lift,所以这一项必须单独比)。

已知未做(理由都写进了 docs)

  • 移动端构建里未被任何 Function 引用的指令表条目中,有一大半是普通函数体(Reqable 24932 条 / 8.09 MB、飞书 43195 条 / 14.67 MB,都以标准 EnterFrame 开头)。不修:没有 Function 对象就没有名字/库/类,只能以 sub_0x… 发射且不归属任何库,而那会动到「保证并行反编译逐字节一致」的那趟顺序预扫描;且「为什么没有 Function 对象」两种候选读法都未排除,命名即编造。dae disasm 0xADDR 今天就能看它们。
  • entry_point 层命名:「只有一个地址装载这个字段 ⇒ 它就是那个 stub」仍是归纳跳跃,判据同已撤回的 isSmi。

完整修复历史与取证过程见 docs/DECOMPILER.zh.md。

v0.1.11

Choose a tag to compare

@github-actions github-actions released this 28 Sep 16:23
v0.1.11
ffe8487

修复循环头栈溢出守卫被整条丢弃(arm64)

这一版只有一处代码改动,但它修的是控制流语义:产物此前会让读者误判函数在每次循环迭代都做了栈检查。

缺陷

Dart 把栈溢出检查放在循环头,而真正的循环条件在下一个块:

块10(循环头): ldr BARRIER,[THR,#0x48]; cmp SP,BARRIER; b.ls <handler>   ← 守卫
块11:           cmp r1, #4; b.ge <exit>                                  ← 循环条件
0x4bbdec:       b 0x4bbdac                                               ← 回边指向循环头

loop_shape 的兜底臂返回 succ(h, 0),也就是分支目标,于是 out-of-line 的溢出处理块被当成了循环体入口。产物变成:

改前:  while (true) {
         BARRIER = mem(THR, 0x48); // 0x4bbdac
         sub_0x4c3c40();           // 0x4bbe30     ← 每圈无条件调用溢出 stub
         if (x1 >= 4) { break; }

两条语句地址相差 0x64,正是「把远端处理块内联到了加载后面」的痕迹;守卫的 if 因为循环头路径 continue 跳过整个分支处理而彻底消失。溢出 stub 于是从「仅 SP <= BARRIER 时调用」变成「每圈无条件调用」。

改后:  while (true) {
         BARRIER = mem(THR, 0x48); // 0x4bbdac
         if (SP <= BARRIER) {
           sub_0x4c3c40(); // 0x4bbe30
         }
         if (x1 >= 4) { break; }

判别依据

关键是区分「头块的分支是循环条件」与「头块的分支只是守卫」。用的是侧块的形状,不是循环归属:溢出处理块的形态是 bl <stub>; b <落空块>,即它的无条件跳转目标正好等于头块的落空后继(is_rejoin_side_block)。成立时头块的分支就是守卫,于是兜底臂改为从落空边进入循环体,并在 body 顶部把守卫补发成 if。

第一版用「分支目标在循环外」判别,失败了:处理块 b 回循环内,被循环检测标成 in_loop,判据恒假;结果它在别处挪动了 15 个 if 而目标缺陷一点没修,已完整撤回(撤回后 material_3_demo 1011 个文件与改动前逐字节一致)。教训写进了 docs/DECOMPILER.md:结构化率 7 语料全不变 + 所有门禁全绿,仍不足以说明改动是对的——必须直接去看目标实例的产物。

验证

项 结果
sample_arm64 无守卫处 113 → 0(有守卫 758 → 875,if ( 5445 → 5562)
Reqable(arm64 真机商业应用) 守卫 1218 处 / 无守卫 0 处(改前是 1149 / 69,69 处全部补回,与独立审计的数字精确吻合)
结构化率 7 语料 逐一完全不变:1060/115、1047/127、1051/116、1063/156、13947/1135、1716/92、1073/115
dart analyze material_3_demo 全量 0 错误、Reqable 全量 0 错误、T4_blank(真机安卓、压缩指针)0 错误
非 dart/ 产物 逐字节一致
性能 material_3_demo 带 --decompile 0.84–0.85 s(v0.1.10 为 1.09–1.22 s)、不带 0.45–0.47 s
门禁 65 测试全绿、full_scorecard 26 样本 / 291 文件 / 24 253 函数 / 0 错误、regress_all 25/25、check_profiles 47/47、clippy 0

棘轮门禁 stack_check_guards_do_not_regress 的上限已收到 0,从此强制保持。

另得到一个否定结论:empty_if_without_else_does_not_grow 仍是 109、没有跟着下降,说明那 139 个「无 else 的空 if 丢分支边」与本次不同源,是另一个根因(已在文档中记录,含三个尚未试过的判别方向)。

发版前抽查

22 条子命令逐条冒烟测试全部 rc=0 且输出非空(arrays/maps 是刻意不提供的子命令——它们是 text/ 下的单列 dump,grep text/arrays.txt 就够,CLI 会把 dae arrays X 读成 dae <bin> <out> 快捷形并报「读不到名为 arrays 的文件」,这是正确行为)。

v0.1.10

Choose a tag to compare

@github-actions github-actions released this 28 Sep 13:05
v0.1.10
ffd2a11

修复五个「产物给出错误值」的缺陷,外加流式落盘与并行渲染

这一版的主线是正确性:五个缺陷都不是「少一行」,而是产物读起来会算错。全部由「拿源码对照产物」和「逐类审计真实应用」发现,既有门禁一个都没报——产物照样过 dart analyze、结构化率不变。

正确性

  • arm64 cset/csetm 整条消失。 lift_one 用裸条件码拼 (ne) ? 1 : 0(非法 Dart),而 nest_block 对 Expr::Text 不做待定值替换、pending 又按目标寄存器建键,于是紧随的同寄存器赋值把它整条覆盖。净效果是静默的错误值:源码 int get rank => this == Level.low ? 0 : 1 被内联成 cmp; cset x2,ne; lsl x2,x2,#1,产物只剩 x2 = x2 << 1,而 x2 还是八条指令前的插值数组长度 4。修复后是 x2 = ((x1 != BARRIER) ? 1 : 0) << 1。另外 NEST_MAX_DEPTH 挡住折叠时改为落地而不是留在 pending 里等着被覆盖。
  • 寄存器名匹配退化成子串匹配,捏造出 ppmem(...) 并吞掉 1411 个 store。 Dart arm64 的池指针 PP 物理名是 x27,而位移文本 #0x27 里含子串 x27,于是 stur x17, [x3, #0x27] 被判成池加载:store 变成赋值、写操作彻底消失,且 Expr::Pool 渲染成 pp[0x27] 再经出口 sanitizer 变成凭空的标识符 ppmem(0x27)。诊断指纹是纯前缀相关:16 种偏移全以 0x27 开头、mem(..., 0x27*) 零幸存。改成词边界匹配后 1411 → 0,并顺带恢复了一批被假池索引挡住的字符串字面量。
  • tst 被渲染成相等比较,写屏障快慢路径语义反转。 tst a,b; b.eq 的真值是 (a & b) == 0,产物却写 BARRIER == HEAP——运行期两寄存器几乎不可能全等,等于宣称「每次都要过写屏障」;且第三段移位修饰 lsr #32 被整个丢掉。436 → 0,正确形态 1303 处。x86 的 test eax, 0x20 + je 同样中招。
  • wN 与 xN 被当成两个独立变量。 它们是同一物理寄存器的两个视图:写 wN 会清零 xN 高 32 位。两个方向都错过——写 wN 后读 xN 的陈旧读 3590 → 16;blr LR; tbz w0,#4 里的 w0 从未被赋值、条件在对 null 求值,这类 1690 → 0(位号 < 32 时 w/x 的第 k 位恒等,所以位测试直接用 64 位名是精确的,不需要掩码)。
  • raw 反汇编注释块越过函数边界:lift 有意多看 16 字节,stmts 一直按地址裁剪而 raw 漏了,于是每个函数尾部印上最多四条下一个函数的指令。裁剪后 dart/ 反而小 2.5–3.5%。
  • getclass/getmethod/decompile -o FILE.dart 命中多库时产物非法:逐库拼接前导声明会让 mem/memSet 等占位函数重复定义,Reqable 随机 100 个类里 45 个中招、2823 个 dart analyze 错误。现在按合并后的正文重算一份前导(只保留第一份不行:它会把别的库定义的函数声明成 dynamic,撞成同一个 duplicate_definition)。修复后 0 错误。
  • x86 adc/sbb 丢掉目标寄存器(渲染成裸调用,对目标的写消失);arm64 sbcs 被 x86 两操作数路径处理(丢掉第三个操作数、且目标兼作操作数)。

指令覆盖

x86 SSE 标量浮点 addsd/subsd/mulsd/divsd(含 ss)——x64 上所有 double/float 算术都走它,此前因为是两操作数形态而全部落成 // unmapped;另有 comisd/ucomisd 归入 cmp 族、cmov<cc>、arm64 cinc/cinv/cneg、inc/dec、cdq/cqo、x86 setcc、arm64 adcs/sbcs。

未映射行数:material_3_demo 3 → 0、T4_blank 34 → 9、hello_3.13.0 161 → 142(剩下 121 条是指令前缀 rep/std/cld/lock,正确修法是与后续指令合并成 memcpy 语义,而不是单独映射前缀;把它们改标成 note 能让数字掉 85% 而信息量为零,所以没做)。

性能

交替 A/B,material_3_demo(15 082 函数):--decompile 3.04 s → 1.09–1.22 s、峰值 RSS 181–200 → 178–184 MB;不带它 0.56–0.58 s → 0.55 s、RSS 139–142 → 124–130 MB。真机微博(9 MB、19 053 反编译函数 / 163 万语句)4.51 s / 251 MB → 2.12 s / 211 MB。

两处改动:产物流式落盘(asm 原本把每个库攒进一个容量低估约 2 倍的 String;render 原本一次返回全部 505 份文件共 63.2 MB),以及按库并行渲染。并行不改变产物一个字节——文件名与「每个入口地址归哪个库发射」都由一趟顺序预扫描先定死,1011 个文件在 1/8 线程下 diff -rq 完全相同。默认并发是 n_threads()(核数、上限 8),DAE_DEC_THREADS=N 可覆盖;在 6 性能核 + 12 能效核的机器上超过 8 线程反而更慢更费内存。

两处做了又撤回的改动

都记在 docs/DECOMPILER.md,因为它们比成功的那些更有信息量:

  • 把立即数字面量折进待定值:int - dynamic 的静态类型是 num,而 num 没有 <</&/|,直接打破 dart analyze。
  • 把 tbz xN, #0 还原成 isSmi(xN):依据是 profile 的 heap_object_tag/smi_mask,Reqable 上 1169+58 处、残留形态归零、analyze 0 错误、压缩指针安卓语料同样生效——每项指标都说成功。但 n.isEven ? 'even' : 'odd' 编译出来也是测第 0 位(操作数是未装箱 int),产物于是变成 if (isHeapObject(w1)) { "odd" } else { "even" } = 编造语义,比朴素但正确的 w1 & (1 << 0) != 0 更糟,而且只有对照源码才发现。判据由此明确:只有一对一的形态映射才叫还原;一个形态对应多个语义时,命名就是编造。

一处看起来像回归、其实是修复生效的地方

text/fields.txt 少了一行(634 → 633,_SyncStarIterator._current)。原因是访问器推断路径会跑完整的 lift,而它的健全性护栏是「恰好一个字段偏移」。那个 setter 有两处字段访问,第二处位移是 0x27——在旧版被上面的子串 bug 吞成池读取、不算字段访问,于是护栏通过并写出了那一行。子串 bug 修好后第二处被正确识别,护栏正确地拒绝推断。佐证是那个「setter」开头是两次加载而非 stur,根本不是朴素字段 setter 的形状。所以那一行是一个 bug 抵消了另一个 bug 的盲区才产出的。

验证

62 个测试全绿;full_scorecard 26 个样本 / 291 个文件 / 24 253 个函数,dart analyze 0 错误;regress_all 25/25;check_profiles 47/47(含 21 份压缩指针变体);clippy 0。Reqable 全量产物 1955 个文件同样 0 错误。

新增四条门禁,每条都用旧二进制负测过(证明不是空过):cset_instructions_materialize_as_ternaries(基线 8 指令 / 0 三元式 / 8 个函数不合格)、x86_setcc_materializes_as_ternary(基线 9 条全部 unmapped)、w_register_write_aliases_x_register(基线 290 处陈旧读)、no_register_substring_false_positives_in_output、bit_test_conditions_use_the_64bit_view。另加强了一条既有门禁:condflag_only_wraps_bare_condition_codes 原先只查「含空格或运算符」,放过了 condFlag("isSmi(w0)"),现在要求参数必须是 1–3 个纯小写字母的裸条件码——门禁判据要按形状写,不要按已见过的坏样子枚举。

dae v0.1.9: decompiler output that stopped lying by omission

Choose a tag to compare

@github-actions github-actions released this 28 Sep 00:15
v0.1.9
613c67d

Four defects, all found the same way: decompile our own example programs and read the result against the source. Every one was invisible to the existing gates — the output still passed dart analyze, structuring ratios and address self-consistency were unchanged, and the regression archives stayed byte-identical. Three of the four made the pseudocode omit something rather than say something wrong, which is the failure mode no validity check can catch.

1. Statements were silently discarded

nest_block folded register assignments into pending values, inlined them at their use sites, and landed the rest at block end. On notes and compares it did pending.clear() — threw them away — while calls, stores, branches and returns flushed them. push/pop are notes, and they are exactly where call-argument preparation ends.

On the x64 example corpus, fib compiles to:

mov rcx, rax      ; rcx = n
sub rcx, 1        ; rcx = n - 1
push rcx          ; argument
call fib

The first two folded into rcx = rax - 1 and were then discarded at the push. The decompiled body showed fib() with no argument and no line anywhere mentioning n - 1 — for a function whose entire meaning is recursing on n−1 and n−2. It did not count as unmapped either: the instruction was recognised, only its result was dropped.

Now flushed, matching every other barrier. Measured on a 15,082-function Flutter app: dart/ grows 1,998,350 → 2,165,737 lines (+8.4%), recovering parameter loads, argument setup and epilogues. fib now reads:

rax = mem(FP + 0x10); // 0x5e36e   ← the parameter n, previously absent
if (rax < 2) {
} else {
  rcx = rcx - 1; // 0x5e37f        ← fib(n-1)'s argument, previously absent
  fib() /* 0x5e35c */;
  rcx = rcx - 2; // 0x5e392        ← fib(n-2)'s argument, previously absent
  fib() /* 0x5e35c */;
  ...
}

DecompileStats did not move at all, because it is computed before nest_block — which is precisely why the run summary could not see this. A narrower variant (flush only on notes, +3.0% lines) was measured and rejected: it still dropped parameter loads cleared at a compare.

2. condFlag wrapped conditions that were already valid Dart

cbz/cbnz/tbz/tbnz build a complete boolean expression at lift time, but every branch then went through fold_cond, which matches on mnemonics and falls back to condFlag("{mnem}"). So a real condition came out as a string inside a placeholder that always returns false. From a purpose-built stress sample (switch + ternary):

// before                                     // after
if (condFlag("x2 == 0")) {                    if (x2 == 0) {
  x0 = "zero"; return x0; }                     x0 = "zero"; return x0; }
if (condFlag("w1 & (1 << 0) != 0")) {         if (w1 & (1 << 0) != 0) {
  x0 = "odd"; } else { x0 = "even"; }           x0 = "odd"; } else { x0 = "even"; }

The after column reads directly as the source's n.isEven ? 'even' : 'odd'. 14,886 → 2,841 occurrences; the remainder are genuine bare condition codes (vc 1782, vs 293, eq 162, ne 90, hs 5, lo 3), which do need the placeholder. Unrecognised bare tokens still go through fold_cond, so if (eq) can never reach the output.

3. Scoped decompiles lost cross-library call names

The entry→name map was built from the emission set, so --lib, --app, getclass, getmethod and getlib degraded every call into another library to sub_0x…. In testing_app (a Flutter sample whose source is in the repo), Favorites.remove is two lines:

void remove(int itemNo) {
  _favoriteItems.remove(itemNo);
  notifyListeners();
}

A full decompile rendered them correctly as GrowableList_remove() and ChangeNotifier_notifyListeners(). Under --lib testing_app the same two became sub_0x8a1b8() and sub_0x6d60() — the two calls that carry the method's entire meaning were the ones lost, and "just the app's own code" is what --app advertises. The names were always in the snapshot (dae callees resolved both), so this was a projection gap, not missing data. Named call targets in scoped output, measured on two independent artifacts: 26.6% → 54.0% on testing_app with --lib, and 26.9% → 42.9% (6,380 → 10,180 named calls) on a real 7.5 MB Android build with --app.

4. dae classes listed top-level functions as nameless classes

Each library's functions with no owning class were emitted as a row with an empty name and cid -. Empty sorts first, so dae classes x | head -1 | cut -f3 returned "" — and fed that empty string into whatever came next. Now skipped, with the count line stating how many were skipped and where they still appear (dae functions, dae members).

The same line now states the scope that misled us while investigating: this command lists only classes that own at least one function, while text/classes.txt lists every Class record. Those differ a lot — 3,256 → 3,047 rows on a real Android app (209 nameless rows removed, nothing else), and 2,177 vs 3,358 on a Flutter sample, the gap being classes whose methods were fully inlined or tree-shaken.

Compatibility

On both a Mach-O arm64 Flutter app and a real Android compressed-pointer build, every difference between v0.1.8 and v0.1.9 is inside dart/: 503 of 503 and 867 of 867 changed files, zero outside it. ida_script/, r2_script/, frida.js, asm/, text/ and callgraph.dot are byte-identical, and the export summary matches item for item. Both the full and the --app-scoped decompile output still analyse at 0 errors.

New gates, each negative-tested

  • decompiled_body_covers_instruction_addresses — how many real instruction addresses from asm/ appear as statement addresses in dart/. 70.1% before → 78.3% after, floor 0.75, chosen between the two so a revert fails. Reverting reports 129/184 and fails.
  • condflag_only_wraps_bare_condition_codes — a condFlag argument containing a space or a comparison operator is a failure. Reverting lists the offending expressions and fails.
  • scoped_decompile_keeps_cross_library_call_names — a scoped decompile's anonymous-call set must be a subset of the full decompile's. Corpus-independent. Reverting reports "30 call targets became anonymous" and fails.

The first two exist because the defect they guard was invisible to everything else: validity gates cannot see omission, and regress_all runs unfiltered so it never exercised the scoping path.

Still open, now measured rather than assumed

  • Statement order does not follow address order — 21,826 sites, 2.74% of statements, 36.1% of functions. It cannot be fixed by sorting on address: a folded expression is only correct because it appears before the statement it folded, so reordering would double-count. Fixing it means choosing between liveness analysis to suppress redundant landings, and dropping folding entirely.
  • Return values are mostly not recovered — bare return; is 95.6% of returns (17,238 vs 790). Not "never": both case branches of classify emit return x0;. The figure is dominated by void functions and epilogues.
  • Calls still show no arguments. This was attempted before and reverted: without a verified per-ABI clobbered-register table there is no real liveness, so a register written before an earlier call gets passed off as this call's argument. Item 1 above at least makes the argument setup visible as its own statements.
  • The superclass chain is wrong (unchanged from v0.1.8, where it was first documented): App extends StatefulWidget resolves to SceneBuilder. It feeds frida.js's sid field and the ancestor grouping in text/objs.txt, so both are unreliable and are marked at their source sites.
  • Object-pool names are still not projected into the IDA/r2 scripts (blutter emits ~52,700 pp.*). The data exists; dae pp and dae findrefs query it.

Two things that looked like bugs and were not

Both settled by external truth rather than by inspection, because the honest answer was not the obvious one:

  • Account.deposit's missing if (amount <= 0) throw ArgumentError(...) — that Code object is 4 instructions, and the immediate is 0x32 = 50. It is the constant-specialised copy of a.deposit(50) from main; 50 > 0 is known at compile time, so the compiler legitimately folded the guard away.
  • A Greeter class absent from a variant's class table — nm finds zero Greeter/greet symbols out of 1,555, i.e. fully inlined and tree-shaken, with only the name left in the string table for stack traces. The same toolchain's x64 corpus recovers Greeter at cid 205, so x64 class recovery is fine.

The general rule this release kept running into: read dae disasm before judging the decompiler. Several apparent omissions were the compiler's doing, and one apparent class-recovery failure was our own query hitting the wrong data source.

Verified

57 tests under DAE_REQUIRE_GATES=1, plus every ignored release gate · dart_valid full scorecard: 26 artifacts, 0 dart analyze errors · app_truth against real demo source: classes 98.8%/100%, literals 95.4%/97.4%, source-file→library 18/18 and 21/23 · regress_all 25/25 byte-identical · check_profiles 47/47 · clippy 0 · 41-check CLI comparison against the v0.1.8 binary.

Install

cargo install dae-rs          # crate name is dae-rs; the binary is `dae`
brew install ejfkdev/tap/dae
scoop bucket add ejfkdev https://github.com/ejfkdev/scoop-bucket; scoop install dae

Or grab a binary for Linux / macOS / Windows (x64 and arm64) below.

dae v0.1.8: 50x faster decompilation, a 20-command progressive CLI

Choose a tag to compare

@github-actions github-actions released this 27 Sep 21:52
v0.1.8
3b4cc18

The last release listed "decompiler wall-clock is not improved, and no speedup is claimed" as its top open item. That item is closed: --decompile is ~50× faster, and the CLI grows from 12 subcommands to 20.

Speed

Interleaved A/B against v0.1.7 on the same machine, two rounds each (the host carries unrelated load, so single runs are not evidence):

workload v0.1.7 v0.1.8
material_3_demo (15,082 functions) --decompile 106.8 / 108.7 s 1.91 / 2.35 s ~50×
real Android arm64 app (compressed pointers) --decompile 175.2 / 178.1 s 2.74 / 2.75 s ~64×
material_3_demo, export only 1.49 / 1.43 s 0.54 / 0.50 s ~2.8×
peak RSS 206–232 MB 179–211 MB −27…−47 MB

None of this came from a faster algorithm; it came from stopping three rebuilds of run-invariant data:

  • lift rebuilt the whole object-pool map once per function — 122,064 entries on a real app, rebuilt 15,082 times on the sample above — and Structurer owned its Roles by value, so emit_function deep-cloned that same map again per function. Both now borrow. This is the ~33× and it also explains why export got 2.8× faster: field recovery runs through the same lift path.
  • mask_regs rebuilt its register-alias table on every instruction — clone the profile aliases, append pp/thr and nine hardcoded pairs, stable-sort by descending key length, then one replace_word per pair, each allocating a String and rescanning the whole text. ~1M instructions × 20 pairs ≈ 20M allocations. The table is now built once; lift went 1.95 s → 0.63 s.
  • sort_by_key does not cache its key. callgraph sorted edges with sort_by_key(|a| (…, a.to_text.clone())), so it allocated a String per comparison: 96,904 edges × O(log N) ≈ 1.6M clones. Plus an O(n²) name lookup in the stubs exporter.

A single-pass alias lookup is not equivalent to sequential replacement in general, because the replacements cascade: the arm64 profile maps x29 → fp and x30 → lr (lowercase) and the hardcoded tail maps fp → FP, lr → LR, so x29 reaches the output as FP. The new table resolves each key by simulating the chain in the original pair order — graph reachability would be wrong here, since it also fires on a value that equals an earlier key, which sequential replacement never re-applies.

Two changes are kept but credited with nothing: capstone's .detail(true) → .detail(false) (no detail API is used anywhere, so it is strictly less work, but the A/B showed no measurable gain), and the callgraph fix's effect on wall time (it bought memory and removed 1.6M allocations; sorting 96k edges was already fast).

CLI: 20 subcommands on a declarative tree

get oriented   info · libs · classes · functions · largest
find things    strings · fields · members · findrefs · callers · callees
object layer   pp · objs · stubs
decompile      getclass · getmethod · getlib · decompile
low level      disasm
full export    export        (and `dae <binary> <out_dir>` stays as an equivalent shortcut)

Parsing moved to clap. The reason is not fashion — the hand-rolled parser was written twice over, and that shape is where the sibling tool's CLI bugs come from: an -o flag that was dead code because an earlier loop bailed on unknown options first, a subcommand that took a flag's value as its input path, and one that parsed --dex then dropped it. With flags declared once and positionals parsed independently, those three cannot occur. Shared options live in one struct flattened into every command; seven commands share one <binary> [pattern> shape and five share <binary> <name>, so their semantics cannot drift apart.

New in this release:

  • findrefs <bin> string TEXT — every code site that loads a given string literal from the object pool, and findrefs <bin> kind NAME for an object kind (the /* TypeArguments */ word that appears in dart/).
  • members — methods and fields in one search; callees — the other direction of the call graph, with columns identical to callers so the two read side by side.
  • pp / objs / stubs — the object layer becomes queryable. Each renders through the same function that writes text/pp.txt, text/objs.txt and text/stubs.txt, so "what the artifact shows" and "what the query returns" cannot disagree.
  • decompile <bin> — decompile without writing any other artifact, to stdout by default. This is the only way to pipe a whole app's pseudocode; a full export requires an out_dir.
  • Scope filters — --exclude-lib PATTERN, --no-sdk (URLs starting with dart:), --app (also package:flutter). Decided by the library's original URL, not by guessing from the mangled name: dart:core mangles to dart_core, and a package named dart_core_extra would look the same. On a real Flutter app the three levels measure 505 libraries / 15,796 functions → 489 / 11,016 (--no-sdk) → 56 / 765 (--app).

Function names now also accept the all-dots lib.Class.method form that callers/callees/findrefs/call_edges.txt print, so one command's output feeds straight into the next. That was broken, not merely missing: piping findrefs's from column into dae disasm reported "nothing matched".

Query latency on a 15,796-function app: info 53 ms, objs 43 ms, pp 59 ms, stubs 62 ms, members 68 ms, getclass 82 ms, decompile --app 185 ms, findrefs 209 ms, callees 311 ms.

Correctness fixes

  • pp.txt no longer prints a fabricated constant. Its first line was hardcoded pool heap offset: 0x10f000080, carried over from the Python reference implementation — which also hardcodes it. blutter computes that value as pool_addr − heap_base; dae parses the snapshot stream and has neither the pool's image address nor a heap base. The same constant printed for macOS and Android, compressed and uncompressed pointers, so it was wrong for at least some of them. It now reads unavailable with the reason, and a gate fails if a number ever comes back. This is the one place v0.1.8's output differs from v0.1.7's.
  • dae info exits 1 on parse drift instead of printing the drift and returning 0, and its drift message no longer prints a wrapped u64 class id (18446744073709551553 for −63).
  • Usage errors exit 2, matching the documented convention (0 ok / 1 runtime error / 2 usage error). They used to exit 1, conflating the two. The message is clap's precise diagnosis plus one bilingual line pointing at dae help — clap has no i18n, so that is the honest trade-off.

Output compatibility

Across all 11 commits since v0.1.7, the whole artifact tree is byte-identical to v0.1.7 except that one pp.txt line. Verified with diff -rq on both a Mach-O arm64 Flutter app (1,011 files including all 489 under asm/ and 505 under dart/) and a real Android compressed-pointer build, and the export summary — every count, including the decompiler's blocks/statements/structured/unstructured/unmapped figures — matches item for item. dae export <bin> <out> and the dae <bin> <out> shortcut produce identical trees.

Known limitation: the superclass chain is wrong

Documented now rather than newly broken. Analyzer::parent_of does not resolve superclasses correctly. Measured against an app's own source, which is on disk:

source says dae resolves
App extends StatefulWidget (cid 2285) SceneBuilder (cid 1142)
BrightnessButton extends StatelessWidget (cid 2115) ParagraphBuilder (cid 1057)
_AppState extends State<App> _MixinApplication163&…

The class names and libraries in the same output are correct, so cid → name is fine; only the super hop is wrong. Probing all 13 Class-cluster refs found that only positions 9 and 11 resolve through type_cids at all, and 11 is also wrong — so either the superclass is not among those refs, or the Type cluster's (flags >> 4) & cid_tag_mask decode is. The second is the likelier suspect, because it would explain getting a valid cid that is systematically the wrong one.

Two shipped artifacts consume this chain and are therefore unreliable, both now marked at their source sites: frida.js's sid field (measured: {id:2316,name:"App",…,sid:1142} where the real super is 2285) and the ancestor grouping inside text/objs.txt (the field values themselves are readable; the inheritance grouping is not). Neither was silently changed — altering frida.js bytes means re-validating 25 regression archives, which is its own piece of work.

A hierarchy command was built and then withdrawn: it produced the wrong chain, and a wrong inheritance chain is worse than none. The full diagnosis is left in src/cli.rs so nobody has to redo it.

Also deliberately not provided: findrefs field (compiled code carries no symbolic field reference, only a bare displacement, so matching on displacement would report unrelated [x, #0x18] as hits — guessing, not querying), findrefs type (a pool entry's description is Kind: content, and that prefix is the object category, not a type name), and a manifest-derived --app package name (a Dart snapshot has no manifest).

Still open

  • The superclass chain, above — fixing it needs the Dart SDK's Class::Serialize / AbstractType::Serialize for ref order and flags encoding, then re-baselining frida.js and the regression archives.
  • Object-pool names are still absent from the IDA/r2 scripts (blutter emits ~52,700 pp.* flags). The data exists — text/pp.txt carries 122,064 resolved entries on a real app, and findrefs now queries it — it is just not projected into the tool scripts.
  • text/pp.txt does not escape values, so a pool string containing a real newline spills across two lines and breaks the file's own one-entry-per-line format (text/strings.txt escapes; pp.txt does not). findrefs escapes correctly and is ...
Read more