b26: S17 safe-logger baked

This commit is contained in:
lumia-emu
2026-09-13 12:08:22 +00:00
parent 4e38215e86
commit 42227147d4
4 changed files with 120 additions and 5 deletions
+82
View File
@@ -1044,6 +1044,88 @@ def main():
save(d, 'img0_b25.elf')
# b26 = b25 + S17 safe-logger (0x8034810 pop.w -> b.w S17):
# S8 (bx lr) silenced all init logging (UART empty by design).
# S17 (50B @0x08006CF0, scaffold): print r1-string via UARTDM-TF
# only if r1 in rodata [0x804B800,0x8058000) (wild pointers skip),
# then pop-return (no leak, return value ignored by callers).
d = bytearray(base)
for va, (a, b) in BLX2BL.items():
set4(d, va, b)
for va, exp, new in [
(0x802F664, 'e4f77efc', 'c046c046'),
(0x802F672, 'e6f7bbfa', 'c046c046'),
(0x802F678, 'e9f7fef9', 'c046c046'),
(0x801B71E, '9847fee7', 'c046c046'),
(0x8008396, 'fef780f9', 'c046c046'),
(0x8016184, 'fdf790fc', 'c046c046'),
(0x801B76C, '280b0508', '00000708'),
(0x8017AFC, 'bde8fc87', 'eef74fb8'),
(0x802F690, '9847fee7', 'c046c046'),
(0x801671C, '9847fee7', 'c046c046'),
(0x8013BAC, 'f8bd0a4a', 'f3f730b8'),
(0x801B6BE, 'bde8f081', 'ebf7c3ba'),
(0x8016720, '10bd0000', 'f0f7b2ba'),
(0x8034810, 'bde8fc87', 'd2f76eba'),
]:
assert hx(d, va) == exp, (hex(va), hx(d, va))
set4(d, va, new)
# Full bl idiom at 0x8006682 (bl + pop, 6B) -> NOPs (see b18).
o = off(0x8006682)
assert d[o:o + 6].hex() == '00f001f807bd', hx(d, 0x8006682, 6)
d[o:o + 6] = bytes.fromhex('c046c046c046')
o = off(0x8013AA8)
assert d[o:o + 4].hex() == '07f026be', hx(d, 0x8013AA8)
d[o:o + 4] = bytes.fromhex('c046c046')
o = off(0x8013BA6)
assert d[o:o + 2].hex() == 'b888', (hex(0x8013BA6), hx(d, 0x8013BA6, 2))
d[o:o + 2] = bytes.fromhex('ff20')
# Helper-pop S16 chain (see b25).
o = off(0x8007B66)
assert d[o:o + 2].hex() == '10bd', hx(d, 0x8007B66, 2)
d[o:o + 2] = bytes.fromhex('6047')
# Clock S11 (see b24).
o = off(0x800E988)
assert d[o:o + 2].hex() == '10bd', hx(d, 0x800E988, 2)
d[o:o + 2] = bytes.fromhex('7047')
save(d, 'img0_b26.elf')
+6 -1
View File
@@ -367,6 +367,11 @@ def main():
# S10 stublet (10B @0x08006C88, b23): rollback-exit router.
# movw/movt ip + bx ip to sbl_main 0x802f6a3.
mu.mem_write(0x08006C88, bytes.fromhex("4ff2a36cc0f6020c6047"))
# S17 safe-logger (50B @0x08006CF0, b26): print r1-string via
# UARTDM-TF only if r1 in rodata [0x804B800,0x8058000); pop-return.
mu.mem_write(0x08006CF0, bytes.fromhex(
"4bf60003c0f60403994211d348f20003c0f605039942"
"0bd210b54ff20003c0f28a730c4614f8010b08b11867fae710bd7047"))
# PBL version-table fabrication (b23): [0x080528D0] = STUBV so the
# rollback query's blx calls maze (returns 0 = versions OK).
W32(0x080528D0, STUBV)
@@ -430,7 +435,7 @@ def main():
# --- end parity ---
# stub range is readonly on HW/QEMU: ignore SBL heap-clobber writes,
# keep maze/stublets intact (restore-on-write with reentrancy guard)
STUB_LO, STUB_HI = 0x080068C0, 0x08006CF0 # +S7/S9/S10/S16 + banner
STUB_LO, STUB_HI = 0x080068C0, 0x08006D30 # +S7/S9/S10/S16/S17
stub_snap = bytes(mu.mem_read(STUB_LO, STUB_HI - STUB_LO))
_inww = [False]
_swn = [0]