From 52be36bcb2e89ab030a5a53759ed70ff81621416 Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Tue, 19 Jan 2016 22:54:54 +0000
Subject: [PATCH] Mark IBTs as COMPLETE for indirect jumps that are resolved in
 orphan code.

Former-commit-id: c22a92a8493f865fa82f2e5ce9aa55ef4cf56fbc
---
 src/drivers/idapro/SMPStaticAnalyzer.cpp | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/drivers/idapro/SMPStaticAnalyzer.cpp b/src/drivers/idapro/SMPStaticAnalyzer.cpp
index ee4fb309..756a6514 100644
--- a/src/drivers/idapro/SMPStaticAnalyzer.cpp
+++ b/src/drivers/idapro/SMPStaticAnalyzer.cpp
@@ -1422,22 +1422,16 @@ void FindOrphanedCode(STARS_Segment_t *CurrSeg, FILE *AnnotFile, FILE *InfoAnnot
 					// If instruction is an indirect branch, emit an XREF
 					//  annotation for each of its targets.
 					SMPitype CurrDataFlow = CurrInst.GetDataFlowType();
-					if ((CurrDataFlow == INDIR_JUMP) || (CurrDataFlow == INDIR_CALL)) {
-						SMP_xref_t xrefs;
-						for (bool ok = xrefs.SMP_first_from(addr, XREF_ALL); ok; ok = xrefs.SMP_next_from()) {
-							if (xrefs.GetTo() != 0) {
-								if (xrefs.GetIscode() && (xrefs.GetType() != fl_F)) {
-									// Found a code target, with its address in xrefs.to
-									global_STARS_program->PrintCodeToCodeXref(addr, xrefs.GetTo(), CurrInst.GetSize());
-								}
-							}
-						}
+					bool IndirCallFlag = (CurrDataFlow == INDIR_CALL);
+					if ((CurrDataFlow == INDIR_JUMP) || IndirCallFlag) {
+						global_STARS_program->PrintAllCodeToCodeXrefs(addr, CurrInst.GetSize(), IndirCallFlag);
 					}
 					// If the address of this instruction appeared in data, emit an IBT annotation.
 					if (global_STARS_program->IsCodeAddressTaken(addr)) {
 						global_STARS_program->PrintUnknownCodeXref(addr, CurrInst.GetSize());
 					}
-				}
+				} // end if inst is Analyzeable
+
 				// Emit IBT annotations for instructions that fit computed-goto patterns in libc/glibc, such
 				//  as prefetch instructions and the instructions that follow them (computed goto often chooses
 				//  between going to the prefetch or jumping just past it, and IDA Pro cannot analyze these libc
-- 
GitLab