From af4bc8b33d1e59e13700ba18060eadbe22ebdf7d Mon Sep 17 00:00:00 2001 From: clc5q <clc5q@git.zephyr-software.com> Date: Sat, 8 Aug 2015 05:28:07 +0000 Subject: [PATCH] Make reduced analysis threshold lower for STARS-IDA on 32-bit platforms. Former-commit-id: 0e9c94747b4c12e2e32833dca37f738e49e271be --- include/interfaces/idapro/STARSProgram.h | 1 + src/interfaces/idapro/STARSIDAProgram.cpp | 26 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/interfaces/idapro/STARSProgram.h b/include/interfaces/idapro/STARSProgram.h index ba490b17..73f686d4 100644 --- a/include/interfaces/idapro/STARSProgram.h +++ b/include/interfaces/idapro/STARSProgram.h @@ -46,6 +46,7 @@ public: private: // Data + std::size_t STARS_Platform_Bitwidth; // not binary, but the system OS we are running on // Methods void ComputeGlobalFieldOffsets(struct GlobalVar &CurrGlobal); diff --git a/src/interfaces/idapro/STARSIDAProgram.cpp b/src/interfaces/idapro/STARSIDAProgram.cpp index 5457b4d6..87049e47 100644 --- a/src/interfaces/idapro/STARSIDAProgram.cpp +++ b/src/interfaces/idapro/STARSIDAProgram.cpp @@ -3,6 +3,10 @@ #include <cstdint> #include <cstdio> #include <cassert> +#include <cerrno> +#include <cstdlib> + +#include <sys/utsname.h> #include <pro.h> #include <fpro.h> @@ -28,6 +32,7 @@ using namespace std; // Limit on bytes of code for full analysis #define STARS_CODESIZE_FULL_ANALYSIS_LIMIT 8000000 +#define STARS_CODESIZE_FULL_ANALYSIS_LIMIT_32BIT_PLATFORMS 6500000 // Distinguish between indexed and direct accesses in global granularity? // Set to zero until we can do more precise analyses of indexed accesses. @@ -36,7 +41,26 @@ using namespace std; // Set flags, take actions based on code size. void STARS_IDA_Program_t::ReportTotalCodeSize(unsigned long long TotalCodeSize) { this->SetTotalCodeSize(TotalCodeSize); - this->SetReducedProcessingFlag(TotalCodeSize > STARS_CODESIZE_FULL_ANALYSIS_LIMIT); + + struct utsname SysInfoBuf; + int ReturnCode = uname(&SysInfoBuf); + if (ReturnCode == -1) { + SMP_msg("ERROR: uname() failed.\n"); + this->STARS_Platform_Bitwidth = 32; + } + else if (0 == strcmp("x86_64", SysInfoBuf.machine)) { + this->STARS_Platform_Bitwidth = 64; + SMP_msg("INFO: Platform bit width from uname() is 64\n"); + } + else { + this->STARS_Platform_Bitwidth = 32; + SMP_msg("INFO: Platform bit width from uname() is 32\n"); + } + + if (this->STARS_Platform_Bitwidth <= 32) + this->SetReducedProcessingFlag(TotalCodeSize > STARS_CODESIZE_FULL_ANALYSIS_LIMIT_32BIT_PLATFORMS); + else + this->SetReducedProcessingFlag(TotalCodeSize > STARS_CODESIZE_FULL_ANALYSIS_LIMIT); return; } -- GitLab