mirror of
https://github.com/stenzek/duckstation.git
synced 2026-10-11 22:49:58 +00:00
CPU/Recompiler: Align ARM32 backpatch thunk calls
Pad odd register save lists with the reserved state register to preserve the required eight-byte stack alignment when calling memory helpers.
This commit is contained in:
@@ -2542,6 +2542,10 @@ u32 CPU::Recompiler::CompileLoadStoreThunk(void* thunk_code, u32 thunk_space, vo
|
||||
save_regs.Combine(RegisterList(Register(i)));
|
||||
}
|
||||
|
||||
const bool pad_stack = ((save_regs.GetCount() & 1) != 0);
|
||||
if (pad_stack)
|
||||
armAsm->sub(sp, sp, 4);
|
||||
|
||||
if (!save_regs.IsEmpty())
|
||||
armAsm->push(save_regs);
|
||||
|
||||
@@ -2642,6 +2646,9 @@ u32 CPU::Recompiler::CompileLoadStoreThunk(void* thunk_code, u32 thunk_space, vo
|
||||
if (!save_regs.IsEmpty())
|
||||
armAsm->pop(save_regs);
|
||||
|
||||
if (pad_stack)
|
||||
armAsm->add(sp, sp, 4);
|
||||
|
||||
armEmitJmp(armAsm, static_cast<const u8*>(code_address) + code_size, true);
|
||||
armAsm->FinalizeCode();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user