diff --git a/include/interfaces/idapro/STARSProgram.h b/include/interfaces/idapro/STARSProgram.h index ba490b1735d8f3c64c1fa8f21d45c2606ac5e878..73f686d437890412e777f37c482458442ae400b0 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 5457b4d6b92b9dd0c9d9e8a9d8727836460709c8..87049e478d261876d157772c41517ebb1f5aadac 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; }