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); romfsRedirPatchSubstituted2 = *(u32 *)(code + fsTryOpenFile);
romfsRedirPatchHook2 = MAKE_BRANCH(payloadOffset + (u32)&romfsRedirPatchHook2 - (u32)romfsRedirPatch, fsTryOpenFile + 4); romfsRedirPatchHook2 = MAKE_BRANCH(payloadOffset + (u32)&romfsRedirPatchHook2 - (u32)romfsRedirPatch, fsTryOpenFile + 4);
romfsRedirPatchCustomPath = pathAddress; romfsRedirPatchCustomPath = pathAddress;
romfsRedirPatchFsMountArchive = 0x100000 + fsMountArchive; romfsRedirPatchFsMountArchive = MAKE_BRANCH_LINK(payloadOffset + (u32)&romfsRedirPatchFsMountArchive - (u32)romfsRedirPatch, fsMountArchive);
romfsRedirPatchFsUnMountArchive = 0x100000 + fsUnMountArchive; romfsRedirPatchFsUnMountArchive = MAKE_BRANCH_LINK(payloadOffset + (u32)&romfsRedirPatchFsUnMountArchive - (u32)romfsRedirPatch, fsUnMountArchive);
romfsRedirPatchFsRegisterArchive = 0x100000 + fsRegisterArchive; romfsRedirPatchFsRegisterArchive = MAKE_BRANCH_LINK(payloadOffset + (u32)&romfsRedirPatchFsRegisterArchive - (u32)romfsRedirPatch, fsRegisterArchive);
romfsRedirPatchArchiveId = archiveId; romfsRedirPatchArchiveId = archiveId;
memcpy(&romfsRedirPatchUpdateRomFsMount, updateRomFsMount, 4); memcpy(&romfsRedirPatchUpdateRomFsMount, updateRomFsMount, 4);

View File

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