summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2018-08-21 15:47:34 -0400
committerRusty Wagner <rusty@vector35.com>2018-08-21 15:47:34 -0400
commit5841af2db8e8dcf4e0da0c438ac040c5fa90038b (patch)
tree45512fef65afea712ad5e87bea9a27455f751e5a
parent8e320c4be695cd47ae93673320d525ce513cec90 (diff)
Add return hint MLIL instruction (used in intermediate stages, not emitted in final forms)
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h1
-rw-r--r--mediumlevelilinstruction.cpp9
-rw-r--r--mediumlevelilinstruction.h4
-rw-r--r--python/mediumlevelil.py1
5 files changed, 16 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 32ed38d2..e0406592 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -3187,6 +3187,7 @@ namespace BinaryNinja
ExprId Jump(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId JumpTo(ExprId dest, const std::vector<BNMediumLevelILLabel*>& targets,
const ILSourceLocation& loc = ILSourceLocation());
+ ExprId ReturnHint(ExprId dest, const ILSourceLocation& loc = ILSourceLocation());
ExprId Call(const std::vector<Variable>& output, ExprId dest, const std::vector<ExprId>& params,
const ILSourceLocation& loc = ILSourceLocation());
ExprId CallUntyped(const std::vector<Variable>& output, ExprId dest, const std::vector<Variable>& params,
diff --git a/binaryninjacore.h b/binaryninjacore.h
index c8fb9f8f..e029f208 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -851,6 +851,7 @@ extern "C"
MLIL_LOW_PART,
MLIL_JUMP,
MLIL_JUMP_TO,
+ MLIL_RET_HINT, // Intermediate stages, does not appear in final forms
MLIL_CALL, // Not valid in SSA form (see MLIL_CALL_SSA)
MLIL_CALL_UNTYPED, // Not valid in SSA form (see MLIL_CALL_UNTYPED_SSA)
MLIL_CALL_OUTPUT, // Only valid within MLIL_CALL, MLIL_SYSCALL, MLIL_TAILCALL family instructions
diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp
index 9cf82b08..93587c34 100644
--- a/mediumlevelilinstruction.cpp
+++ b/mediumlevelilinstruction.cpp
@@ -122,6 +122,7 @@ unordered_map<BNMediumLevelILOperation, vector<MediumLevelILOperandUsage>>
{MLIL_ADDRESS_OF_FIELD, {SourceVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage}},
{MLIL_JUMP, {DestExprMediumLevelOperandUsage}},
{MLIL_JUMP_TO, {DestExprMediumLevelOperandUsage, TargetListMediumLevelOperandUsage}},
+ {MLIL_RET_HINT, {DestExprMediumLevelOperandUsage}},
{MLIL_CALL, {OutputVariablesMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
ParameterExprsMediumLevelOperandUsage}},
{MLIL_CALL_UNTYPED, {OutputVariablesSubExprMediumLevelOperandUsage, DestExprMediumLevelOperandUsage,
@@ -1322,6 +1323,7 @@ void MediumLevelILInstruction::VisitExprs(const std::function<bool(const MediumL
case MLIL_BOOL_TO_INT:
case MLIL_JUMP:
case MLIL_JUMP_TO:
+ case MLIL_RET_HINT:
case MLIL_IF:
case MLIL_UNIMPL_MEM:
case MLIL_LOAD:
@@ -1591,6 +1593,7 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_LOW_PART:
case MLIL_BOOL_TO_INT:
case MLIL_JUMP:
+ case MLIL_RET_HINT:
case MLIL_UNIMPL_MEM:
case MLIL_FSQRT:
case MLIL_FNEG:
@@ -2497,6 +2500,12 @@ ExprId MediumLevelILFunction::JumpTo(ExprId dest, const vector<BNMediumLevelILLa
}
+ExprId MediumLevelILFunction::ReturnHint(ExprId dest, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(MLIL_RET_HINT, loc, 0, dest);
+}
+
+
ExprId MediumLevelILFunction::Call(const vector<Variable>& output, ExprId dest,
const vector<ExprId>& params, const ILSourceLocation& loc)
{
diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h
index b37b8832..d39ea87d 100644
--- a/mediumlevelilinstruction.h
+++ b/mediumlevelilinstruction.h
@@ -814,6 +814,10 @@ namespace BinaryNinja
MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
MediumLevelILIndexList GetTargetList() const { return GetRawOperandAsIndexList(1); }
};
+ template <> struct MediumLevelILInstructionAccessor<MLIL_RET_HINT>: public MediumLevelILInstructionBase
+ {
+ MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); }
+ };
template <> struct MediumLevelILInstructionAccessor<MLIL_CALL>: public MediumLevelILInstructionBase
{
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index cfa8f900..774231ab 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -128,6 +128,7 @@ class MediumLevelILInstruction(object):
MediumLevelILOperation.MLIL_LOW_PART: [("src", "expr")],
MediumLevelILOperation.MLIL_JUMP: [("dest", "expr")],
MediumLevelILOperation.MLIL_JUMP_TO: [("dest", "expr"), ("targets", "int_list")],
+ MediumLevelILOperation.MLIL_RET_HINT: [("dest", "expr")],
MediumLevelILOperation.MLIL_CALL: [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
MediumLevelILOperation.MLIL_CALL_UNTYPED: [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
MediumLevelILOperation.MLIL_CALL_OUTPUT: [("dest", "var_list")],