Compare commits

...

1 Commits

Author SHA1 Message Date
coah
9c443f5ddd Retain candidate-window name address across pane lookups 2026-10-03 12:10:04 -05:00
3 changed files with 375 additions and 1 deletions

View File

@@ -398,7 +398,8 @@ namespace textinput {
mRightScroll.Create(this, paneNames + 108, paneNames + 88);
mLeftScroll.Init();
mRightScroll.Init();
mTextWindow.Create(this, scW_predictWindow);
const char* windowName = scW_predictWindow;
mTextWindow.Create(this, windowName);
init();
}

View File

@@ -0,0 +1,169 @@
# Candidate-box window-name lifetime, 2026-10-03
Base: `57c17ebe2a7b3788cbbbf54f7dc9a9fb35abaec8`. 43U only.
Branch: `agent/bittle/candidatebox-window-name`.
## One bounded hypothesis
Immediately before the existing `mTextWindow.Create` call, capture the fixed
array address in `const char* windowName`, and pass that value to the unchanged
helper. No other production statement, helper body, type, scope or metadata was
changed. Exactly one candidate form was compiled.
`scW_predictWindow` is a mutable `char[16]` array defined at source line 220, not
a mutable pointer variable. Its object has size 16 at `.data+0x738` in both
objects, corresponding to target address 0x8165DA08, and contains
`W_predictWindow` followed by NUL. All named source references were inspected;
no writes beyond its initializer were found. The proof does not assume that
callbacks cannot change its characters: only the storage address is captured,
and every character read remains at its existing call site. The local pointer
is initialized before its sole source use, is not address-taken, has no shadow
or name collision, and crosses no branch or label.
`UITextWindow::Create` remains unchanged: obtain the pane manager, search for
the pane component, then search for the animation pane. Argument evaluation,
constructors, virtual calls and observable memory operations keep their order.
## Historical evidence and limits
`partial-oct2f.attempts.md:803` records the same window-name-capture hypothesis
at 93.67614%, 352/352 instructions and zero reported regressions. It was restored
in that older exact-only run. The historical variant tag is `d9cd56dc516f`; its
actual source snapshot and complete data/relocation gates are unavailable.
The current create body is byte-identical to the historical baseline body in
`c4857800df46ae3edfd824198fa09a31c4f6ce0f`, SHA256:
`c3e7e73cb75cef1cb36b2af59257e20e77b6afdc1c0db23da7b2e4f8a23d9824`.
The result below reproduces the old score numerically, but is a current-context
hypothesis replay, not a claimed identical historical source reproduction.
Other prior allocation, typed receiver, scoped buffer, pane-array traversal and
helper-lifetime experiments in tiCandidateBox, data-d15, rt8, partial-oct2d and
sol-high-structural-round4 attempt logs were read. No additional variant or
declaration sweep was run.
## Frozen baseline and results
The baseline cache came from the parent's independently verified frozen
`wii-rgb422-next-review`, HEAD `8f1d13822b51509c354ab676d5e6c0097b7e0552`, tree
`1dde64c7318dc1cfdb4fd7e067931d495d56b02c`, identical to the selected base tree.
All 1027 copied source-object hashes were checked. A real baseline compilation
and fresh complete official report reproduced that reference exactly.
Baseline -> candidate:
- LayoutByNW4R::create: 92.71023 -> 93.67614%.
- Function length: 351 -> 352 instructions, 1404 -> 1408 bytes; target is 1408.
- Unit fuzzy: 99.509 -> 99.56567%.
- Exact functions: 109/112 unchanged; exact code: 19988/24000 unchanged.
- Exact data: 4652/4652 unchanged; link status unchanged.
- All sibling function metrics and all other 1026 unit records unchanged.
Source SHA256 before:
`726f8910224b1f804a3bfcf5af4a4ea5ad8397d18889f0b7ed0e6841ecb97ec8`.
Source SHA256 after:
`fe5f1e07efec104d4adede90279fcb35470080b4f2eeadb495da73da7c98d9ce`.
Object SHA256 before:
`60d61cfbc40a8bd72bb04628c7a385004aff7c2b17a72421f3f10129a624f9cb`.
Object SHA256 after:
`677fd43d2cc7dc39bb0c728006c67d9498f9ca1a5046c2bc6812b2fe80a31fe4`.
## Instruction, continuation and relocation evidence
The target computes the window-name address at +0x50C, before the pane-manager
virtual call, then reuses it for both searches. The baseline instead computes
that same address separately for the two name arguments.
The candidate changes only these instructions relative to baseline:
- Inserts `addi r28,r29,0x738` at +0x50C.
- Moves the existing conditional branch to +0x510 and adjusts its destination
from baseline +0x514 to candidate +0x518, preserving the same continuation.
- Replaces the two address calculations at baseline +0x528/+0x538 with
`mr r4,r28` at candidate +0x52C/+0x53C.
Every instruction before the insertion is identical. Every later instruction
is identical under that single insertion-offset map except the branch and two
argument copies listed above. All earlier r28 uses have ended before its new
definition. The original data-base value r29 and new address value r28 survive
the same calls under the existing ABI. Frame 0x20, save/restore helper range,
all other argument registers and every direct/virtual call remain unchanged.
The new address is an addition, never a global-pointer or character load.
All allocated nontext section lengths and bytes, and all raw nontext relocation
section payloads, are byte-identical. Compiler string/symbol metadata is not
byte-identical. All text outside this function is byte-identical after
removing the respective function slices. Sibling function sizes and canonical
function-relative relocation targets are identical. This function's relocation
records follow exactly the same four-byte insertion-offset map.
An initial name-only audit flagged renamed compiler-generated `@NNNN` labels.
That failed check is preserved, not concealed. Resolving each data label to its
unchanged section/offset and each code target to function-plus-addend proves the
targets are unchanged. Later function placements move by four bytes because
the real function grows; these ordinary relocations are not new data, table
entry changes or metadata overrides. Canonical evidence is recorded separately
from the original name-only result.
Exhaustive accounting finds exactly four changed section payloads:
- `.text`: 28564 -> 28568 bytes. A positional comparison finds 20603 changed
common byte positions because the tail moves; the function-splice proof
establishes that every byte outside create is unchanged under that move.
- `.rela.text`: 4728 bytes unchanged in length, 335 changed bytes. All 394
records preserve raw type, symbol index and addend. Source offsets at or
after the actual insertion move by exactly four bytes: exactly 331 records
move, and the other 63 do not.
- `.symtab`: 5392 bytes unchanged in length, 131 changed bytes. Exactly 129
later STT_FUNC symbol values move by four bytes; only create's size changes,
from 1404 to 1408. All bindings, names, sizes of siblings and other fields
are unchanged.
- `.strtab`: 15521 bytes unchanged in length, 65 changed bytes representing
59 `@NNNN` names. Every renamed symbol is STB_LOCAL/STT_OBJECT, with the same
symbol index, string offset, section, section offset, size and other fields.
No public symbol name changes. These names do not describe different data.
All other section payloads are identical, including `.rela.ctors`, `.rela.rodata`,
`.rela.data` and `.rela.sdata`. The ELF header is identical. Section-header
changes are limited to `.text` size and `.ctors` physical file offset
28616 -> 28620. Four pre-rodata alignment bytes are consumed; overall file size
and the rodata file position remain unchanged.
The committed read-only verifier checks pinned object hashes, every changed
byte position, every symbol entry, all 752 relocation records and referents,
the function-splice relation and the exact instruction/branch mapping above.
It does not simply discard names or register numbers. Its optional details file
enumerates all before/after byte offsets, symbol entries and relocation targets.
Run from the leaf with cached tools:
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=../local-tools ../.venv/bin/python \
tools/decomp-assist/verify_tiCandidateBox_window_name.py \
../candidatebox-window-name-evidence/baseline.o \
build/43U/src/src/keyboard/tiCandidateBox.o \
--target build/43U/obj/src/keyboard/tiCandidateBox.o \
--details ../candidatebox-window-name-evidence/exhaustive-object-proof.json
## Full verification
- Full `all_source`, default `progress` and `build/43U/ok` passed.
- All other 1026 source-object hashes remain equal to the frozen reference.
- Fresh final report equals the immutable candidate report across all 1027
units; only this unit/function's fuzzy measures differ from baseline.
- All 109 exact siblings independently have zero instruction differences.
- Pool: all 57 strings identical.
- Literal advisory: 112 functions, 32 arguments, no skips, candidates or errors.
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
- `git diff --check` passes; no new assembly, padding, guards or fake storage.
- One real baseline and one candidate compilation. The full build rebuilt the
other 1026 objects but did not recompile this already-current candidate.
- After correcting the metadata accounting, the full build/ok/DOL, official
report, all 109 instruction-exact siblings and all 1026 other object hashes
were checked again. They pass with zero further compilations or source edits.
Private workspace evidence: `../candidatebox-window-name-evidence/`, containing
baseline/candidate source/object/report snapshots, exact patch, frozen reference
check, instruction/continuation and canonical relocation audits, original failed
name-only audit, pool/literal logs, full build and final-verification.json.
Original binaries remain local; none are committed.
GATE: strict fuzzy improvement with preserved exact/data/link/sibling gates.
Candidate retained only for independent parent review. No new exact-function,
whole-unit completion, Wii runtime execution, main change or remote action is
claimed. No follow-on variant was run.

