Compare commits
1 Commits
main
...
agent/bitt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
798b08a1e3 |
@@ -394,7 +394,9 @@ namespace textinput {
|
||||
mOnOffButton.Create(this);
|
||||
mOnOffButton.Init();
|
||||
const char* paneNames = scPaneNameTable;
|
||||
mLeftScroll.Create(this, paneNames + 68, paneNames + 48);
|
||||
const char* leftScrollBoundName = paneNames + 48;
|
||||
const char* leftScrollPaneName = paneNames + 68;
|
||||
mLeftScroll.Create(this, leftScrollPaneName, leftScrollBoundName);
|
||||
mRightScroll.Create(this, paneNames + 108, paneNames + 88);
|
||||
mLeftScroll.Init();
|
||||
mRightScroll.Init();
|
||||
|
||||
187
tools/decomp-assist/tiCandidateBox-left-names-20261003.md
Normal file
187
tools/decomp-assist/tiCandidateBox-left-names-20261003.md
Normal file
@@ -0,0 +1,187 @@
|
||||
# Left-scroll address capture, 2026-10-03
|
||||
|
||||
Base: `30d968099a52cc95308f99ba589b2a91c0bc7645`, 43U only.
|
||||
Branch: `agent/bittle/candidatebox-left-names`. One authorized candidate.
|
||||
|
||||
## Source scope and history
|
||||
|
||||
The sole production change captures two real arguments immediately before the
|
||||
existing left-scroll Create call:
|
||||
|
||||
const char* leftScrollBoundName = paneNames + 48;
|
||||
const char* leftScrollPaneName = paneNames + 68;
|
||||
mLeftScroll.Create(this, leftScrollPaneName, leftScrollBoundName);
|
||||
|
||||
The existing paneNames initializer, right-scroll call, accepted window-name
|
||||
capture, all constructors, helpers and subsequent statements remain unchanged.
|
||||
Both locals are initialized, unshadowed and not address-taken. Only their values
|
||||
are passed; no new local storage is exposed to a callback.
|
||||
|
||||
paneNames is a local const-char pointer initialized once from the sole definition
|
||||
of `scPaneNameTable`, a const char[132] object. This is fixed array storage, not
|
||||
a mutable global pointer read. Original and compiled objects agree on size 132,
|
||||
`.data+0x6B4`, target address 0x8165D984 and all bytes. Offsets 48 and 68 point to
|
||||
the B_prdc_scrl_Left and P_prdc_scrl_Left records. Each name has 16 characters
|
||||
plus NUL, 17 bytes within its 20-byte record; ends 65 and 85 lie within 132.
|
||||
The transformation caches addresses, not character contents.
|
||||
|
||||
UIButton::Create is unchanged. Its observable order remains getPaneManager,
|
||||
searchPaneComponent(s1), searchPaneComponent(s2), searchAnmPane(s1), then setting
|
||||
the bounding pane listener. Both pointer additions are side-effect-free and
|
||||
remain within the same array. All lookup arguments and their order are retained.
|
||||
|
||||
Target create +0x3F4/+0x3F8 materializes the bounding and visible-pane addresses
|
||||
before the pane-manager call. The baseline rematerializes them for the three
|
||||
lookup arguments. The previously accepted window capture supports the source
|
||||
form, but is not treated as a promise of this candidate's result.
|
||||
|
||||
Prior rt8.attempts.md:86-89 includes removing the shared paneNames base and
|
||||
passing direct array expressions, yielding 353/352 instructions. data-d15:341
|
||||
includes a full-array reference; earlier logs include receiver and shared Init
|
||||
loop changes. No exact two-local left-pair capture was found in the surviving
|
||||
records. Those historical source snapshots are unavailable, so broader overlap
|
||||
cannot be excluded. No old numeric result is claimed for this specific form.
|
||||
|
||||
## Frozen baseline and measured result
|
||||
|
||||
The baseline came from parent `wii-candidatebox-review`, HEAD
|
||||
`60c782b0e7ea507e4f74a2d0419cec9c6527c84d`, tree
|
||||
`598351eedd350d39d3f4edabed2b861d055b497f`, identical to the selected base tree.
|
||||
All 1027 cached objects were checked. The real baseline compile and complete
|
||||
official report reproduced this frozen reference exactly.
|
||||
|
||||
- create fuzzy: 93.67614 -> 94.59091%.
|
||||
- Unit fuzzy: 99.56567 -> 99.61933%.
|
||||
- Baseline: 1408 bytes / 352 instructions / frame 0x20.
|
||||
- Candidate: 1416 bytes / 354 instructions / frame 0x30.
|
||||
- Original target: 1408 bytes / 352 instructions / frame 0x20.
|
||||
- Exact functions 109/112, matched code 19988/24000, exact data 4652/4652,
|
||||
and link status are unchanged.
|
||||
|
||||
The larger frame and extra two instructions are real costs, not hidden or
|
||||
treated as original matches. Score alone is not acceptance.
|
||||
|
||||
Source hashes before/after:
|
||||
`fe5f1e07efec104d4adede90279fcb35470080b4f2eeadb495da73da7c98d9ce`
|
||||
`936ab4742caa71293284a33425f73321f172dc5b563cc215c7f213ddd3bef3e3`.
|
||||
Object hashes before/after:
|
||||
`677fd43d2cc7dc39bb0c728006c67d9498f9ca1a5046c2bc6812b2fe80a31fe4`
|
||||
`31106c95cfcd2e8274f43ee2b5eb51be9861e577a5d967a96e667766feb71200`.
|
||||
|
||||
## Exact instruction and lifetime mapping
|
||||
|
||||
Two address calculations are inserted at candidate +0x404/+0x408:
|
||||
`addi r26,r30,0x30` and `addi r25,r30,0x44`. r30 is proved to be .data+0x6B4,
|
||||
defined at baseline +0x29C from the unchanged r29 data base. These non-recording
|
||||
instructions do not alter the condition register between the comparison and
|
||||
existing branch.
|
||||
|
||||
The baseline left-call arguments at +0x424/+0x434/+0x444 become candidate
|
||||
+0x42C/+0x43C/+0x44C register copies from r25/r26/r25. Branch mappings are
|
||||
baseline +0x404 -> candidate +0x40C (target +0x40C -> +0x414), +0x470 -> +0x478
|
||||
(target +0x478 -> +0x480), and +0x510 -> +0x518 (target +0x518 -> +0x520).
|
||||
All other following instruction locations advance by eight bytes.
|
||||
|
||||
The allocator's register role changes r27 -> r25 only at its definition +0x18
|
||||
and five argument moves +0x24/+0x54/+0x64/+0xCC/+0x110. Its last use precedes
|
||||
the later left-pane definition. The retained window address changes r28 -> r25
|
||||
only at its own definition and two argument moves, baseline offsets
|
||||
+0x50C/+0x52C/+0x53C. These are separate per-definition lifetimes, not a blanket
|
||||
register renaming. All remaining differences are the explicit prologue/epilogue
|
||||
changes below. The verifier checks all 23 changed existing instructions and both
|
||||
insertions; everything else is instruction-identical under the location map.
|
||||
|
||||
### Stack and ABI audit
|
||||
|
||||
The frame increases by 16 bytes, retaining 16-byte alignment. r1/r11 occur only
|
||||
in six prologue/epilogue instructions. No other stack-relative load/store, stack
|
||||
address formation, stack argument, address-taken local, or stack address passed
|
||||
to a lookup/allocation/callback exists in this function. Existing object/member
|
||||
addresses remain based on this; allocation buffers are heap values. No stack
|
||||
address is explicitly retained, compared or hashed by the owned code.
|
||||
|
||||
Both versions save LR at incoming-SP+4. Both reconstruct r11 as incoming SP for
|
||||
the save/restore helpers. Existing r27-r31 slots stay at incoming-SP-20 through
|
||||
-4. Candidate adds r25/r26 at incoming-SP-28/-24, inside its larger private
|
||||
frame. The actual `_savegpr_25` and `_restgpr_25` bodies were compared with the
|
||||
original Runtime object: seven matching word stores/loads followed by blr.
|
||||
They touch no argument register and restore every additional callee-saved GPR.
|
||||
The common epilogue restores LR and incoming SP on the sole return path.
|
||||
|
||||
Ordinary ABI argument values, object addresses and branch continuations are
|
||||
preserved. The 16 extra stack bytes remain a resource cost. No Wii runtime,
|
||||
stack-exhaustion equivalence or arbitrary callback stack-introspection
|
||||
equivalence is claimed. Parent review of this measured larger-frame candidate
|
||||
is required; no attempt was made to force the old frame.
|
||||
|
||||
## Exhaustive object accounting
|
||||
|
||||
All allocated nontext section sizes and payloads are identical. Text outside
|
||||
create is identical after removing the respective function slices. Exactly six
|
||||
section payloads change:
|
||||
- .text: 28568 -> 28576 bytes; 21016 positional common bytes differ due to the
|
||||
insertion and tail shift, with the exact function-splice relation verified.
|
||||
- .rela.text: same 4728-byte length, 397 changed bytes.
|
||||
- .rela.data: same 3780-byte length, 40 changed bytes. Raw bytes are NOT identical.
|
||||
- .symtab: same 5392-byte length, 320 changed bytes.
|
||||
- .strtab: same 15521-byte length, 2665 changed bytes.
|
||||
- .comment: same 2740-byte length, 26 changed bytes.
|
||||
|
||||
The verifier proves a bijection of all 337 symbols. 59 private STB_LOCAL/
|
||||
STT_OBJECT @NNNN names advance by two, with data section/offset/extent and all
|
||||
other semantic attributes unchanged. No public name changes or symbols appear
|
||||
or disappear. 44 symbol indices reorder; 129 later function values move by
|
||||
eight bytes; only create's size increases. Both complete string tables are
|
||||
reconstructed from the checked symbol-name intervals, accounting for every byte.
|
||||
|
||||
All 752 relocation records are checked. Exactly 335 .rela.text source offsets
|
||||
move by eight bytes; types and addends do not change. 53 text and 40 data
|
||||
relocation symbol indices change. The data changes and all but two text changes
|
||||
resolve through the proved symbol bijection to the same targets. The two
|
||||
explicit exceptions are create's save/restore helper calls, r27 -> r25, whose
|
||||
actual behavior is verified above. All sibling relocation referents and
|
||||
function-relative instruction semantics remain unchanged.
|
||||
|
||||
The entire .comment difference is accounted byte-for-byte as an unchanged
|
||||
44-byte prefix followed by 337 unchanged eight-byte records permuted by the
|
||||
same symbol-index bijection. This is an exact byte relationship, not an
|
||||
assumption that an unknown metadata difference can be ignored. The ELF section
|
||||
table/file offsets advance by eight bytes after the enlarged .text section;
|
||||
file size also grows by eight. All other section payloads remain identical.
|
||||
|
||||
## Validation and reproduction
|
||||
|
||||
- Full all_source/default progress/build/43U/ok passes; DOL SHA1 remains
|
||||
`26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
- All other 1026 source objects and complete unit records equal frozen baseline.
|
||||
- All 109 exact functions independently compare at zero instruction differences.
|
||||
- Fresh final report equals the immutable candidate report; no sibling metrics
|
||||
or data/exact/link measure regressions exist.
|
||||
- Pool: 57 identical strings.
|
||||
- Literal advisory: 111 functions/27 arguments pass, zero candidates/errors.
|
||||
create is explicitly skipped because its size now differs from target. The
|
||||
exact instruction/lifetime map and original-array address/byte checks above
|
||||
supply the separate argument evidence; the automated skip is not concealed.
|
||||
- One real baseline and one candidate compilation; the full build rebuilt the
|
||||
other 1026 objects, with no candidate recompile or follow-on form.
|
||||
|
||||
Runnable read-only proof, using cached tools from this leaf:
|
||||
|
||||
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=../local-tools ../.venv/bin/python \
|
||||
tools/decomp-assist/verify_tiCandidateBox_left_names.py \
|
||||
../candidatebox-left-names-evidence/baseline.o \
|
||||
build/43U/src/src/keyboard/tiCandidateBox.o \
|
||||
--target build/43U/obj/src/keyboard/tiCandidateBox.o \
|
||||
--runtime build/43U/src/libs/Runtime/src/runtime.o \
|
||||
--original-runtime build/43U/obj/libs/Runtime/src/runtime.o \
|
||||
--details ../candidatebox-left-names-evidence/exhaustive-proof.json
|
||||
|
||||
Evidence is local in `../candidatebox-left-names-evidence/`: immutable sources,
|
||||
objects, reports, patch and compile logs; full build; pool/literal advisory;
|
||||
exhaustive symbol/section/relocation/instruction proof; final-verification.json.
|
||||
Original binaries are not committed. Source remains frozen at the one measured
|
||||
candidate. No main or remote action occurred.
|
||||
|
||||
GATE: strict fuzzy gain with exact/data/link/sibling preservation; larger frame
|
||||
and literal-tool skip explicitly disclosed. Candidate awaits independent parent
|
||||
review, with no claim of exact completion or acceptance from score alone.
|
||||
231
tools/decomp-assist/verify_tiCandidateBox_left_names.py
Normal file
231
tools/decomp-assist/verify_tiCandidateBox_left_names.py
Normal file
@@ -0,0 +1,231 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only verification of the single two-address left-scroll candidate.
|
||||
|
||||
Use the project's venv with PYTHONPATH=../local-tools. Inputs are immutable
|
||||
compiled objects; no compilation or source rewriting is performed.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
|
||||
from pathlib import Path
|
||||
from odiff import dis, sym
|
||||
from verify_tiCandidateBox_window_name import read_object, changes
|
||||
|
||||
|
||||
FUNCTION = "create__Q39textinput12candidatebox12LayoutByNW4RFP12MEMAllocator"
|
||||
BASE_SHA = "677fd43d2cc7dc39bb0c728006c67d9498f9ca1a5046c2bc6812b2fe80a31fe4"
|
||||
CANDIDATE_SHA = "31106c95cfcd2e8274f43ee2b5eb51be9861e577a5d967a96e667766feb71200"
|
||||
|
||||
|
||||
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, required=True)
|
||||
parser.add_argument("--runtime", type=Path, required=True)
|
||||
parser.add_argument("--original-runtime", type=Path, required=True)
|
||||
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)
|
||||
_, tsecs, tsyms, _ = read_object(args.target)
|
||||
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 + 0x404
|
||||
mapping = {}
|
||||
private_names = []
|
||||
symbol_proof = []
|
||||
code_shifts = []
|
||||
for old in asyms:
|
||||
private = re.fullmatch(r"@\d+", old["name"]) and old["st_info"]["bind"] == "STB_LOCAL"
|
||||
if not old["name"]:
|
||||
matches = [s for s in bsyms if s == old]
|
||||
elif private:
|
||||
matches = [s for s in bsyms if s["name"] == "@" + str(int(old["name"][1:]) + 2)]
|
||||
else:
|
||||
matches = [s for s in bsyms if s["name"] == old["name"]]
|
||||
assert len(matches) == 1, old["name"]
|
||||
new = matches[0]
|
||||
mapping[old["index"]] = new["index"]
|
||||
# String offsets and indices may move, but all semantic fields are checked.
|
||||
expected = dict(old, index=new["index"], st_name=new["st_name"], name=new["name"])
|
||||
if private:
|
||||
assert old["st_info"] == {"bind": "STB_LOCAL", "type": "STT_OBJECT"}
|
||||
assert old["section"] != ".text"
|
||||
private_names.append([old["index"], old["name"], new["name"]])
|
||||
else:
|
||||
assert old["name"] == new["name"]
|
||||
if old["name"] == FUNCTION:
|
||||
assert old["st_size"] == 1408
|
||||
expected["st_size"] = 1416
|
||||
elif old["section"] == ".text" and old["st_value"] >= start + 1408:
|
||||
assert old["st_info"]["type"] == "STT_FUNC"
|
||||
expected["st_value"] += 8
|
||||
code_shifts.append(old["index"])
|
||||
assert new == expected, (old, new, expected)
|
||||
symbol_proof.append({"before": old, "after": new})
|
||||
assert len(set(mapping.values())) == 337 and len(private_names) == 59 and len(code_shifts) == 129
|
||||
assert sum(i != j for i, j in mapping.items()) == 44
|
||||
arrays = []
|
||||
for sections, symbols in [(asecs, asyms), (bsecs, bsyms), (tsecs, tsyms)]:
|
||||
array = next(s for s in symbols if s["name"] == "scPaneNameTable")
|
||||
assert array["section"] == ".data" and array["st_value"] == 0x6B4 and array["st_size"] == 132
|
||||
data = sections[".data"]["data"][0x6B4:0x6B4 + 132]
|
||||
assert data[48:65] == b"B_prdc_scrl_Left\0" and data[68:85] == b"P_prdc_scrl_Left\0"
|
||||
arrays.append(data)
|
||||
assert arrays[0] == arrays[1] == arrays[2]
|
||||
|
||||
# Reconstruct both complete string tables from their symbol-name intervals.
|
||||
# This also verifies every st_name and accounts for every metadata byte.
|
||||
for sections, symbols in [(asecs, asyms), (bsecs, bsyms)]:
|
||||
data = sections[".strtab"]["data"]
|
||||
reconstructed = bytearray(len(data))
|
||||
covered = {0}
|
||||
for s in symbols:
|
||||
encoded = s["name"].encode() + b"\0"
|
||||
at = s["st_name"]
|
||||
assert data[at:at + len(encoded)] == encoded
|
||||
reconstructed[at:at + len(encoded)] = encoded
|
||||
covered.update(range(at, at + len(encoded)))
|
||||
assert bytes(reconstructed) == data and len(covered) == len(data)
|
||||
ac, bc = asecs[".comment"]["data"], bsecs[".comment"]["data"]
|
||||
assert ac[:44] == bc[:44] and len(ac) == len(bc) == 44 + 8 * 337
|
||||
comment_records = []
|
||||
for i, j in mapping.items():
|
||||
old, new = ac[44 + 8 * i:44 + 8 * (i + 1)], bc[44 + 8 * j:44 + 8 * (j + 1)]
|
||||
assert old == new
|
||||
comment_records.append([i, j, old.hex()])
|
||||
|
||||
relocation_proof = []
|
||||
helper_changes = []
|
||||
assert arels.keys() == brels.keys()
|
||||
for section in arels:
|
||||
assert len(arels[section]) == len(brels[section])
|
||||
for old, new in zip(arels[section], brels[section]):
|
||||
expected = dict(old)
|
||||
expected["symbol_index"] = mapping[old["symbol_index"]]
|
||||
if section == ".rela.text" and old["offset"] >= insertion:
|
||||
expected["offset"] += 8
|
||||
target = asyms[old["symbol_index"]]
|
||||
if section == ".rela.text" and old["offset"] in (start + 0x10, start + 0x56C):
|
||||
required = "_savegpr_27" if old["offset"] == start + 0x10 else "_restgpr_27"
|
||||
assert target["name"] == required and old["type"] == 10 and old["addend"] == 0
|
||||
new_name = required.replace("27", "25")
|
||||
new_target = next(s for s in bsyms if s["name"] == new_name)
|
||||
expected["symbol_index"] = new_target["index"]
|
||||
helper_changes.append([required, new_name, old["offset"], expected["offset"]])
|
||||
else:
|
||||
new_target = bsyms[expected["symbol_index"]]
|
||||
if target["name"] == FUNCTION:
|
||||
assert old["addend"] == 0
|
||||
# The proved bijection checks exact identity/extent for data and
|
||||
# named function plus unchanged addend for all code referents.
|
||||
assert new_target["section"] == target["section"]
|
||||
assert new == expected, (section, old, new, expected)
|
||||
relocation_proof.append({"section": section, "before": old, "after": new,
|
||||
"target_before": target, "target_after": bsyms[new["symbol_index"]]})
|
||||
assert len(helper_changes) == 2 and len(relocation_proof) == 752
|
||||
|
||||
section_changes = {}
|
||||
header_changes = {}
|
||||
for name in asecs:
|
||||
a, b = asecs[name], bsecs[name]
|
||||
if a["header"]["sh_flags"] & 2 and name != ".text":
|
||||
assert a["data"] == b["data"] and a["header"]["sh_size"] == b["header"]["sh_size"]
|
||||
delta = changes(a["header"], b["header"])
|
||||
if delta:
|
||||
header_changes[name] = delta
|
||||
if name == ".text":
|
||||
assert delta == {"sh_size": [28568, 28576]}
|
||||
else:
|
||||
assert delta == {"sh_offset": [a["header"]["sh_offset"], a["header"]["sh_offset"] + 8]}
|
||||
if a["data"] != b["data"]:
|
||||
diffs = [[i, x, y] for i, (x, y) in enumerate(zip(a["data"], b["data"])) if x != y]
|
||||
section_changes[name] = {"old_size": len(a["data"]), "new_size": len(b["data"]),
|
||||
"changed_common_bytes": len(diffs), "byte_differences": diffs,
|
||||
"old_tail": list(a["data"][len(b["data"]):]),
|
||||
"new_tail": list(b["data"][len(a["data"]):])}
|
||||
assert set(section_changes) == {".text", ".rela.text", ".rela.data", ".symtab", ".strtab", ".comment"}
|
||||
assert {k: v["changed_common_bytes"] for k, v in section_changes.items()} == {
|
||||
".text": 21016, ".rela.text": 397, ".rela.data": 40, ".symtab": 320, ".strtab": 2665, ".comment": 26}
|
||||
assert changes(ah, bh) == {"e_shoff": [66056, 66064]}
|
||||
assert args.candidate.stat().st_size == args.baseline.stat().st_size + 8
|
||||
at, bt = asecs[".text"]["data"], bsecs[".text"]["data"]
|
||||
assert at[:start] + at[start + 1408:] == bt[:start] + bt[start + 1416:]
|
||||
|
||||
a = dis(str(args.baseline), *sym(str(args.baseline), FUNCTION))
|
||||
b = dis(str(args.candidate), *sym(str(args.candidate), FUNCTION))
|
||||
original = dis(str(args.target), *sym(str(args.target), FUNCTION))
|
||||
assert len(a) == len(original) == 352 and len(b) == 354
|
||||
expected = list(a)
|
||||
replacements = {
|
||||
0x000: ("stwu", "r1, -0x30(r1)"), 0x008: ("stw", "r0, 0x34(r1)"),
|
||||
0x00C: ("addi", "r11, r1, 0x30"), 0x010: ("bl", "_savegpr_25+0 [reloc 10]"),
|
||||
0x018: ("mr", "r25, r4"), 0x024: ("mr", "r3, r25"),
|
||||
0x054: ("mr", "r4, r25"), 0x064: ("mr", "r3, r25"),
|
||||
0x0CC: ("mr", "r4, r25"), 0x110: ("mr", "r4, r25"),
|
||||
0x404: ("beq", "0x414"), 0x424: ("mr", "r4, r25"),
|
||||
0x434: ("mr", "r4, r26"), 0x444: ("mr", "r4, r25"),
|
||||
0x470: ("beq", "0x480"), 0x50C: ("addi", "r25, r29, 0x738"),
|
||||
0x510: ("beq", "0x520"), 0x52C: ("mr", "r4, r25"),
|
||||
0x53C: ("mr", "r4, r25"), 0x568: ("addi", "r11, r1, 0x30"),
|
||||
0x56C: ("bl", "_restgpr_25+0 [reloc 10]"), 0x570: ("lwz", "r0, 0x34(r1)"),
|
||||
0x578: ("addi", "r1, r1, 0x30"),
|
||||
}
|
||||
for offset, instruction in replacements.items():
|
||||
assert expected[offset // 4] != instruction
|
||||
expected[offset // 4] = instruction
|
||||
point = 0x404 // 4
|
||||
inserted = [("addi", "r26, r30, 0x30"), ("addi", "r25, r30, 0x44")]
|
||||
expected[point:point] = inserted
|
||||
assert expected == b
|
||||
# Explicit provenance of both captured values and the retained window name.
|
||||
assert a[0x14 // 4] == ("lis", "r29, .data+0 [reloc 6]")
|
||||
assert a[0x28 // 4] == ("addi", "r29, r29, .data+0 [reloc 4]")
|
||||
assert a[0x29C // 4] == ("addi", "r30, r29, 0x6b4")
|
||||
stack_refs = [(4 * i, instruction) for i, instruction in enumerate(b)
|
||||
if re.search(r"\br1\b|\br11\b", instruction[1])]
|
||||
assert [x[0] for x in stack_refs] == [0, 8, 12, 0x570, 0x578, 0x580]
|
||||
# No other baseline use of these new registers can be hidden by a rename.
|
||||
assert not any(re.search(r"\br25\b|\br26\b", operands) for _, operands in a)
|
||||
allocator_refs = [4 * i for i, (_, op) in enumerate(a[:0x118 // 4]) if re.search(r"\br27\b", op)]
|
||||
assert allocator_refs == [0x18, 0x24, 0x54, 0x64, 0xCC, 0x110]
|
||||
window_refs = [4 * i for i, (_, op) in enumerate(a[0x50C // 4:], 0x50C // 4) if re.search(r"\br28\b", op)]
|
||||
assert window_refs == [0x50C, 0x52C, 0x53C]
|
||||
assert a[0] == original[0] == ("stwu", "r1, -0x20(r1)")
|
||||
helpers = {}
|
||||
operands = ["r25, -0x1c(r11)", "r26, -0x18(r11)", "r27, -0x14(r11)",
|
||||
"r28, -0x10(r11)", "r29, -0xc(r11)", "r30, -8(r11)", "r31, -4(r11)"]
|
||||
for name, mnemonic in [("_savegpr_25", "stw"), ("_restgpr_25", "lwz")]:
|
||||
expected_helper = [(mnemonic, op) for op in operands] + [("blr", "")]
|
||||
for path in [args.runtime, args.original_runtime]:
|
||||
offset, _ = sym(str(path), name)
|
||||
assert dis(str(path), offset, 32) == expected_helper
|
||||
helpers[name] = expected_helper
|
||||
result = {"function_counts": {"baseline": [1408, 352], "candidate": [1416, 354], "target": [1408, 352]},
|
||||
"frames": {"baseline": 32, "candidate": 48, "target": 32},
|
||||
"extra_stack_bytes": 16, "stack_references": stack_refs, "helper_bodies": helpers,
|
||||
"inserted_instructions": inserted, "instruction_replacements_at_baseline_offsets": replacements,
|
||||
"symbol_bijection": mapping, "symbol_proof": symbol_proof, "private_names": private_names,
|
||||
"comment_record_bijection": comment_records, "section_changes": section_changes,
|
||||
"section_header_changes": header_changes, "elf_header_changes": changes(ah, bh),
|
||||
"relocation_proof": relocation_proof, "helper_relocation_changes": helper_changes,
|
||||
"all_allocated_nontext_bytes_identical": True, "all_sibling_text_identical_under_splice": True,
|
||||
"ordinary_call_arguments_and_branch_continuations_preserved": True,
|
||||
"no_stack_address_arguments_except_proved_save_restore_helpers": True}
|
||||
if args.details:
|
||||
args.details.write_text(json.dumps(result, indent=2) + "\n")
|
||||
print(json.dumps({"verified": True, "function_counts": result["function_counts"], "frames": result["frames"],
|
||||
"private_names": len(private_names), "symbol_indices_moved": 44, "code_symbols_shifted": len(code_shifts),
|
||||
"relocations_checked": len(relocation_proof), "helper_target_changes": helper_changes,
|
||||
"changed_section_bytes": {k: v["changed_common_bytes"] for k, v in section_changes.items()}}, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user