sbl b15: force table loop count 0xff (skip broken exit pop)

This commit is contained in:
SashegDev
2026-09-11 06:38:12 +00:00
parent cc213e0521
commit 537e2b6b2a
+26
View File
@@ -133,6 +133,32 @@ def main():
assert d[o:o + 4].hex() == '07f026be', hx(d, 0x8013AA8) assert d[o:o + 4].hex() == '07f026be', hx(d, 0x8013AA8)
d[o:o + 4] = bytes.fromhex('c046c046') d[o:o + 4] = bytes.fromhex('c046c046')
save(d, 'img0_b12.elf') save(d, 'img0_b12.elf')
# b15 = b14 + force table-loop count (0x8013ba6 ldrh r0,[r7,#4] ->
# movs r0,#0xff): exit pop reads clobbered slot (->0); looping builds
# tables via helpers instead. 2-byte patch.
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'),
(0x8006684, '01f807bd', '46c046c0'),
(0x8017AFC, 'bde8fc87', '4af020bb'),
]:
assert hx(d, va) == exp, (hex(va), hx(d, va))
set4(d, va, new)
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')
save(d, 'img0_b15.elf')
# b14 = b13 + redirect S6 pop (0x8017afc ldmia.w sp!,{r2-r9,sl,pc}) # b14 = b13 + redirect S6 pop (0x8017afc ldmia.w sp!,{r2-r9,sl,pc})
# to S6 stublet at 0x08062140 (pc slot clobbered to 0 at runtime) # to S6 stublet at 0x08062140 (pc slot clobbered to 0 at runtime)
d = bytearray(base) d = bytearray(base)