From bd9ace9f14f8c52a499d160e9c4df1e4cde8c23e Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Thu, 21 Jan 2016 16:53:42 +0000
Subject: [PATCH] Detect recursive fixed calls.

Former-commit-id: 94666d2282500664bbac52cdbfbd616c2ab4eb5b
---
 src/interfaces/irdb/STARS_IRDB_Function.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/interfaces/irdb/STARS_IRDB_Function.cpp b/src/interfaces/irdb/STARS_IRDB_Function.cpp
index 4f77a969..68ce462d 100644
--- a/src/interfaces/irdb/STARS_IRDB_Function.cpp
+++ b/src/interfaces/irdb/STARS_IRDB_Function.cpp
@@ -255,8 +255,10 @@ void STARS_IRDB_Function_t::FindFixedCalls(SMPFunction *CurrFunc) {
 				if (success && (!TargetIDSet.empty())) {
 					assert(1 == TargetIDSet.size());
 					STARS_ea_t JumpTargetID = TargetIDSet.begin()->GetIDWithinFile();
-					if ((STARS_BADADDR != JumpTargetID) && (!this->IsInstIDInFunc(JumpTargetID))) {
-						// Valid jump target outside of current function.
+					bool ValidJumpTarget = (STARS_BADADDR != JumpTargetID);
+					bool RecursiveFixedCall = (JumpTargetID == CurrFunc->GetFirstFuncAddr());
+					if (ValidJumpTarget && ((!this->IsInstIDInFunc(JumpTargetID)) || RecursiveFixedCall)) {
+						// Valid jump target outside of current function, or recursive call to start of function.
 						CurrInst->SetFixedCallJump();
 						cout << "Found fixed call jump to ID " << JumpTargetID << " from ID " << CurrInst->GetAddr() << endl;
 						FixedCallPushSeen = false; // reset for detection of next occurrence
-- 
GitLab