From bc1e0c24e896e3cad4a1d3338c12d5888904b590 Mon Sep 17 00:00:00 2001 From: pierre Date: Sun, 26 Sep 2010 19:37:30 +0000 Subject: [PATCH] Add an PanicAlert in case we try to do an >32 bit displacement If you see this alert, dolphin will probably crash in a few moments. Found in the course of fiddling with DSPLLEs JIT, which puts its data structures and static code somewhere above 0x7fff00000000 on my machine, making it unreachable via 32bit displacements from the created code at ~ 0x40000000. Fixed all the offending places in DSPLLEs JIT to emit register indirect accesses, only to find out that the generated code is slower than the interpreter and does work just as good(or bad). Oh well, back to DSPHLE it is then. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6229 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/x64Emitter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/Src/x64Emitter.cpp b/Source/Core/Common/Src/x64Emitter.cpp index 51a20b06fe..01469ad293 100644 --- a/Source/Core/Common/Src/x64Emitter.cpp +++ b/Source/Core/Common/Src/x64Emitter.cpp @@ -168,7 +168,12 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg) const //TODO : add some checks #ifdef _M_X64 u64 ripAddr = (u64)emit->GetCodePtr() + 4 + extraBytes; - s32 offs = (s32)((s64)offset - (s64)ripAddr); + s64 distance = (s64)offset - (s64)ripAddr; + if (distance >= 0x0000000080000000LL + || distance < -0x0000000080000000LL) { + PanicAlert("WriteRest: op out of range (%p uses %p)", ripAddr, offset); + } + s32 offs = (s32)distance; emit->Write32((u32)offs); #else emit->Write32((u32)offset);