diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-01-05 15:37:58 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-01-06 14:15:15 +0100 |
| commit | e9494c09013290a382b90e84cd363567d166f687 (patch) | |
| tree | c6a973dd87be704676d588d5ca0a25b0e0c2535b | |
| parent | afdeb68de2b634c600c30f61422f9fd59286376c (diff) | |
| download | miasm-e9494c09013290a382b90e84cd363567d166f687.tar.gz miasm-e9494c09013290a382b90e84cd363567d166f687.zip | |
IR: Call_effects API modification
Old API:
def call_effects(self, addr):
New API:
def call_effects(self, addr, instr):
The addr is the address of the called function
'instr' is the instruction responsible for the call.
The new API is a bit more flexible for model a function.
| -rw-r--r-- | miasm2/arch/aarch64/ira.py | 2 | ||||
| -rw-r--r-- | miasm2/arch/arm/ira.py | 2 | ||||
| -rw-r--r-- | miasm2/arch/mips32/ira.py | 2 | ||||
| -rw-r--r-- | miasm2/arch/msp430/ira.py | 2 | ||||
| -rw-r--r-- | miasm2/arch/x86/ira.py | 4 | ||||
| -rw-r--r-- | miasm2/ir/analysis.py | 11 |
6 files changed, 14 insertions, 9 deletions
diff --git a/miasm2/arch/aarch64/ira.py b/miasm2/arch/aarch64/ira.py index 3f610360..090ff6d0 100644 --- a/miasm2/arch/aarch64/ira.py +++ b/miasm2/arch/aarch64/ira.py @@ -55,7 +55,7 @@ class ir_a_aarch64l(ir_a_aarch64l_base): # CALL lbl = bloc.get_next() new_lbl = self.gen_label() - irs = self.call_effects(pc_val) + irs = self.call_effects(pc_val, l) irs.append(AssignBlock([ExprAff(self.IRDst, ExprId(lbl, size=self.pc.size))])) nbloc = irbloc(new_lbl, irs) diff --git a/miasm2/arch/arm/ira.py b/miasm2/arch/arm/ira.py index b279fab5..7d8e1838 100644 --- a/miasm2/arch/arm/ira.py +++ b/miasm2/arch/arm/ira.py @@ -53,7 +53,7 @@ class ir_a_arml(ir_a_arml_base): # CALL lbl = bloc.get_next() new_lbl = self.gen_label() - irs = self.call_effects(pc_val) + irs = self.call_effects(pc_val, l) irs.append(AssignBlock([ExprAff(self.IRDst, ExprId(lbl, size=self.pc.size))])) nbloc = irbloc(new_lbl, irs) diff --git a/miasm2/arch/mips32/ira.py b/miasm2/arch/mips32/ira.py index de508e41..ecbc1a7f 100644 --- a/miasm2/arch/mips32/ira.py +++ b/miasm2/arch/mips32/ira.py @@ -41,7 +41,7 @@ class ir_a_mips32l(ir_mips32l, ira): # CALL lbl = bloc.get_next() new_lbl = self.gen_label() - irs = self.call_effects(pc_val) + irs = self.call_effects(pc_val, l) irs.append(AssignBlock([ExprAff(self.IRDst, ExprId(lbl, size=self.pc.size))])) nbloc = irbloc(new_lbl, irs) diff --git a/miasm2/arch/msp430/ira.py b/miasm2/arch/msp430/ira.py index f9da81a7..8e6aecee 100644 --- a/miasm2/arch/msp430/ira.py +++ b/miasm2/arch/msp430/ira.py @@ -51,7 +51,7 @@ class ir_a_msp430(ir_a_msp430_base): l = bloc.lines[-1] lbl = bloc.get_next() new_lbl = self.gen_label() - irs = self.call_effects(pc_val) + irs = self.call_effects(pc_val, l) irs.append(AssignBlock([ExprAff(self.IRDst, ExprId(lbl, size=self.pc.size))])) nbloc = irbloc(new_lbl, irs) diff --git a/miasm2/arch/x86/ira.py b/miasm2/arch/x86/ira.py index d496f380..49806162 100644 --- a/miasm2/arch/x86/ira.py +++ b/miasm2/arch/x86/ira.py @@ -53,7 +53,7 @@ class ir_a_x86_16(ir_x86_16, ira): sub_call_dst = sub_call_dst.name lbl = bloc.get_next() new_lbl = self.gen_label() - irs = self.call_effects(l.args[0]) + irs = self.call_effects(l.args[0], l) irs.append(AssignBlock([ExprAff(self.IRDst, ExprId(lbl, size=self.pc.size))])) @@ -92,7 +92,7 @@ class ir_a_x86_64(ir_x86_64, ir_a_x86_16): ir_x86_64.__init__(self, symbol_pool) self.ret_reg = self.arch.regs.RAX - def call_effects(self, ad): + def call_effects(self, ad, instr): return [AssignBlock([ExprAff(self.ret_reg, ExprOp('call_func_ret', ad, self.sp, self.arch.regs.RCX, diff --git a/miasm2/ir/analysis.py b/miasm2/ir/analysis.py index 70fda11c..c606d958 100644 --- a/miasm2/ir/analysis.py +++ b/miasm2/ir/analysis.py @@ -29,11 +29,16 @@ class ira(ir): """Returns ids of all registers used in the IR""" return self.arch.regs.all_regs_ids + [self.IRDst] - def call_effects(self, ad): - """ - Default simulation of a function call to @ad + def call_effects(self, ad, instr): + """Default modelisation of a function call to @ad. This may be used to: + + * insert dependencies to arguments (stack base, registers, ...) + * add some side effects (stack clean, return value, ...) + @ad: (Expr) address of the called function + @instr: native instruction which is responsible of the call """ + return [AssignBlock( [ExprAff(self.ret_reg, ExprOp('call_func_ret', ad, self.sp)), ExprAff(self.sp, ExprOp( |