Repository navigation
ptx-fix-output-parameters: ET_REL relocatable-object loader (option relocobjects) - #37
Merged
Merged
Conversation
…t loader support The angr testcase test_decompiling_ptx_fix_output_parameters decompiles fix_output_parameters from ptx.o, a relocatable ELF object (ET_REL). kuna's loader (kuna-analysis loadimage_object.rs) builds its memory map only from PT_LOAD segments; a .o has no program headers, so the map is empty and EVERY function fails with "Unable to load N bytes" — kuna emits zero output while angr decompiles fully with resolved symbols. Closing this needs loader infrastructure (synthesize segments from SHF_ALLOC sections + apply .rela.* relocations + rebase symbols), not a single option-gated decompiler Action/Rule. Scope decider returned "large" → this is a [PROPOSAL] draft PR for human go/no-go, not an implementation. Bundle: docs/features/ptx-fix-output-parameters-bcee92/ (analysis.md, proposal.md, angr-vs-kuna.txt, record.json). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Jun 25, 2026
Closed
…er (option relocobjects, DIV-7)
Closes the angr-vs-kuna gap test_decompiling_ptx_fix_output_parameters::
fix_output_parameters. ptx.o is a relocatable ELF object (ET_REL) with no
PT_LOAD program headers; kuna's PT_LOAD-only LoadImageBfd port mapped zero bytes,
so every function failed ("Unable to load N bytes") and kuna emitted no output at
all, while angr's CLE ELF relocatable backend decompiled it fully.
New kuna-analysis/src/s1_loader/elf_reloc.rs lays SHF_ALLOC sections out above
0x400000 (angr's default; fix_output_parameters -> 0x400660), applies the .rela.*
relocations (R_X86_64_PC32/PLT32/32/32S/64), rebases defined symbols, and binds
undefined externs (PLT-relative call targets named even when STT_NOTYPE) to
synthetic addresses. ObjectLoadImage::from_bytes branches to from_relocatable for
kind()==Relocatable with empty segments(); the linked ET_EXEC/ET_DYN path is
byte-identical.
Option `relocobjects` (default on). The loader runs at `load file`, upstream of
the per-function option machinery, so the toggle is bridged via the
KUNA_RELOC_OBJECTS env var that set_kuna_option and `kuna decompile` write.
Ablation 0/675 (XML datatest path never builds an ObjectLoadImage); speed within
budget. DIV-7. make test PARITY OK; make test-stages PARITY OK (159/159; two
kuna-catalog.xml provenance counts bumped for the new settable). Loader cargo
tests (hand-assembled ET_REL + real ptx.o fixture); no XML stage test is possible
for a loader feature. The one rust-test failure (verify_w10_proto_unlock) is a
pre-existing DIV-6 stale-oracle assertion, unrelated, left untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mahaloz
marked this pull request as ready for review
June 25, 2026 04:40
Contributor
Author
|
APPROVE |
Bring the relocobjects (ET_REL loader) feature branch up to current main. Conflicts resolved by UNION; relocobjects' DIV renumbered DIV-7 -> DIV-8 (DIV-7 is now dedupvardecls on main): - stages.toml: 40 settable blocks; count assertions updated to 40 - decompile.rs: keep both the relocobjects env bridge and experimental_formats env - loadimage_object.rs from_relocatable: add the new fallback_archtype field (main) - kuna-catalog.xml / baseline: angr provenance 6, structure-recovery 3; use_when/change_kind max bumped 40 -> 50 (40 settables + 1 extra returnpair row) - divergences.md: DIV-7 dedupvardecls (main) kept, relocobjects added as DIV-8 - UPSTREAM.md / PROGRESS.md / stage-mapping.md: relocobjects DIV-7 -> DIV-8 - assertions.md + baseline-stages.json regenerated Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (163/163). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 14, 2026
MSVC /O1 writes mov ebx,3 as push 3; pop ebx. That pop into a callee-saved register is not the epilogue, and ending the cleanup scan there dropped the arguments of a cdecl call whose cleanup MSVC deferred past it (pkgen2: sub_42ea6e(v1,v2) -> (v1), and the next zend_register_long_constant took the orphaned pair). A pop right after a push is now passed over. The fixture gains consts (rebuilt from its recipe), stage Noelo-Lab#36/Noelo-Lab#37; spec 04 also states the remaining limit (a frame torn down with no callee-saved restore first). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 14, 2026
…oelo-Lab#1581 docs/baseline-stages.json is synthesized with mergebaseline.py (main's keys plus the five CALLEEARGS Noelo-Lab#33-Noelo-Lab#37 this branch adds); every other file merged without conflict. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
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.
relocobjects: load ELF relocatable objects (ET_REL/.o)Closes the angr-vs-kuna gap
test_decompiling_ptx_fix_output_parameters::fix_output_parameters(
ptx.o, angr 9.2.213). Analysis:analysis.md· approved proposal:proposal.md.The gap
ptx.ois a relocatable ELF object (ET_REL) with noPT_LOADprogram headers. kuna'sfaithful
LoadImageBfdport (kuna-analysis/loadimage_object.rs) builds its byte map only fromPT_LOADsegments, so a.omapped zero bytes and every function failed to lift(
Unable to load N bytes at ...) — kuna emitted no output at all. angr's CLE ELF relocatablebackend decompiles it fully with resolved names.
Mechanism
A new kuna file
kuna-analysis/src/s1_loader/elf_reloc.rs. For anET_RELobject(
kind()==Relocatable+ emptysegments()),ObjectLoadImage::from_bytestakes a newfrom_relocatablepath that:SHF_ALLOCsection at a non-overlapping VMA above0x400000(angr's CLEdefault —
fix_output_parameterslands at0x400660, matching angr), respecting alignment;.bss/NOBITSis zero-filled;.rela.*relocations into the snapshotted bytes —R_X86_64_PC32/PLT32(
S + A − P),R_X86_64_64/32/32S(S + A); an unhandled kind degrades with a loggedwarning rather than miscompiling;
targets are named even when gcc emits them
STT_NOTYPE) to synthetic addresses, so calls renderby name (
strlen(...),__sprintf_chk(...),__ctype_b_loc(...), …).The linked
ET_EXEC/ET_DYNPT_LOADpath is untouched (byte-identical).Option
relocobjects(default on — it only affects.ofiles, which the loader otherwise cannot loadat all). The loader runs at
load file, upstream of the per-function option machinery, so thetoggle is bridged to the loader by the
KUNA_RELOC_OBJECTS(RELOC_OBJECTS_ENV) process env varthat
Architecture::set_kuna_optionandkuna decompilewrite:Discoverable via
kuna catalog --json(source_decompiler: angr,change_kind: structure-recovery). New divergence DIV-7.Ablation / parity / speed
ObjectLoadImage, and the linked-ELF path is byte-identical.make test→ PARITY OK.make test-stages→ PARITY OK (159/159; the twokuna-catalog.xmlprovenance counts bumped3→4
angr/ 2→3structure-recoveryfor the new settable).fix_output_parametersdecompile−6.97%(on vs the off/errorpath), well under the +5% budget; the layout+relocation work is a one-time O(sections+relocs) pass
at load.
Tests
Cargo workspace (
make rust-test) — no XML stage test is possible for a loader feature (thedatatest path bypasses
ObjectLoadImageentirely):s1_loader::elf_reloc— a hand-assembledET_RELexercising section layout + each relocationkind + defined/extern symbol binding;
loadimage_object— the vendored realptx.ofixture:fix_output_parametersrebases to0x400660, its bytes load, and externs (strlen/dcgettext/error) resolve.🤖 Generated with Claude Code
Before / after —
fix_output_parametersinptx.oReal captured kuna output on the function this feature was built for, with
option relocobjectsflipped. Ported from angr — test_decompiling_ptx_fix_output_parameters; CLE ELF relocatable backend; fix_output_parameters.relocobjects offrelocobjects on(default)kuna — before (
option relocobjects off)kuna — after (
option relocobjects on)angr reference (the goal, v9.2.213)