Skip to content

[AUTOMATED] feat(p5): structsynth on by default - #682

Merged
mahaloz merged 14 commits into
mainfrom
feat/structsynth-on
Sep 18, 2026
Merged

mahaloz merged 14 commits into
mainfrom
feat/structsynth-on

Conversation

@mahaloz

@mahaloz mahaloz commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

By default, a stripped function that reads one object at fixed offsets now gets a struct_N * parameter, and the reads print as fields. --option structsynth off gives the old output back.

$ kuna decompile-all decompiler/crates/kuna-analysis/tests/fixtures/i386_pie_nl --addr 0x1a30

Before (main):

unsigned int build_type_arg(unsigned int *a0,unsigned int *a1,unsigned int a2)
...
        *a1 = 0;
        a1[4] = a2;
        a1[1] = 0;
        a1[5] = 0;

After:

unsigned int build_type_arg(unsigned int *a0,struct_0 *a1,unsigned int a2)
...
        a1->field_0x0 = 0;
        a1->field_0x10 = a2;
        a1->field_0x4 = 0;
        a1->field_0x14 = 0;

The same change turns coreutils fmt O2's put_word from void sub_3000(unsigned long *a0) with *(unsigned int *)&a0[1] into void sub_3000(struct_0 *a0) with a0->field_0x8.

The change

  • structsynth defaults to param. That covers the catalog row, reset_defaults, and the prose in docs/spec/05-types.md and docs/options.md.
  • A synthesized field only gets a sign when every read of it agrees on one. Otherwise it stays undefined<N>, which prints unsigned. After [AUTOMATED] fix(p3): keep a narrow load's width when it is read through a wider-typed pointer #677, find O2 sub_7670 passes a zero-extended 16-bit field to a 32-bit argument (movzwl 0x68). The field had taken short from a read used in a signed compare, so sub_7510(a1->field_0x68) sign-extended the value that [AUTOMATED] fix(p3): keep a narrow load's width when it is read through a wider-typed pointer #677 keeps unsigned. The field is now unsigned short, which is also what DWARF says.
  • A sharded run (--jobs N on decompile-all, decompile-graph or decompile-project) runs its workers with structsynth off and says so on stderr. Each worker numbered its own struct_N: fmt O2 at --jobs 4 renamed three prototypes, and the project .h merge tore the definitions apart (ls O2 at --jobs 4 gave 23 struct { openings and one };). The output now equals --jobs 1 --option structsynth off, and the help text says so. A serial run still synthesizes.
  • A field read at one width both as a float and as something else is raw bytes (char field_0x8[8]), so each read casts the address. For a gcc -O2 union read with both movsd and cvtsi2sdq, a long field printed (double)a0->field_0x8, a value conversion, so a stored 2.5 came back as 4.6e18. It now prints *(double *)a0->field_0x8.
  • Stage tests: the elfmain off pass keeps the upstream form with option structsynth off. PEBNAMES-X86 #6/#8 now expect the SEH function's FS base as v->field_0x0 / v->field_0x30. The stages baseline changes only by four renamed keys.
  • Modes are unchanged. reliable is the shipped defaults, so it gets param. aggressive inherits the default rather than pinning param below a future all. fast only changes discovery.

Evidence

  • make test 675/675, with no datatest assertion moved. make test-stages 1156/1156. make test-cli 189/189 (four new probes). make rust-test green. Three round trips compile the printed C and check the values. [AUTOMATED] fix(p3): keep a narrow load's width when it is read through a wider-typed pointer #677's now also runs at the default. signfield_zext_x86_64 handed sink 4294941372 before the sign rule. unionfield_fp_x86_64 returned 4.6e18 for 2.5 before the float rule.
  • Whole-binary decompile-all over 14 stripped binaries (5,610 functions, x86-64 and ARM32) changes 483 functions. 350 are checked mechanically as the same byte offsets written as fields. I read the other 133, and each accesses the same bytes (docs/features/structsynth/flip.md). No function in either arm has a goto whose label is missing. That includes find O2 sub_f620, which kept this off last time. Eight exported headers declare 311 structures, and every offsetof equals its field offset. The two review fixes move 5 of 12,544 functions across 24 binaries, all in crazyflie cf2 O2. Three of them copied a float field into an unsigned int array as a value, and now copy the bits.
  • The accepted cost: decbench type_match compares pointee names, so struct_0 * never matches a ground-truth WORD *. Over 444 slices the flip costs one perfect function (959 → 958, aggregate −0.05%). The 19 decisions it moves off a match are real false positives: factor's GMP limb arrays and shred's name buffer. [AUTOMATED] type_match: credit any struct pointer when the source type is a pointer to a struct decbench#93 asks the metric to credit a structure pointer against a pointer to a named structure.
  • Speed (decompile-all, interleaved min-of-15): fmt O2 −3.4%, ls O2 +2.9%, sort O2 +2.4%, bash O2 (1.3 MB) −0.6%, inert control +0.7%.

