diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-07-18 07:44:59 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-07-18 07:45:08 +0200 |
| commit | 7d2227eeb09a0ec43a837082570a0cb955651daa (patch) | |
| tree | 04780ca818378f42bc91efe2fc2d88a2d77692f7 /miasm2/ir/analysis.py | |
| parent | cf74092981e4f3fa7bed9ce182a38e570653a138 (diff) | |
| download | miasm-7d2227eeb09a0ec43a837082570a0cb955651daa.tar.gz miasm-7d2227eeb09a0ec43a837082570a0cb955651daa.zip | |
IR/Analysis: call_effects can add extra blocks
Diffstat (limited to 'miasm2/ir/analysis.py')
| -rw-r--r-- | miasm2/ir/analysis.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/miasm2/ir/analysis.py b/miasm2/ir/analysis.py index 962b9889..d49f6b4e 100644 --- a/miasm2/ir/analysis.py +++ b/miasm2/ir/analysis.py @@ -4,7 +4,7 @@ import warnings import logging from miasm2.ir.ir import IntermediateRepresentation, AssignBlock -from miasm2.expression.expression import ExprOp +from miasm2.expression.expression import ExprOp, ExprAff from miasm2.analysis.data_flow import dead_simp as new_dead_simp_imp @@ -35,15 +35,22 @@ class ira(IntermediateRepresentation): * insert dependencies to arguments (stack base, registers, ...) * add some side effects (stack clean, return value, ...) + Return a couple: + * list of assignments to add to the current irblock + * list of additional irblocks + @addr: (Expr) address of the called function @instr: native instruction which is responsible of the call """ - assignblk = AssignBlock({ - self.ret_reg: ExprOp('call_func_ret', addr, self.sp), - self.sp: ExprOp('call_func_stack', addr, self.sp)}, - instr) - return [assignblk] + call_assignblk = AssignBlock( + [ + ExprAff(self.ret_reg, ExprOp('call_func_ret', addr, self.sp)), + ExprAff(self.sp, ExprOp('call_func_stack', addr, self.sp)) + ], + instr + ) + return [call_assignblk], [] def add_instr_to_current_state(self, instr, block, assignments, ir_blocks_all, gen_pc_updt): """ @@ -62,8 +69,12 @@ class ira(IntermediateRepresentation): @gen_pc_updt: insert PC update effects between instructions """ if instr.is_subcall(): - call_effects = self.call_effects(instr.args[0], instr) - assignments+= call_effects + call_assignblks, extra_irblocks = self.call_effects( + instr.args[0], + instr + ) + assignments += call_assignblks + ir_blocks_all += extra_irblocks return True if gen_pc_updt is not False: |