Repository navigation
[AUTOMATED] feat(p5): synthesize struct types from constant-offset dereferences of a pointer parameter (structsynth) - #655
Merged
Merged
Conversation
mahaloz
force-pushed
the
feat/structsynth
branch
2 times, most recently
from
September 17, 2026 03:42
c88849b to
b096d9e
Compare
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
mahaloz
force-pushed
the
feat/structsynth
branch
2 times, most recently
from
September 17, 2026 07:20
40dcaff to
715a2c4
Compare
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…await go/no-go; GH-657 fix queued Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…await go/no-go; GH-657 fix queued Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
force-pushed
the
feat/structsynth
branch
from
September 17, 2026 14:31
0aa34b0 to
86e80c6
Compare
mahaloz
marked this pull request as ready for review
September 17, 2026 15:39
mahaloz
force-pushed
the
feat/structsynth
branch
2 times, most recently
from
September 17, 2026 17:24
d7e8596 to
6f04718
Compare
…references of a pointer parameter (structsynth) A new P5 action (`p5_types/kuna_structsynth.rs`) collects the constant-offset loads and stores made through a pointer parameter, prunes them to a layout a C compiler reproduces byte for byte, and type-locks the parameter to the synthesized `struct_N *`. Behind `--option structsynth off|param`. Rebased onto origin/main (foldcallretphi #654, ptrfromuse #659, libctypes default-on #658); counters re-derived on the rebased tree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…rebase Speed (worst +1.34% over six binaries against a +2.60% inert control) and the corpora under a temporary default flip (675/675 datatests unmoved, four stage assertions that are each the intended field rendering) both pass; the 444-slice type_match perfect count misses by four-hundredths of a function (959 -> 958), and the 15-binary decompile-all sweep turns up a bug hunk -- findutils find O2 sub_f620 emits `goto label_f752;` with no such label, one more function landing on an emitter defect already live in nine others. Default stays `off`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…the others The interleaved min-of-N `decompile-all` A/B that produced the speed block lived in a scratch directory while the five other instruments in this bundle are checked in; the numbers are not reproducible without it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
Rebase onto origin/main (structdefs, indirectonly). Every hard-coded count re-derived from the freshly built tree with scripts.repipe.counters --rederive --fix, phase_catalog.json re-captured, and docs/baseline-stages.json re-recorded with SLEIGHHOME set -- no arithmetic anywhere. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…ol and the structdefs pairing The base now carries structdefs and indirectonly. Re-proves the default-off arm byte-identical against a build of it, records the structdefs x structsynth combination (the definition of the synthesized layout printed above the function it was synthesized for), and states both readings of the accuracy criterion. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…ew base The census, the libctypes precedence witness, the aggressive-preset exclusion and the dangling-goto delta all reproduce unchanged after the rebase. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…he rebase Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…s-glibc base Real glibc layouts take no parameter this pass was taking -- the census is byte-identical -- the off-arm stays byte-identical against a build of the new base, and the hunk that decides the default reproduces unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…the rebases Both arms are byte-identical across the three bases on the identity-control binaries, so the speed and typesweep blocks stand as measured; the census and the deciding hunk were re-run on the current base anyway. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…nt to its base Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…ent base Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
Rebased onto origin/main (the foldcallret barrier, GH-657). Counters re-derived on the freshly built tree, phase_catalog.json recaptured, docs/options.md regenerated and docs/baseline-stages.json re-recorded so both sides' stage assertions are present. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
force-pushed
the
feat/structsynth
branch
from
September 17, 2026 18:54
fbf7444 to
75e2826
Compare
mahaloz
pushed a commit
that referenced
this pull request
Sep 17, 2026
…on the structsynth base Rebased onto origin/main 2272403 (structsynth #655). #655 adds a settable and three stage files, so the counters move: 217 settables, tiers 68/86/63, 311 corpus files, fixture 217 and the comma-terminated catalog-row count 216, all re-derived with `counters --fix` on the freshly built tree. The stages baseline is re-recorded, not hand-merged: 1110 = main's 1100 + this branch's 10, with 0 assertions removed and every neighbour's keys intact (18 structsynth, 15 LIBCTYPES, 13 indirectonly, 8 foldcallret, 5 structdefs). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this makes possible
A stripped binary keeps no record of the aggregate a pointer points at, so kuna
proves the pointee it can and stops there. Build a two-field record and read it:
The layout is only in the reader's head, across every function that touches the
same object. With
--option structsynth param:On
ls-O2,hash_rehashrecovers nine of the ten members of gnulib'sstruct hash_table, each at its real offset.The change
p5_types/kuna_structsynth.rs) walks the live LOAD/STORE opsonce, peels each address to
(base, constant offset)through COPY/CAST andconstant pointer arithmetic, and type-locks the parameter to a completed
struct_N *. Widest access wins a conflicting offset.ActionInferTypesreturns 0 unconditionally, so nothing downstream can see the fixpoint; a
plateau flag on the
Funcdatais the signal.TYPE_PTR— and anamed pointee (DWARF, a parsed declaration, a libc shell from
libctypes, anearlier synthesized layout) always wins. Phis, non-constant offset terms,
integer uses, stack and spacebase bases, and uniform-stride runs all decline.
dense and C-sized, because
kuna decompile-projectexports the declaration assource and the body names members the header has to declare.
structdefs:--option structdefs on --option structsynth paramprints
struct struct_0 { long field_0x0; int field_0x8; char field_0xc[4]; };above the function, and carries it in
decompile-all --json.The default is
off, on measured evidenceSpeed passes (worst whole-binary delta +1.34% over six binaries, against an
inert control binary that moved +2.60% on the same run) and so do the corpora
under a temporary flip (675/675 datatest assertions unmoved; four stage
assertions move and all four are the intended field rendering). Two things say
no. Over the 444-slice
type_matchsweep the flip is worth one perfect function(959 → 958, aggregate −0.049%), because the metric compares pointee spellings by
name and
struct_0 *cannot intersect a ground-truthWORD *. And over a15-binary, 5,431-function
decompile-allsweep the type lock changes whichblocks the structurer duplicates, landing one more function on an emitter defect
that is already live in nine others:
find-O2sub_f620emitsgoto label_f752;with no such label. It is out ofaggressivefor the samereason.
docs/features/structsynth/carries every number.Tests
Three two-pass stage tests (
structsynth-param-struct,-overlap-layout,-hole-member): pass one isoption structsynth offand the raw offsets, passtwo the fields.
-overlap-layout#5 and-hole-member#4/#5 fail with thelayout prune and the hole filler ablated. 16 unit tests in
p5_types/kuna_structsynth/tests.rscover each decline clause, the roundedsize, and the plateau latch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29