Optimize the ASM code of romfsredir, saving 2 bytes so that it does not exceed the size of throwFatalError function

This commit is contained in:
fangrong 2025-09-28 15:41:02 +08:00 committed by TuxSH
parent d3d9a63bf2
commit 4cfca3c55d
2 changed files with 13 additions and 16 deletions

View File

@ -631,9 +631,9 @@ static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size, u32 textSize,
romfsRedirPatchSubstituted2 = *(u32 *)(code + fsTryOpenFile);
romfsRedirPatchHook2 = MAKE_BRANCH(payloadOffset + (u32)&romfsRedirPatchHook2 - (u32)romfsRedirPatch, fsTryOpenFile + 4);
romfsRedirPatchCustomPath = pathAddress;
romfsRedirPatchFsMountArchive = 0x100000 + fsMountArchive;
romfsRedirPatchFsUnMountArchive = 0x100000 + fsUnMountArchive;
romfsRedirPatchFsRegisterArchive = 0x100000 + fsRegisterArchive;
romfsRedirPatchFsMountArchive = MAKE_BRANCH_LINK(payloadOffset + (u32)&romfsRedirPatchFsMountArchive - (u32)romfsRedirPatch, fsMountArchive);
romfsRedirPatchFsUnMountArchive = MAKE_BRANCH_LINK(payloadOffset + (u32)&romfsRedirPatchFsUnMountArchive - (u32)romfsRedirPatch, fsUnMountArchive);
romfsRedirPatchFsRegisterArchive = MAKE_BRANCH_LINK(payloadOffset + (u32)&romfsRedirPatchFsRegisterArchive - (u32)romfsRedirPatch, fsRegisterArchive);
romfsRedirPatchArchiveId = archiveId;
memcpy(&romfsRedirPatchUpdateRomFsMount, updateRomFsMount, 4);

View File

@ -31,19 +31,22 @@ romfsRedirPatch:
bne romfsRedirPatchSubstituted1
stmfd sp!, {r0-r4, lr}
adr r0, romfsRedirPatchArchiveName
ldr r4, romfsRedirPatchFsUnMountArchive
blx r4
.global romfsRedirPatchFsUnMountArchive
romfsRedirPatchFsUnMountArchive:
.word 0xdead0004
sub sp, sp, #4
ldr r1, romfsRedirPatchArchiveId
mov r0, sp
ldr r4, romfsRedirPatchFsMountArchive
blx r4
.global romfsRedirPatchFsMountArchive
romfsRedirPatchFsMountArchive:
.word 0xdead0005
mov r3, #0
mov r2, #0
ldr r1, [sp]
adr r0, romfsRedirPatchArchiveName
ldr r4, romfsRedirPatchFsRegisterArchive
blx r4
.global romfsRedirPatchFsRegisterArchive
romfsRedirPatchFsRegisterArchive:
.word 0xdead0006
add sp, sp, #4
ldmfd sp!, {r0-r4, lr}
b romfsRedirPatchSubstituted1
@ -111,22 +114,16 @@ romfsRedirPatch:
.balign 4
.global romfsRedirPatchArchiveName
.global romfsRedirPatchFsMountArchive
.global romfsRedirPatchFsUnMountArchive
.global romfsRedirPatchFsRegisterArchive
.global romfsRedirPatchArchiveId
.global romfsRedirPatchRomFsMount
.global romfsRedirPatchUpdateRomFsMount
.global romfsRedirPatchCustomPath
romfsRedirPatchArchiveName : .ascii "lf:\0"
romfsRedirPatchFsMountArchive : .word 0xdead0005
romfsRedirPatchFsUnMountArchive : .word 0xdead0009
romfsRedirPatchFsRegisterArchive : .word 0xdead0006
romfsRedirPatchArchiveId : .word 0xdead0007
romfsRedirPatchRomFsMount : .ascii "rom:"
romfsRedirPatchUpdateRomFsMount : .word 0xdead0008
romfsRedirPatchCustomPath : .word 0xdead0004
romfsRedirPatchCustomPath : .word 0xdead0009
_romfsRedirPatchEnd: