PPU Loader: Fixup stack alignment after envp fix

This commit is contained in:
Elad Ashkenazi 2023-08-12 02:03:24 +03:00 committed by GitHub
parent c6dcf3f1d3
commit 5668b1bd7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2337,13 +2337,13 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str
if (!Emu.data.empty())
{
std::memcpy(vm::base(ppu->stack_addr + ppu->stack_size - ::size32(Emu.data)), Emu.data.data(), Emu.data.size());
ppu->gpr[1] -= Emu.data.size();
ppu->gpr[1] -= utils::align<u32>(::size32(Emu.data), 0x10);
}
// Initialize process arguments
// Calculate storage requirements on the stack
const u32 pointers_storage_size = u32{sizeof(u64)} * (::size32(Emu.envp) + ::size32(Emu.argv) + 3);
const u32 pointers_storage_size = u32{sizeof(u64)} * utils::align<u32>(::size32(Emu.envp) + ::size32(Emu.argv) + 2, 2);
u32 stack_alloc_size = pointers_storage_size;
@ -2376,7 +2376,7 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str
*args++ = 0;
const vm::ptr<u64> envp = vm::cast(utils::align<u32>(args.addr(), 8));
const vm::ptr<u64> envp = args;
args = envp;
for (const auto& arg : Emu.envp)
@ -2391,8 +2391,6 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str
*args++ = 0;
*args++ = 0; // Unknown
ppu->gpr[1] -= stack_alloc_size;
ensure(g_fxo->get<lv2_memory_container>().take(primary_stacksize));