Skip to content

Commit

Permalink
Arm64, bin2llvmir: Decoder should not analyse stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejKastak committed Mar 1, 2019
1 parent d980328 commit 7b88475
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/retdec/bin2llvmir/analyses/symbolic_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class SymbolicTree
static void setToDefaultConfiguration();
static void setTrackThroughAllocaLoads(bool b);
static void setTrackThroughGeneralRegisterLoads(bool b);
static void setTrackThroughStackPointerRegister(bool b);
static void setTrackOnlyFlagRegisters(bool b);
static void setSimplifyAtCreation(bool b);
static void setNaryLimit(unsigned n);
Expand All @@ -119,6 +120,7 @@ class SymbolicTree
static bool _val2valUsed;
static bool _trackThroughAllocaLoads;
static bool _trackThroughGeneralRegisterLoads;
static bool _trackThroughStackPointerRegister;
static bool _trackOnlyFlagRegisters;
static bool _simplifyAtCreation;
static unsigned _naryLimit;
Expand Down
10 changes: 9 additions & 1 deletion src/bin2llvmir/analyses/symbolic_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ void SymbolicTree::expandNode(
|| isa<CallInst>(value)
|| (_abi
&& _abi->isRegister(value)
&& !_abi->isStackPointerRegister(value)
&& (!_trackThroughStackPointerRegister
|| !_abi->isStackPointerRegister(value))
&& !_abi->isZeroRegister(value)
&& value != _abi->getRegister(MIPS_REG_GP, _abi->isMips())))
{
Expand Down Expand Up @@ -702,6 +703,7 @@ Config* SymbolicTree::_config = nullptr;
bool SymbolicTree::_val2valUsed = false;
bool SymbolicTree::_trackThroughAllocaLoads = true;
bool SymbolicTree::_trackThroughGeneralRegisterLoads = true;
bool SymbolicTree::_trackThroughStackPointerRegister = true;
bool SymbolicTree::_trackOnlyFlagRegisters = false;
bool SymbolicTree::_simplifyAtCreation = true;
unsigned SymbolicTree::_naryLimit = 3;
Expand All @@ -710,6 +712,7 @@ void SymbolicTree::setToDefaultConfiguration()
{
_trackThroughAllocaLoads = true;
_trackThroughGeneralRegisterLoads = true;
_trackThroughStackPointerRegister = true;
_trackOnlyFlagRegisters = false;
_simplifyAtCreation = true;
_naryLimit = 3;
Expand Down Expand Up @@ -740,6 +743,11 @@ void SymbolicTree::setTrackThroughGeneralRegisterLoads(bool b)
_trackThroughGeneralRegisterLoads = b;
}

void SymbolicTree::setTrackThroughStackPointerRegister(bool b)
{
_trackThroughStackPointerRegister = b;
}

void SymbolicTree::setTrackOnlyFlagRegisters(bool b)
{
_trackOnlyFlagRegisters = b;
Expand Down
4 changes: 4 additions & 0 deletions src/bin2llvmir/optimizations/decoder/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ bool Decoder::run()
return false;
}

SymbolicTree::setTrackThroughStackPointerRegister(false);

initTranslator();
initDryRunCsInstruction();
initEnvironment();
Expand Down Expand Up @@ -139,6 +141,8 @@ bool Decoder::run()

initializeGpReg_mips();

SymbolicTree::setToDefaultConfiguration();

return false;
}

Expand Down

0 comments on commit 7b88475

Please sign in to comment.