From 77a36cf9cb66e05335528811b1407c161bd5ab17 Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 17 Dec 2010 05:16:51 +0000 Subject: [PATCH] ABI fix for Linux x64. ABI_CallFunctionCC16 was not calculating the jump distance on far calls. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6600 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/ABI.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/Src/ABI.cpp b/Source/Core/Common/Src/ABI.cpp index b363a1d790..1976294f1e 100644 --- a/Source/Core/Common/Src/ABI.cpp +++ b/Source/Core/Common/Src/ABI.cpp @@ -242,7 +242,15 @@ void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) { void XEmitter::ABI_CallFunctionCC16(void *func, u32 param1, u16 param2) { MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM2), Imm32((u32)param2)); - CALL(func); + u64 distance = u64(func) - (u64(code) + 5); + if (distance >= 0x0000000080000000ULL + && distance < 0xFFFFFFFF80000000ULL) { + // Far call + MOV(64, R(RAX), Imm64((u64)func)); + CALLptr(R(RAX)); + } else { + CALL(func); + } } void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {