diff options
| author | Camille Mougey <commial@gmail.com> | 2016-11-07 12:24:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-07 12:24:51 +0100 |
| commit | 3af8c4a5a6668cc89a4df3fb66222f4147a896b9 (patch) | |
| tree | 21a7d7ad5d6da120e8e23e0b92725073d4d4e27c /miasm2/ir/ir.py | |
| parent | a15e0faca425c6e2591448e510bf14f1c3f04e14 (diff) | |
| parent | f0fbc59a663774dc4f4861308bee3f91ccd9746d (diff) | |
| download | miasm-3af8c4a5a6668cc89a4df3fb66222f4147a896b9.tar.gz miasm-3af8c4a5a6668cc89a4df3fb66222f4147a896b9.zip | |
Merge pull request #445 from serpilliere/symb_exec_clean
Symb exec clean
Diffstat (limited to '')
| -rw-r--r-- | miasm2/ir/ir.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index 3a841fa5..d8cccc64 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -46,7 +46,6 @@ class AssignBlock(dict): * if dst is an ExprSlice, expand it to affect the full Expression * if dst already known, sources are merged """ - if dst.size != src.size: raise RuntimeError( "sanitycheck: args must have same size! %s" % @@ -59,7 +58,8 @@ class AssignBlock(dict): for r in dst.slice_rest()] all_a = [(src, dst.start, dst.stop)] + rest all_a.sort(key=lambda x: x[1]) - new_src = m2_expr.ExprCompose(all_a) + args = [expr for (expr, _, _) in all_a] + new_src = m2_expr.ExprCompose(*args) else: new_dst, new_src = dst, src @@ -74,6 +74,7 @@ class AssignBlock(dict): expr_list = [(new_dst, new_src), (new_dst, self[new_dst])] # Find collision + print 'FIND COLISION' e_colision = reduce(lambda x, y: x.union(y), (self.get_modified_slice(dst, src) for (dst, src) in expr_list), @@ -95,7 +96,12 @@ class AssignBlock(dict): for interval in missing_i) # Build the merging expression - new_src = m2_expr.ExprCompose(e_colision.union(remaining)) + args = list(e_colision.union(remaining)) + args.sort(key=lambda x:x[1]) + starts = [start for (_, start, _) in args] + assert len(set(starts)) == len(starts) + args = [expr for (expr, _, _) in args] + new_src = m2_expr.ExprCompose(*args) super(AssignBlock, self).__setitem__(new_dst, new_src) @@ -103,17 +109,16 @@ class AssignBlock(dict): def get_modified_slice(dst, src): """Return an Expr list of extra expressions needed during the object instanciation""" - if not isinstance(src, m2_expr.ExprCompose): raise ValueError("Get mod slice not on expraff slice", str(self)) modified_s = [] - for arg in src.args: - if (not isinstance(arg[0], m2_expr.ExprSlice) or - arg[0].arg != dst or - arg[1] != arg[0].start or - arg[2] != arg[0].stop): + for index, arg in src.iter_args(): + if not (isinstance(arg, m2_expr.ExprSlice) and + arg.arg == dst and + index == arg.start and + index+arg.size == arg.stop): # If x is not the initial expression - modified_s.append(arg) + modified_s.append((arg, index, index+arg.size)) return modified_s def get_w(self): |