From 66b799a6e481ed316eeddcfe33a1d4629e47bb44 Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Sun, 20 Sep 2020 01:16:30 +0200 Subject: [PATCH] Fix host stack overflow caused by some recursive guest methods. (#1528) * Fix host stack overflow caused by some recursive guest methods. * PPTC flag up. * Address comments. Co-authored-by: gdkchan --- ARMeilleure/Instructions/InstEmitFlowHelper.cs | 4 +++- ARMeilleure/Translation/PTC/Ptc.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ARMeilleure/Instructions/InstEmitFlowHelper.cs b/ARMeilleure/Instructions/InstEmitFlowHelper.cs index f5f228f53..0e7ca9ec2 100644 --- a/ARMeilleure/Instructions/InstEmitFlowHelper.cs +++ b/ARMeilleure/Instructions/InstEmitFlowHelper.cs @@ -144,7 +144,9 @@ namespace ARMeilleure.Instructions public static void EmitCall(ArmEmitterContext context, ulong immediate) { - EmitJumpTableBranch(context, Const(immediate)); + bool isRecursive = immediate == (ulong)context.BaseAddress; + + EmitJumpTableBranch(context, Const(immediate), isRecursive); } private static void EmitNativeCall(ArmEmitterContext context, Operand nativeContextPtr, Operand funcAddr, bool isJump = false) diff --git a/ARMeilleure/Translation/PTC/Ptc.cs b/ARMeilleure/Translation/PTC/Ptc.cs index 89aeed08a..c0b59a882 100644 --- a/ARMeilleure/Translation/PTC/Ptc.cs +++ b/ARMeilleure/Translation/PTC/Ptc.cs @@ -21,7 +21,7 @@ namespace ARMeilleure.Translation.PTC { private const string HeaderMagic = "PTChd"; - private const int InternalVersion = 1549; //! To be incremented manually for each change to the ARMeilleure project. + private const int InternalVersion = 1528; //! To be incremented manually for each change to the ARMeilleure project. private const string ActualDir = "0"; private const string BackupDir = "1";