Skip to content
Snippets Groups Projects
Commit 8186603a authored by an7s's avatar an7s
Browse files

parse ib provenance data from the STARS xref file

Former-commit-id: 9f4f704c3c1d759bb3c2cce9a6bee2e477132cc6
parent 436651af
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ wahoo::Instruction::Instruction()
m_isVisited = false;
m_data = NULL;
m_ib_complete=false;
m_ib_provenance = IB_PROVENANCE_UNKNOWN;
}
wahoo::Instruction::Instruction(app_iaddr_t p_address, int p_size, Function* p_func)
......@@ -50,6 +51,8 @@ wahoo::Instruction::Instruction(app_iaddr_t p_address, int p_size, Function* p_f
m_deallocSite = false;
m_stackRef = false;
m_data = NULL;
m_ib_complete=false;
m_ib_provenance = IB_PROVENANCE_UNKNOWN;
}
wahoo::Instruction::~Instruction()
......@@ -84,3 +87,29 @@ void wahoo::Instruction::markVarStackRef()
{
m_varStackRef = true;
}
void wahoo::Instruction::setIbProvenance(char *p_provenance)
{
std::string provenance(p_provenance);
if (provenance == "RETURNTARGET")
{
m_ib_provenance = IB_PROVENANCE_RETURN;
}
else if (provenance == "SWITCHTABLE")
{
m_ib_provenance = IB_PROVENANCE_SWITCH_TABLE;
}
else if (provenance == "INDIRCALL")
{
m_ib_provenance = IB_PROVENANCE_INDIRECT_CALL;
}
else if (provenance == "UNKNOWN")
{
m_ib_provenance = IB_PROVENANCE_UNKNOWN;
}
else
{
m_ib_provenance = IB_PROVENANCE_UNKNOWN;
}
}
......@@ -13,6 +13,8 @@ namespace wahoo {
class Function;
enum IBProvenance { IB_PROVENANCE_UNKNOWN, IB_PROVENANCE_RETURN, IB_PROVENANCE_SWITCH_TABLE, IB_PROVENANCE_INDIRECT_CALL };
class Instruction {
public:
Instruction();
......@@ -52,6 +54,9 @@ class Instruction {
const std::set<Instruction*>& getIBTs() { return ibts; }
void markIbComplete(bool complete=true) { m_ib_complete=complete; }
bool isIbComplete() { return m_ib_complete; }
void setIbProvenance(char *);
void setIbProvenance(const IBProvenance p_provenance) { m_ib_provenance = p_provenance; }
IBProvenance getIbProvenance() const { return m_ib_provenance; }
private:
app_iaddr_t m_address;
......@@ -59,7 +64,6 @@ class Instruction {
int m_size;
Function* m_function;
string m_asm;
// unsigned char m_data[128];
unsigned char* m_data;
bool m_allocSite;
......@@ -71,7 +75,7 @@ class Instruction {
std::set<Instruction*> ibts;
bool m_ib_complete;
IBProvenance m_ib_provenance;
};
}
......
......@@ -669,6 +669,16 @@ void Rewriter::readXrefsFile(char p_filename[])
break;
// check for instr xref ibt
/*
4280c0 1 INSTR XREF IBT FROMIB 426558 RETURNTARGET
426614 1 INSTR XREF IBT FROMIB 426580 RETURNTARGET
4280c0 1 INSTR XREF IBT FROMIB 426580 RETURNTARGET
4269d2 1 INSTR XREF IBT FROMIB 42689c RETURNTARGET
4432bd 1 INSTR XREF IBT FROMIB 42689c RETURNTARGET
447d4f 1 INSTR XREF IBT FROMIB 42689c RETURNTARGET
42689c 1 INSTR XREF FROMIB COMPLETE 3 RETURNTARGET
*/
if(string("IBT")==string(ibt))
{
fscanf(fin, "%s", fromib);
......@@ -685,9 +695,10 @@ void Rewriter::readXrefsFile(char p_filename[])
instr->setIBTAddress(addr);
if(strcmp(fromib,"FROMIB")==0)
{
char provenance[200];
// get the from point into memory.
app_iaddr_t from_addr = 0;
fscanf(fin, "%p", (void**)&from_addr);
fscanf(fin, "%p %s", (void**)&from_addr, provenance);
if(feof(fin)) // deal with blank lines at the EOF
break;
......@@ -697,6 +708,7 @@ void Rewriter::readXrefsFile(char p_filename[])
// record in the IR listing.
from_instr->addIBT(instr);
from_instr->setIbProvenance(provenance);
}
}
}
......@@ -706,17 +718,21 @@ void Rewriter::readXrefsFile(char p_filename[])
// annotations can come in any order so the COMPLETE annotation for IB targets
// can come before/after the targets themselves
// in this loop, just keep track of instructions w/ complete targets
// 4004b6 1 INSTR XREF FROMIB COMPLETE 1
// 4004b6 1 INSTR XREF FROMIB COMPLETE 1 <provenance>
char complete[200];
fscanf(fin, "%s", complete);
if(feof(fin)) // deal with blank lines at the EOF
break;
if(strcmp(complete,"COMPLETE")==0)
{
char provenance[200];
int num_targets;
completeIBT.insert(addr);
fscanf(fin, "%d %s", &num_targets, provenance);
if(feof(fin)) // deal with blank lines at the EOF
break;
}
if(feof(fin)) // deal with blank lines at the EOF
break;
}
char remainder[2000];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment