1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

aarch64: Correctly implement the null function trap

This commit is contained in:
kd-11 2024-09-25 05:31:48 +03:00 committed by kd-11
parent c1d43aff05
commit 82f97d33d1

View File

@ -110,18 +110,21 @@ static u64 make_null_function(const std::string& name)
c.align(AlignMode::kData, 16); c.align(AlignMode::kData, 16);
#else #else
// AArch64 implementation // AArch64 implementation
Label jmp_address = c.newLabel();
Label data = c.newLabel(); Label data = c.newLabel();
// Force absolute jump to prevent out of bounds PC-rel jmp Label jump_address = c.newLabel();
c.ldr(args[0], arm::ptr(jmp_address)); c.ldr(args[0], arm::ptr(data, 0));
c.br(args[0]); c.ldr(a64::x14, arm::ptr(jump_address, 0));
c.align(AlignMode::kCode, 16); c.br(a64::x14);
// Data frame
c.align(AlignMode::kCode, 16);
c.bind(jump_address);
c.embedUInt64(reinterpret_cast<u64>(&null));
c.align(AlignMode::kData, 16);
c.bind(data); c.bind(data);
c.embed(name.c_str(), name.size()); c.embed(name.c_str(), name.size());
c.embedUInt8(0U); c.embedUInt8(0U);
c.bind(jmp_address);
c.embedUInt64(reinterpret_cast<u64>(&null));
c.align(AlignMode::kData, 16); c.align(AlignMode::kData, 16);
#endif #endif
}); });