Skip to content
Snippets Groups Projects
Commit e5ae2ce5 authored by Anh Nguyen-Tuong's avatar Anh Nguyen-Tuong
Browse files

Make sure block ids are unique

parent 1045fb4d
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,22 @@ static void create_got_reloc(FileIR_t* fir, pair<DataScoop_t*,int> wrt, Instruct
i->GetRelocations().insert(r);
}
unsigned Zafl_t::get_blockid()
{
auto counter = 0;
auto blockid = 0;
while (counter++ < (1<<18)) {
blockid = rand() & 0xFFFF;
if (m_used_blockid.find(blockid) == m_used_blockid.end())
{
m_used_blockid.insert(blockid);
return blockid;
}
}
return blockid;
}
/*
zafl_trace_bits[zafl_prev_id ^ id]++; │ tmp= insertAssemblyAfter(getFileIR(), tmp," pop r8");
zafl_prev_id = id >> 1;
......@@ -70,7 +86,7 @@ void Zafl_t::afl_instrument_bb(Instruction_t *inst)
tmp = insertAssemblyAfter(getFileIR(), tmp, "push rdx");
tmp = insertAssemblyAfter(getFileIR(), tmp, "pushf");
auto blockid = rand() & 0xFFFF;
auto blockid = get_blockid();
/*
0: 48 8b 15 00 00 00 00 mov rdx,QWORD PTR [rip+0x0] # 7 <f+0x7>
......@@ -121,7 +137,7 @@ void Zafl_t::afl_instrument_bb(Instruction_t *inst)
*/
int Zafl_t::execute()
{
m_stars_analysis_engine.do_STARS(getFileIR());
// m_stars_analysis_engine.do_STARS(getFileIR());
// for all functions
// for all basic blocks
......
......@@ -19,6 +19,8 @@ public:
int execute();
void afl_instrument_bb(Instruction_t *inst);
private:
unsigned get_blockid();
private:
libIRDB::pqxxDB_t &m_dbinterface;
STARS::IRDB_Interface_t m_stars_analysis_engine;
......@@ -27,6 +29,7 @@ private:
std::pair<DataScoop_t*, int> m_trace_bits; // afl shared memory trace map
std::pair<DataScoop_t*, int> m_prev_id; // id of previous block
std::set<unsigned> m_used_blockid;
int num_bb_instrumented;
};
......
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