Compare commits

..

1 Commits

Author SHA1 Message Date
coah
306ff59554 fix: model Run stack address independently of printf 2026-10-02 17:46:45 -05:00
6 changed files with 58 additions and 32 deletions

View File

@@ -37,6 +37,9 @@ force_active:
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
block_relocations:
# Run establishes a fixed stack at 0x81600000, not __pformatter + 0x280.
- source: .text:0x8137B468
- source: .text:0x8137B46C
- source: .data:0x8165E15C
- source: .data:0x8165E19C

View File

@@ -242,8 +242,6 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
extern vu32 BS2VideoMode;
extern vu32 __DVDLayoutFormat;
extern void __pformatter(void);
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
// clang-format off
#ifdef __MWERKS__
@@ -282,8 +280,9 @@ asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
li r30, 0
li r31, 0
lis r1, __pformatter+640@h
ori r1, r1, (__pformatter+640)@l
// The application stack is fixed; it is unrelated to the formatter.
lis r1, 0x8160
ori r1, r1, 0
li r6, 0
b Run_loop_entry

View File

@@ -1610,7 +1610,7 @@ namespace textinput {
}
void Base::setTranslateMode(TranslateMode mode) {
u32 keyMode;
u32 keyMode = mode;
switch (mode) {
case TM_Direct:
keyMode = 0;

View File

@@ -1,14 +0,0 @@
## scanAP (w1010 revisit) — inlined-bool materialization wall
Orig inlines `Animator::isPlaying()` (`mState == 1` at +0x14) 3x but always as a
MATERIALIZED bool: `lwz rX,0x14; addi r0,rX,-1; cntlzw r0,r0; rlwinm. r0,r0,27,5,31; bne`.
Ours fuses to `lwz r0,0x14; cmpwi r0,1; beq` — 6 insns shorter overall (272 vs 266).
Tried and rejected (MWCC normalizes/folds all of them):
- `isPlaying() == false` at the call site
- `bool playing = anim->isPlaying(); if (!playing)` named local (fuses; eggColorFader's
fadeOut materializes only because `success` is also RETURNED — a second value-use)
- `int isPlaying()` return type — still fuses
- `return !(mState != ANIM_STATE_PLAY)` in the header — still fuses
Conclusion: orig's bool crosses a real value-boundary (2nd use, or a different inlined
shape we haven't identified). Same family as the fused-compare fossil in CHANSVm.
Also tried: convertRevIP untouched (98.7, 292B).

View File

@@ -0,0 +1,51 @@
# Run fixed-stack relocation correction
This is a narrow follow-up to #973, not another Run implementation or a new
match. The existing assembly, cache loop, register clearing, labels and handoff
remain intact. No linking flag changes.
## Evidence
The hash-verified original DOL and linked ELF contain Run at 0x8137B3EC,
size 0xAC (43 instructions). Its instructions at 0x8137B468/0x8137B46C establish
SP as 0x81600000. This architectural stack value should not depend on placement
of an unrelated formatted-output routine.
Automatic extraction had attached two relocations to __pformatter + 0x280:
R_PPC_ADDR16_HI at Run+0x7E and R_PPC_ADDR16_LO at Run+0x82. The linked formatter
address happens to make this expression equal 0x81600000 in this target, but
that is a false semantic dependency in the reconstruction.
DTK block_relocations uses instruction addresses, not ELF halfword offsets.
The two exclusions are therefore .text:0x8137B468 and .text:0x8137B46C.
The source removes the unrelated extern and uses the fixed high/low immediate.
No other source instructions or original bytes are replaced.
## Independent validation
- Full 43U all_source, progress, report and DOL check pass.
- Original app and rebuilt DOL SHA1 both remain
26116613f624061ba99c8d1a299aaa6efa85670d.
- Run remains 100%, 43/43 instructions, ctxdiff zero. No new match attribution.
- Whole report is unchanged: no code, data, function, linking or fuzzy delta.
- Pool: all 91 strings identical.
- All 1027 native source objects compared: only BS2Mach .text changes; size
16960 is unchanged. Exactly the two false text relocations are removed.
All other allocated objects and data sections are unchanged.
- All 1027 active extracted objects compared, plus the same obsolete cached
tiManager.o in both trees. Only BS2Mach .text changes: size 16980 unchanged;
only Run's high immediate placeholder bytes at +0x7E/+0x7F become 0x81,0x60.
Exactly the two formatter relocations disappear, with no added relocations.
Defined target symbols and non-text sections stay unchanged.
- Supplemental integer-PPC contract model checks the compiled source for 1,
4 and 131072 cache lines, preserved LR entry, SP 0x81600000, cleared GPRs and
alternating dcbz/dcbf events. The zero-count prefix retains the original CTR
wrap to 0xFFFFFFFF; the full 2^32-iteration path is not executed. This is an
abstract contract test, not actual cache/MMIO or console execution.
- Workflow/literal/jump-table/pool tests: 8/36/27/8 passed.
- Diff check passes.
Assembly was already introduced by #973. The original isolated full-Run
experiment is deliberately not included here. This correction adds no new
assembly instructions, forced register uses, retail .s objects or padding.
Please review the metadata/source constant attribution explicitly.

View File

@@ -15,16 +15,3 @@ Initial reconstruction uses the sibling tiString and tiUtil headers, real member
## character predicates
The sibling util declarations return bool, while target callers normalize an integer result. Guarded u32 declarations preserve every other translation unit and make all three predicates 16/16 with zero differences.
## inputChar (w1010 orchestrator probe) — indexed-store + dead-compare fossil
Orig mode==3 block (this->0x24==3) emits: `sth r6,0x10` (input[0]=0, r6=0 reused as
value), `cmplwi r4,0xa` (DEAD compare — no branch consumes it), then indexed stores
`slwi r0,r6,1; sthx r4,buf,r0; addi r6,1; slwi r0,r6,1; clrlwi r29,r6,0x10; sthx r5,buf,r0`
= input[i]=ch; i++; input[i]=0 with the index kept SYMBOLIC despite li i,0.
Ours: direct-offset `sth r4,0x10; li r29,1; sth r5,0x12` (125 vs 136 insns).
Tried: `input[i]=ch; i++; input[i]=0; count=i` — MWCC constant-folds i to 0,
re-emits direct offsets. Index must be runtime-opaque in orig (loop bound from a
call result, or a non-foldable form). Dead `cmplwi r4,0xa` matches the documented
dead-compare-fossil family (both-branch merge). Also: count lands in r29 via
clrlwi (u16) — count is i.
Unresolved: what source produces symbolic-index stores + dead compare.