From 4e8f14c902fce2ceb7b3d2790a508fcb59b782d7 Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdhiser@gmail.com>
Date: Thu, 2 May 2019 17:28:54 -0400
Subject: [PATCH] arm32 support

---
 src/base/SMPInstr.cpp                    | 5 +++--
 src/drivers/idapro/SMPStaticAnalyzer.cpp | 8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp
index a10ed420..5098e2e5 100644
--- a/src/base/SMPInstr.cpp
+++ b/src/base/SMPInstr.cpp
@@ -21832,8 +21832,9 @@ bool SMPInstr::BuildRTL(void)
 {
 	switch(global_STARS_program->GetProcessorType())
 	{
+		case ptARM:	  
 		case ptARM64:
-			return BuildARM64RTL();
+			return BuildARM64RTL(); // shared for arm32 (arm) and arm64 (aarch64).
 		case ptX86_64:
 		case ptX86_32:
 			return BuildX86RTL();
@@ -21875,7 +21876,7 @@ bool SMPInstr::BuildARM64RTL(void)
 		case STARS_ARM_bx:                 // Branch to/from Thumb mode
 		case STARS_ARM_blx1:               // Branch with Link and Exchange (immediate address)
 		case STARS_ARM_blx2:               // Branch with Link and Exchange (register indirect)
-			assert(0); // arm 32
+			return this->BuildCallRTL(); // arm/thumb 32
 
 		case STARS_ARM_tbz:                // Test and Branch Zero
 		case STARS_ARM_cbz:                // Compare and Branch on Zero
diff --git a/src/drivers/idapro/SMPStaticAnalyzer.cpp b/src/drivers/idapro/SMPStaticAnalyzer.cpp
index 33f4eb1d..7d82886f 100644
--- a/src/drivers/idapro/SMPStaticAnalyzer.cpp
+++ b/src/drivers/idapro/SMPStaticAnalyzer.cpp
@@ -386,16 +386,16 @@ bool IDAP_run(size_t arg) {
 
 	if (inf.is_64bit()) {
 		global_STARS_program->Set64BitBinary();
-		const auto pt = (ph.id == PLFM_386) ? ptX86_32 :
-		                (ph.id == PLFM_ARM) ? ptARM64 :
+		const auto pt = (ph.id == PLFM_386) ? ptX86_64 :
+		                (ph.id == PLFM_ARM) ? ptARM64  :
 				throw invalid_argument("Unknown machine type");
 		global_STARS_program->SetProcessorType(pt);
 		SMP_msg("INFO: 64-bit binary detected.\n");
 	}
 	else {
 		global_STARS_program->Set32BitBinary();
-		const auto pt = (ph.id == PLFM_386) ? ptX86_64 :
-		                (ph.id == PLFM_ARM) ? ptARM64 :
+		const auto pt = (ph.id == PLFM_386) ? ptX86_32 :
+		                (ph.id == PLFM_ARM) ? ptARM    :
 				throw invalid_argument("Unknown machine type");
 		global_STARS_program->SetProcessorType(pt);
 		SMP_msg("INFO: 32-bit binary detected.\n");
-- 
GitLab