diff options
Diffstat (limited to 'miasm2/arch')
| -rw-r--r-- | miasm2/arch/arm/sem.py | 18 | ||||
| -rw-r--r-- | miasm2/arch/mips32/ira.py | 8 | ||||
| -rw-r--r-- | miasm2/arch/ppc/ira.py | 32 |
3 files changed, 37 insertions, 21 deletions
diff --git a/miasm2/arch/arm/sem.py b/miasm2/arch/arm/sem.py index a3d12514..00250157 100644 --- a/miasm2/arch/arm/sem.py +++ b/miasm2/arch/arm/sem.py @@ -1572,8 +1572,10 @@ class ir_arml(IntermediateRepresentation): assignments = [] loc = loc_do - split = self.add_instr_to_irblock(block, instr, assignments, - irblocks, gen_pc_updt) + split = self.add_instr_to_current_state( + instr, block, assignments, + irblocks, gen_pc_updt + ) if split: raise NotImplementedError("Unsupported instr in IT block (%s)" % instr) @@ -1587,7 +1589,7 @@ class ir_arml(IntermediateRepresentation): ir_blocks_all.append(irblocks) return index, ir_blocks_all - def add_block(self, block, gen_pc_updt=False): + def add_asmblock_to_ircfg(self, block, ircfg, gen_pc_updt=False): """ Add a native block to the current IR @block: native assembly block @@ -1613,8 +1615,10 @@ class ir_arml(IntermediateRepresentation): label = None continue - split = self.add_instr_to_irblock(block, instr, assignments, - ir_blocks_all, gen_pc_updt) + split = self.add_instr_to_current_state( + instr, block, assignments, + ir_blocks_all, gen_pc_updt + ) if split: ir_blocks_all.append(IRBlock(label, assignments)) label = None @@ -1622,9 +1626,9 @@ class ir_arml(IntermediateRepresentation): if label is not None: ir_blocks_all.append(IRBlock(label, assignments)) - new_ir_blocks_all = self.post_add_block(block, ir_blocks_all) + new_ir_blocks_all = self.post_add_asmblock_to_ircfg(block, ircfg, ir_blocks_all) for irblock in new_ir_blocks_all: - self.blocks[irblock.loc_key] = irblock + ircfg.add_irblock(irblock) return new_ir_blocks_all diff --git a/miasm2/arch/mips32/ira.py b/miasm2/arch/mips32/ira.py index 53c2c6b3..3caa8b12 100644 --- a/miasm2/arch/mips32/ira.py +++ b/miasm2/arch/mips32/ira.py @@ -10,12 +10,8 @@ class ir_a_mips32l(ir_mips32l, ira): ir_mips32l.__init__(self, loc_db) self.ret_reg = self.arch.regs.V0 - def pre_add_instr(self, block, instr, assignments, ir_blocks_all, gen_pc_updt): - # Avoid adding side effects, already done in post_add_bloc - return False - - def post_add_block(self, block, ir_blocks): - IntermediateRepresentation.post_add_block(self, block, ir_blocks) + def post_add_asmblock_to_ircfg(self, block, ircfg, ir_blocks): + IntermediateRepresentation.post_add_asmblock_to_ircfg(self, block, ircfg, ir_blocks) new_irblocks = [] for irb in ir_blocks: pc_val = None diff --git a/miasm2/arch/ppc/ira.py b/miasm2/arch/ppc/ira.py index 76a979ae..a30f972d 100644 --- a/miasm2/arch/ppc/ira.py +++ b/miasm2/arch/ppc/ira.py @@ -35,14 +35,30 @@ class ir_a_ppc32b(ir_ppc32b, ira): instr )] - def pre_add_instr(self, block, instr, assignments, ir_blocks_all, gen_pc_update): - """Replace function call with corresponding call effects, - inside the IR block""" - if not instr.is_subcall(): - return False - call_effects = self.call_effects(instr.getdstflow(None)[0], instr) - assignments+= call_effects - return True + def add_instr_to_current_state(self, instr, block, assignments, ir_blocks_all, gen_pc_updt): + """ + Add the IR effects of an instruction to the current state. + + @instr: native instruction + @block: native block source + @assignments: list of current AssignBlocks + @ir_blocks_all: list of additional effects + @gen_pc_updt: insert PC update effects between instructions + """ + if instr.is_subcall(): + call_effects = self.call_effects(instr.getdstflow(None)[0], instr) + assignments+= call_effects + return True + + if gen_pc_updt is not False: + self.gen_pc_update(assignments, instr) + + assignblk, ir_blocks_extra = self.instr2ir(instr) + assignments.append(assignblk) + ir_blocks_all += ir_blocks_extra + if ir_blocks_extra: + return True + return False def sizeof_char(self): return 8 |