View File

@@ -0,0 +1,204 @@
#!/usr/bin/env python3
"""Verify the single window-name capture against its compiled baseline.
Run with the project's venv and PYTHONPATH pointing to local-tools:
python verify_tiCandidateBox_window_name.py baseline.o candidate.o --details proof.json
This reads objects only. It never compiles or changes either input.
"""
import argparse
import hashlib
import json
import re
from pathlib import Path
from elftools.elf.elffile import ELFFile
from odiff import dis, sym
FUNCTION = "create__Q39textinput12candidatebox12LayoutByNW4RFP12MEMAllocator"
BASE_SHA = "60d61cfbc40a8bd72bb04628c7a385004aff7c2b17a72421f3f10129a624f9cb"
CANDIDATE_SHA = "677fd43d2cc7dc39bb0c728006c67d9498f9ca1a5046c2bc6812b2fe80a31fe4"
def read_object(path):
with path.open("rb") as stream:
elf = ELFFile(stream)
sections = {}
for section in elf.iter_sections():
sections[section.name] = {
"header": dict(section.header),
"data": section.data(),
}
symbols = []
for index, symbol in enumerate(elf.get_section_by_name(".symtab").iter_symbols()):
fields = dict(symbol.entry)
fields["st_info"] = dict(fields["st_info"])
fields["st_other"] = dict(fields["st_other"])
fields["name"] = symbol.name
fields["index"] = index
section_index = symbol["st_shndx"]
fields["section"] = elf.get_section(section_index).name if isinstance(section_index, int) else section_index
symbols.append(fields)
relocations = {}
for section in elf.iter_sections():
if section["sh_type"] != "SHT_RELA":
continue
relocations[section.name] = [
{
"offset": relocation["r_offset"],
"type": relocation["r_info_type"],
"symbol_index": relocation["r_info_sym"],
"addend": relocation["r_addend"],
}
for relocation in section.iter_relocations()
]
return dict(elf.header), sections, symbols, relocations
def changes(before, after):
return {key: [before[key], after[key]] for key in before if before[key] != after[key]}
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("baseline", type=Path)
parser.add_argument("candidate", type=Path)
parser.add_argument("--target", type=Path, help="Original local tiCandidateBox object, for target size/count checks")
parser.add_argument("--details", type=Path)
args = parser.parse_args()
assert hashlib.sha256(args.baseline.read_bytes()).hexdigest() == BASE_SHA
assert hashlib.sha256(args.candidate.read_bytes()).hexdigest() == CANDIDATE_SHA
ah, asecs, asyms, arels = read_object(args.baseline)
bh, bsecs, bsyms, brels = read_object(args.candidate)
assert asecs.keys() == bsecs.keys() and len(asyms) == len(bsyms) == 337
owner = next(s for s in asyms if s["name"] == FUNCTION)
start = owner["st_value"]
insertion = start + 0x50C
changed_sections = {}
header_changes = {}
for name in asecs:
a, b = asecs[name], bsecs[name]
delta = changes(a["header"], b["header"])
if delta:
header_changes[name] = delta
if a["data"] != b["data"]:
byte_differences = [[i, x, y] for i, (x, y) in enumerate(zip(a["data"], b["data"])) if x != y]
changed_sections[name] = {
"allocated": bool(a["header"]["sh_flags"] & 2),
"old_size": len(a["data"]),
"new_size": len(b["data"]),
"changed_common_bytes": len(byte_differences),
"byte_differences": byte_differences,
"old_tail": list(a["data"][len(b["data"]):]),
"new_tail": list(b["data"][len(a["data"]):]),
}
assert set(changed_sections) == {".text", ".rela.text", ".symtab", ".strtab"}
assert changed_sections[".strtab"]["changed_common_bytes"] == 65
assert changed_sections[".symtab"]["changed_common_bytes"] == 131
assert changed_sections[".rela.text"]["changed_common_bytes"] == 335
assert len(bsecs[".text"]["data"]) == len(asecs[".text"]["data"]) + 4
# Section payload bytes and section-header physical placement are distinct.
assert ah == bh
assert header_changes == {
".text": {"sh_size": [28564, 28568]},
".ctors": {"sh_offset": [28616, 28620]},
}
# Four bytes of pre-rodata file alignment absorb the longer text section.
assert args.baseline.stat().st_size == args.candidate.stat().st_size
assert asecs[".ctors"]["header"]["sh_size"] == bsecs[".ctors"]["header"]["sh_size"] == 4
assert asecs[".rodata"]["header"]["sh_offset"] == bsecs[".rodata"]["header"]["sh_offset"] == 28624
assert args.baseline.read_bytes()[28620:28624] == bytes(4)
symbol_changes = []
renamed = []
shifted = []
for a, b in zip(asyms, bsyms):
delta = changes(a, b)
if not delta:
continue
symbol_changes.append({"index": a["index"], "before": a, "after": b, "changes": delta})
if "name" in delta:
assert set(delta) == {"name"}
assert a["st_info"] == {"bind": "STB_LOCAL", "type": "STT_OBJECT"}
assert re.fullmatch(r"@\d+", a["name"]) and re.fullmatch(r"@\d+", b["name"])
assert a["section"] != ".text"
renamed.append(a["index"])
elif "st_size" in delta:
assert set(delta) == {"st_size"} and a["name"] == FUNCTION
assert a["st_size"] == 1404 and b["st_size"] == 1408
else:
assert set(delta) == {"st_value"} and a["section"] == ".text"
assert a["st_info"]["type"] == "STT_FUNC"
assert a["st_value"] >= start + 1404 and b["st_value"] == a["st_value"] + 4
shifted.append(a["index"])
assert len(renamed) == 59 and len(shifted) == 129 and len(symbol_changes) == 189
assert arels.keys() == brels.keys()
referent_checks = []
for section in arels:
assert len(arels[section]) == len(brels[section])
for a, b in zip(arels[section], brels[section]):
expected_offset = a["offset"] + (4 if section == ".rela.text" and a["offset"] >= insertion else 0)
assert b == dict(a, offset=expected_offset)
before, after = asyms[a["symbol_index"]], bsyms[b["symbol_index"]]
if before["section"] == ".text":
# Code referents retain the same named function and addend.
assert before["name"] == after["name"] and before["st_info"]["type"] == "STT_FUNC"
if before["name"] == FUNCTION:
assert a["addend"] == 0
else:
assert before["section"] == after["section"]
assert before["st_value"] == after["st_value"] and before["st_size"] == after["st_size"]
if before["name"] != after["name"]:
assert before["index"] in renamed
referent_checks.append({"relocation_section": section, "before": a, "after": b, "target_before": before, "target_after": after})
if section != ".rela.text":
assert asecs[section]["data"] == bsecs[section]["data"]
at, bt = asecs[".text"]["data"], bsecs[".text"]["data"]
assert at[:start] + at[start + 1404:] == bt[:start] + bt[start + 1408:]
a = dis(str(args.baseline), *sym(str(args.baseline), FUNCTION))
b = dis(str(args.candidate), *sym(str(args.candidate), FUNCTION))
point = 0x50C // 4
assert a[:point] == b[:point] and b[point] == ("addi", "r28, r29, 0x738")
instruction_changes = []
for i, old in enumerate(a):
j = i + (i >= point)
if old != b[j]:
instruction_changes.append((4 * i, 4 * j, old, b[j]))
assert instruction_changes == [
(0x50C, 0x510, ("beq", "0x514"), ("beq", "0x518")),
(0x528, 0x52C, ("addi", "r4, r29, 0x738"), ("mr", "r4, r28")),
(0x538, 0x53C, ("addi", "r4, r29, 0x738"), ("mr", "r4, r28")),
]
assert not any(re.search(r"\br28\b", operands) for _, operands in a[point:])
assert a[0] == b[0] == ("stwu", "r1, -0x20(r1)") and a[4] == b[4] and a[-6:] == b[-6:]
target_count = None
if args.target:
target_offset, target_size = sym(str(args.target), FUNCTION)
target = dis(str(args.target), target_offset, target_size)
assert target_size == 1408 and len(target) == 352 and target[0] == a[0]
target_count = {"bytes": target_size, "instructions": len(target)}
report = {
"function_counts": {"baseline": {"bytes": 1404, "instructions": len(a)}, "candidate": {"bytes": 1408, "instructions": len(b)}, "target": target_count},
"changed_sections": changed_sections,
"elf_header_changes": changes(ah, bh),
"section_header_changes": header_changes,
"symbol_changes": symbol_changes,
"private_renamed_symbols": renamed,
"relocation_referent_checks": referent_checks,
"instruction_changes_besides_insert": instruction_changes,
"all_allocated_nontext_payloads_identical": True,
"all_nontext_raw_relocation_sections_identical": True,
"all_sibling_text_identical_under_function_splice": True,
"all_relocation_referents_preserved": True,
"abi_and_branch_continuations_preserved": True,
}
if args.details:
args.details.write_text(json.dumps(report, indent=2) + "\n")
print(json.dumps({"verified": True, "changed_sections": {k: {x: y for x, y in v.items() if x not in ("byte_differences", "old_tail", "new_tail")} for k, v in changed_sections.items()}, "private_name_changes": len(renamed), "code_symbol_shifts": len(shifted), "relocations_verified": len(referent_checks)}, indent=2))
if __name__ == "__main__":
main()