Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opensrc/SMPStaticAnalyzer
1 result
Show changes
Commits on Source (1)
......@@ -112,6 +112,7 @@ class STARS_Program_t
bool ShouldSTARSPerformConstantPropagation(void) const { return STARS_PerformConstantPropagation; };
bool ShouldSTARSTranslateToSPARKAda(void) const { return STARS_TranslateToSPARKAda; };
bool IsIDAProDriverMode(void) const { return IDAProDriver; };
bool IsSharedObject(void) const { return SharedObjectFlag; };
bool IsLocationWhitelisted(ZST_SysCallType CallType, std::string LocationName) const;
bool IsLocationBlacklisted(ZST_SysCallType CallType, std::string LocationName) const;
// Given a called function name, does it produce only benign numeric errors when
......@@ -184,6 +185,7 @@ class STARS_Program_t
};
void SetTotalCodeSize(unsigned long long TotalSize) { STARS_TotalCodeSize = TotalSize; };
void IncrementCurrentFileNum(void) { ++CurrentFileNumber; };
void SetSharedObjectFlag(const bool flag) { SharedObjectFlag = flag; };
// Analysis methods
void MDInitializeCallerSavedRegs(void);
......@@ -204,6 +206,7 @@ class STARS_Program_t
STARS_ProcessorType_t processor_type;
char STARS_ISA_dtyp;
bool IDAProDriver; // program is compiled in IDA Pro mode
bool SharedObjectFlag;
int STARS_MD_LAST_SAVED_REG_NUM;
// Unique data referent number to use in data annotations.
......
......@@ -477,7 +477,9 @@ bool IDAP_run(size_t arg) {
time_t EndTime, Time1, Time2;
CurrProg->AnalyzeData(); // Analyze static data in the executable
Time1 = time(nullptr);
global_STARS_program->FindCodeAddressesTaken(CurrProg); // find code addresses in read-only data segments
if (!global_STARS_program->IsSharedObject()) {
global_STARS_program->FindCodeAddressesTaken(CurrProg); // find code addresses in read-only data segments
}
Time2 = time(nullptr);
// Note: ProfilerInformation must come after the call above to AnalyzeData().
......
......@@ -8,6 +8,10 @@
#include <sys/utsname.h>
#include <iostream>
#include <string>
#include <sstream>
#include "interfaces/idapro/all.h"
#include "interfaces/STARSTypes.h"
#include "interfaces/STARSIDATypes.h"
......@@ -152,6 +156,61 @@ void STARS_IDA_Program_t::DetermineRootFileName(void) {
#endif
string TempRootString(TempRootName);
this->SetRootFileName(TempRootString);
// Try to find ".so" or ".dll" or ".a" in file name, indicating shared object.
// This code below only works for non-renamed file, e.g. STARS/IDA Pro operation,
// and not files renamed with new extensions, e.g. a.ncexe. Replace with info from
// file header soon.
bool sharedObjectFlag = false;
char token[210];
std::size_t tokencount = 0;
istringstream FileNameStr(TempRootString);
this->SetSharedObjectFlag(false);
char delim = '.';
FileNameStr.getline(token, 200, delim);
while (FileNameStr.rdstate() == std::istringstream::goodbit) {
++tokencount;
if (1 < tokencount) { // Not looking for file extension before first "."
sharedObjectFlag = ((0 == strcmp(token, "so")) || (0 == strcmp(token, "dll"))
|| (0 == strcmp(token, "a")));
if (sharedObjectFlag) {
this->SetSharedObjectFlag(sharedObjectFlag);
SMP_msg("INFO: Determined shared object from file extension %s\n", token);
break;
}
}
FileNameStr.getline(token, 200, delim);
}
#if 1
// See if shared object extension is at the very end, with no more "." delimiter after.
// Find file name extension.
if (!sharedObjectFlag) {
string delimiter(".");
std::size_t found = TempRootString.rfind(delimiter, TempRootString.length());
if (found != std::string::npos) { // found last instance of delimiter
string extension = TempRootString.substr(found, std::string::npos);
if (!extension.empty()) {
// This code below only works for non-renamed files, e.g. STARS/IDA Pro operation,
// and not files renamed with new extensions, e.g. a.ncexe. Replace with info from
// file header soon.
SMP_msg("INFO: Found extension %s\n", extension.c_str());
sharedObjectFlag = ((0 == extension.compare(".so")) || (0 == extension.compare(".dll"))
|| (0 == extension.compare(".a")));
this->SetSharedObjectFlag(sharedObjectFlag);
if (sharedObjectFlag)
SMP_msg("INFO: Determined shared object from file extension %s\n", extension.c_str());
}
else {
SMP_msg("ERROR: Empty file name extension.\n");
}
}
else {
SMP_msg("ERROR: Could not reverse-find the dot delimiter in file name.\n");
}
}
#endif
return;
}
// Does the instruction at InstAddr access the global data offset in GlobalAddr
......