Skip to content

Commit

Permalink
Address calculation should use 64-bit integers..
Browse files Browse the repository at this point in the history
  • Loading branch information
mxz297 committed Nov 21, 2016
1 parent d811f19 commit c0f9eb2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions parseAPI/src/BoundFactData.C
Expand Up @@ -396,7 +396,7 @@ BoundValue::BoundValue(const BoundValue & bv):
isZeroExtend(bv.isZeroExtend)
{
if (bv.values != NULL) {
values = new set<int>(*(bv.values));
values = new set<int64_t>(*(bv.values));
}
}

Expand Down Expand Up @@ -441,7 +441,7 @@ BoundValue & BoundValue::operator = (const BoundValue &bv) {
values = NULL;
}
if (bv.values != NULL) {
values = new set<int>(*bv.values);
values = new set<int64_t>(*bv.values);
}
return *this;

Expand Down Expand Up @@ -519,13 +519,13 @@ void BoundValue::Join(BoundValue &bv, Block *b) {
// it could be a case where multiple jump tables share
// an indirect jump.
// Example: 0x47947 at libc-2.17.so
set<int> left, right;
set<int64_t> left, right;
bool leftRet, rightRet;
leftRet = PerformTableRead(*this, left, b->obj()->cs());
rightRet = PerformTableRead(bv, right, b->obj()->cs());
if (leftRet && rightRet) {
left.insert(right.begin(), right.end());
values = new set<int> (left);
values = new set<int64_t> (left);
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion parseAPI/src/BoundFactData.h
Expand Up @@ -81,7 +81,7 @@ struct BoundValue {
// Otherwise, tableReadSize reprenents the number bytes of the access
int tableReadSize;
int multiply;
std::set<int> * values;
std::set<int64_t> * values;
bool isInverted;
bool isSubReadContent;
bool isZeroExtend;
Expand Down
4 changes: 2 additions & 2 deletions parseAPI/src/IndirectASTVisitor.C
Expand Up @@ -509,7 +509,7 @@ AST::Ptr JumpTableFormatVisitor::visit(DataflowAPI::RoseAST *ast) {
return AST::Ptr();
}

bool PerformTableRead(BoundValue &target, set<int> & jumpTargets, CodeSource *cs) {
bool PerformTableRead(BoundValue &target, set<int64_t> & jumpTargets, CodeSource *cs) {

Address tableBase = (Address)target.interval.low;
Address tableLastEntry = (Address)target.interval.high;
Expand Down Expand Up @@ -539,7 +539,7 @@ bool PerformTableRead(BoundValue &target, set<int> & jumpTargets, CodeSource *cs
for (Address tableEntry = tableBase; tableEntry <= tableLastEntry; tableEntry += target.interval.stride) {
if (!cs->isCode(tableEntry) && !cs->isData(tableEntry)) continue;
if (!cs->isReadOnly(tableEntry)) continue;
int targetAddress = 0;
int64_t targetAddress = 0;
if (target.tableReadSize > 0) {
switch (target.tableReadSize) {
case 8:
Expand Down
2 changes: 1 addition & 1 deletion parseAPI/src/IndirectASTVisitor.h
Expand Up @@ -17,7 +17,7 @@ AST::Ptr SimplifyAnAST(AST::Ptr ast, Address addr);
AST::Ptr SubstituteAnAST(AST::Ptr ast, const BoundFact::AliasMap &aliasMap);
AST::Ptr DeepCopyAnAST(AST::Ptr ast);
bool ContainAnAST(AST::Ptr root, AST::Ptr check);
bool PerformTableRead(BoundValue &target, set<int> & jumpTargets, CodeSource*);
bool PerformTableRead(BoundValue &target, set<int64_t> & jumpTargets, CodeSource*);


// On x86 and x86-64, the value of PC is post-instruction,
Expand Down
3 changes: 1 addition & 2 deletions parseAPI/src/IndirectAnalyzer.C
Expand Up @@ -17,8 +17,7 @@ using namespace Dyninst::InstructionAPI;


bool IndirectControlFlowAnalyzer::NewJumpTableAnalysis(std::vector<std::pair< Address, Dyninst::ParseAPI::EdgeTypeEnum > >& outEdges) {
// if (block->last() == 0x47947) dyn_debug_parsing = 1; else dyn_debug_parsing = 0;
// if (block->last() == 0x52460) dyn_debug_parsing=1; else dyn_debug_parsing=0;
// if (block->last() == 0x3ed4e2c437) dyn_debug_parsing=1; else dyn_debug_parsing=0;
parsing_printf("Apply indirect control flow analysis at %lx\n", block->last());
parsing_printf("Looking for thunk\n");

Expand Down
2 changes: 1 addition & 1 deletion parseAPI/src/JumpTablePred.C
Expand Up @@ -263,7 +263,7 @@ bool JumpTablePred::FillInOutEdges(BoundValue &target,
}
return true;
}
set<int> jumpTargets;
set<int64_t> jumpTargets;
if (!PerformTableRead(target, jumpTargets, block->obj()->cs())) {
jumpTableFormat = false;
return false;
Expand Down

0 comments on commit c0f9eb2

Please sign in to comment.