structdefs stays off. With this on, it would add 872 lines to ls O2 (+6.4%). structdedup (#675) and structarrays rebase onto this. Once protoorder (#669) lands, a callee's struct_N parameter reaches its callers.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

@mahaloz mahaloz added the full-ci Run the full cargo workspace suite on this PR before merge (internal PRs skip it by default) label Sep 18, 2026
mahaloz and others added 14 commits September 18, 2026 22:38
…ly when every access agrees (+ #677 round trip under the flip, signfield fixture, probe)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
…a float-vs-integer field is raw bytes

decompile-all/decompile-graph --jobs N numbered struct_N per worker process, so
one document used a name for two layouts (fmt O2: 3 renamed prototypes). Every
sharded run now passes its workers structsynth off and says so on stderr; the
help text and docs say the output equals --jobs 1 --option structsynth off.

A synthesized field read both as a double and as a long was typed long, so the
movsd read printed (double)a0->field_0x8 (a value conversion). Evidence now
accumulates the value classes of every access of the field's width; a float
beside a non-float makes the field undefined1[N], so each read casts the address.
New fixture unionfield_fp_x86_64 + round-trip test + probes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
… prose for the float rule and the past-the-end piece syntax

Accumulating the value classes made a pointer field also read as long and
unsigned long (find O2 sub_f620 field_0x8) contest its sign and lose the
pointer spelling. A pointer has no sign to get wrong, so the sign contest now
applies only when the committed type is an integer, which is exactly the old
pairwise rule; the float rule is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
@mahaloz
mahaloz force-pushed the feat/structsynth-on branch from 3476d2d to 0a80735 Compare September 18, 2026 22:57
@mahaloz
mahaloz merged commit 6e4f6fa into main Sep 18, 2026
9 checks passed
@mahaloz
mahaloz deleted the feat/structsynth-on branch September 18, 2026 23:19
mahaloz added a commit that referenced this pull request Sep 18, 2026
…too; re-record stages on 6e4f6fa

Since structsynth on by default (#682), a field read both as a float and as
an integer is raw-byte filler in the reader's own layout. A container's typed
field there would print the float read as a value conversion again, so the
ledger's unclaimed-bytes veto covers those bytes as well. Stage baseline
re-recorded on 6e4f6fa (+12 structsynth keys, 1156 -> 1168); options.md and
the phase_catalog fixture regenerated.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz added a commit that referenced this pull request Sep 19, 2026
…too; re-record stages on 6e4f6fa

Since structsynth on by default (#682), a field read both as a float and as
an integer is raw-byte filler in the reader's own layout. A container's typed
field there would print the float read as a value conversion again, so the
ledger's unclaimed-bytes veto covers those bytes as well. Stage baseline
re-recorded on 6e4f6fa (+12 structsynth keys, 1156 -> 1168); options.md and
the phase_catalog fixture regenerated.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz added a commit that referenced this pull request Sep 19, 2026
…too; re-record stages on 6e4f6fa

Since structsynth on by default (#682), a field read both as a float and as
an integer is raw-byte filler in the reader's own layout. A container's typed
field there would print the float read as a value conversion again, so the
ledger's unclaimed-bytes veto covers those bytes as well. Stage baseline
re-recorded on 6e4f6fa (+12 structsynth keys, 1156 -> 1168); options.md and
the phase_catalog fixture regenerated.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz added a commit that referenced this pull request Sep 19, 2026
…too; re-record stages on 6e4f6fa

Since structsynth on by default (#682), a field read both as a float and as
an integer is raw-byte filler in the reader's own layout. A container's typed
field there would print the float read as a value conversion again, so the
ledger's unclaimed-bytes veto covers those bytes as well. Stage baseline
re-recorded on 6e4f6fa (+12 structsynth keys, 1156 -> 1168); options.md and
the phase_catalog fixture regenerated.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the full cargo workspace suite on this PR before merge (internal PRs skip it by default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant