Skip to content

[AUTOMATED] fix(cli): offer a linked image the selector it actually has when a name is ambiguous - #703

Merged
mahaloz merged 1 commit into
mainfrom
fix/ambiguous-selector-hint
Sep 21, 2026
Merged

mahaloz merged 1 commit into
mainfrom
fix/ambiguous-selector-hint

Conversation

@mahaloz

@mahaloz mahaloz commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Depends on #701.

The problem

Two same-named functions in a linked image make a by-name selector ambiguous,
and the report tells you to use a selector form that only exists for
relocatable objects. Following it gives a second, unrelated error, and the
addresses it prints are called synthetic although they are the ones the image
is mapped at.

$ K=decompiler/target/release/kuna
$ F=decompiler/crates/kuna-analysis/tests/fixtures/macho_dup_main
$ $K decompile $F _main
error: selector "_main" is ambiguous; candidates:
  _main at synthetic 0x1000005a0
  _main at synthetic 0x1000005b0
use a section-qualified selector to choose one candidate
$ $K decompile $F '.text+0x5a0'
error: no function ".text+0x5a0" in .../macho_dup_main; for a stripped binary pass an address with --addr

The fix

  • The ambiguity carries whether the image came from a relocatable object, the
    way Unmapped already does. The section-qualified hint is for that case only;
    a linked image is offered the selector that works there, spelled out once per
    candidate rather than as a grammar to apply.
  • synthetic stays where it is true — a relocatable definition's load VMA and
    an undefined external's placeholder — and goes where the image maps the
    candidate itself.
$ $K decompile $F _main
error: selector "_main" is ambiguous; candidates:
  _main at 0x1000005a0
  _main at 0x1000005b0
use an address selector to choose one candidate: --addr 0x1000005a0, --addr 0x1000005b0

The tests

macho_dup_main is macho_imports with one symbol's name pointed at
another's; macho_dup_main.py beside it carries the transform. Two cases in
verify_entry_selectors.rs and three in ambiguous_selector_cli.rs: the linked
report offers the address form and the offered address decompiles, while the
relocatable .o report is the one it always was. A tests/cli/ probe pins the
linked-image text. One existing expectation moved, and it is the defect:
verify_assertplane counted synthetic 0x to prove both candidates of a linked
PE were listed. 675/675 datatests, stages PARITY OK, workspace suite green,
make test-cli 216/216.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ocFS1B6rT3wfWcQsuwE6B

@mahaloz
mahaloz force-pushed the fix/macho-name-lookup branch from f798e42 to ea0aec4 Compare September 21, 2026 17:17
@mahaloz
mahaloz force-pushed the fix/ambiguous-selector-hint branch from 541af33 to 0081823 Compare September 21, 2026 17:17
@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 21, 2026
Base automatically changed from fix/macho-name-lookup to main September 21, 2026 17:48
…as when a name is ambiguous

Two same-named entries made a by-name selector ambiguous, and the report told
the caller to use a section-qualified form. Those coordinates exist only in a
relocatable object, so on a linked image the advice led to a second, unrelated
error. The ambiguity now carries the same `relocatable` bit `Unmapped` does:
the section form is offered for a relocatable input and the address form, one
per candidate, for a linked one.

The per-candidate line kept the relocatable wording too. `synthetic` stays on a
relocatable definition's load VMA and an undefined external's placeholder, and
is dropped for a candidate the image maps itself.

Closes #667.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015ocFS1B6rT3wfWcQsuwE6B
@mahaloz
mahaloz force-pushed the fix/ambiguous-selector-hint branch from 0081823 to 44f7b00 Compare September 21, 2026 17:49
@mahaloz
mahaloz merged commit 69a9470 into main Sep 21, 2026
9 checks passed
@mahaloz
mahaloz deleted the fix/ambiguous-selector-hint branch September 21, 2026 18:20
mahaloz added a commit that referenced this pull request Sep 21, 2026
* [AUTOMATED] wip(analysis): libctypes second round of named libc structs

Mined the libc/POSIX-named ptr_struct ground-truth pool from the DWARF twins
of the 444-slice corpus and added the slots that pay.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] wip(analysis): obstack fixture, stage passes 11-12, unit tests

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] wip: spec prose, phases.toml summary, options.md, stages baseline

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] wip: probe/test fixtures repointed, feature bundle analysis+plan

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] wip: re-capture phase_catalog fixture, move the ghidra-sim C-line pins

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] wip: feature record.json

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] wip: refresh the module header for the second round

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): cite the twin's debug info for the nl witness

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): record the export compile-error cost

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): tidy the unreachable half of the ranked pool

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): list every newly-wrong row

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the speed block and the gate results

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the quieter-moment speed confirmation

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] fix(analysis): the obstack size slots follow the channel, not the corpus

gnulib's copy of obstack.c declares its size type size_t; the installed glibc
header declares int. The table asserted size_t for both, so an image that
IMPORTS _obstack_begin/_obstack_newchunk from glibc (the five dpkg programs at
each optimization level, 15 slices of the same results tree) got a false
declaration, and the caller of a two-line glibc-obstack program went from
`void f(int n)` to `void f(unsigned int n)` with two inserted casts.

Split the channel: LIBC_DEFINED_NAMED (size_t) is seeded only from the names
the image defines and does not also import, LIBC_IMPORTED_OBSTACK (int) from
the import channel by name and by resolver address. Corrects the module and
spec prose that claimed obstack is never an import.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the gzip row in full, and the two obstack channels

The single worse typesweep row said "a by-value struct stat local that becomes a
byte blob". What it actually is: char v5 [80] handed to an lstat that writes 144
bytes, with st_atim/st_mtim detached into locals the body reads and nothing
writes. State that, say what causes it (the timespec * slot on
utimensat/futimens -- reverting those two slots brings stat v5 back), and record
the measurement it is kept on: over the 30 corpus slices that import either
name, 122 functions gain a timespec rendering and this is the only new
under-declared stat, against 7 that main already prints in those same slices.

Also: rebased onto argclobber (#689), stages baseline re-recorded, PR body cut
under a screen, and the statfs/export redeclaration noted beside the option's
documented export cost.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] test(stages): pin the imported obstack channel end to end

libctypes_obstack_import_x86_64 is the twin of the existing obstack fixture on
the other channel: _obstack_newchunk imported from glibc rather than linked in
from gnulib. Two assertions, off and on, pin `void grow_import(obstack *a0,int4
a1)` against #28's `uint8` -- a table that spelled both channels the same fails
one of them.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): re-measure on the rebased base

The 444-slice typesweep was run again in full after the rebase onto argclobber
(#689), base arm built from origin/main's kuna_libctypes.rs + protos/mod.rs in
this tree. Identical to the first run down to the per-variable tables: 1,349 ->
1,353 perfect, mean .3403 -> .3417, 147 newly correct / 6 newly wrong, 91
improved / 1 worse. Also completes the newly-correct breakdown, which was
listing 139 of the 147.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the channel split's load cost

min-of-9 interleaved `kuna functions` over -O2 tar: 0.144s before the extra
defined-name walk, 0.142s after.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] style(analysis): shorten the inline note at the obstack seam

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the channel split's blast radius

decompile-all over five whole binaries, the two builds differing only by the
split: grep/tar/ls/gzip byte-identical, dpkg-query moves 7 lines.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] style(analysis): present-name set is module-private again

Nothing outside protos/mod.rs reads it now that the obstack seam takes the
defined-name set.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): disclose the sigaction frame split

The `sigfillset(sigset_t *)` slot gives the `sa_mask` sub-object its own
identity, so a 152-byte `sigaction` frame slot splits at 136 and the
`sa_flags` store lands outside the object handed to `sigaction()`.

Measured by ablating that one table row: no `sigaction` declaration moves
anywhere in the 444 scored slices (6 of them import `sigfillset`), and in a
disjoint openssh -O2 sweep exactly one function per binary changes, all of
them `ssh_signal`. The shape already ships through `sigemptyset`, which
prints the identical split on the ablated build.

Also records the `statfs` name collision as it appears in plain
`decompile-all`, not only in a project export.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the sigaction repro in full

The mitigation claim is only checkable with the program it was measured on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): re-measure the typesweep on the new base

Third full run of both arms, this time at 69d252d. The perfect counts, the
improved/worse split and every per-variable table are unchanged; only the
pooled mean moves, 0.3403 -> 0.3405 off and 0.3417 -> 0.3419 on, which is #694
lifting both arms alike.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the utmp rows measured, the 32-bit size limit, the re-derived fixture swap

Adds three sections to the feature analysis: the utmp/utmpx rows reaching a
caller's own local on who/logoutd/runlevel (they ship on a pool count, not a
sweep delta, and this is what they buy); the table's sizes being glibc x86-64
with nothing scaling them by word size, and what that is confined to; and the
export fixture swap re-derived under #693's callee-first schedule.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): record the rebase onto the callee-first export

The gate block now names the base it was run on, and a new section records how
the two repointed fixtures were re-derived under that schedule, the nine-binary
`libctypes off` identity against a build of the new base, and why the type sweep
did not need re-running (`decompile-all --json` is byte-identical between the
two bases). The timespec rows are recorded as a decision rather than a
disclosure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] docs(libcstructs): the workspace suite result on the rebased tree

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG

* [AUTOMATED] feat(analysis): drop the sigfillset row from libctypes

It splits a struct sigaction frame slot in openssh's ssh_signal and buys
nothing in the mined pool.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] feat(analysis): drop the two-element time slots and the sigset_t sub-object rows

utimensat/futimens/utimes/futimesat take a two-element array; naming one
element shrinks the caller's frame object (gzip lutimens reads a stat tail
nothing writes; scp/sftp hand utimes 16 of 32 bytes). sigsuspend,
pthread_sigmask, sigdelset, sigismember and sigwait split a struct sigaction
local when handed &sa.sa_mask.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] docs(libcstructs): the spec and option row say which slots are left out and why

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] docs(libcstructs): round-5 measurements, the dropped rows, off-pool notes for every kept row

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] docs(libcstructs): the frame checker, the sigset_t repro and the 15-binary hunk classification

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] docs(libcstructs): record.json for round 5

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] test(analysis): the frame-splitting slots stay out of the libctypes tables

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] chore(libcstructs): re-derive counts and generated files after rebase

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] docs(libcstructs): round-5 speed block and the gates on the rebased tree

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

* [AUTOMATED] docs(libcstructs): the gates on the #703-rebased tree

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017ei9zqc7XHgZdMAzrk8jAL

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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