diff options
| author | Ajax <commial@gmail.com> | 2018-02-13 14:49:52 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2018-02-14 12:14:07 +0100 |
| commit | 3baf9b6d10b9a2e11a1d92f268ce4470f343fc64 (patch) | |
| tree | ef5408227cd69610cbd345be7a3cf69441c0d10c | |
| parent | c887ab5c5da2c12ccb84be93da238a9c9be3e229 (diff) | |
| download | miasm-3baf9b6d10b9a2e11a1d92f268ce4470f343fc64.tar.gz miasm-3baf9b6d10b9a2e11a1d92f268ce4470f343fc64.zip | |
'simp_cond_factor' is wrong if << / >> / a>> has more than 2 arguments
| -rw-r--r-- | miasm2/expression/simplifications_common.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py index 6840a0ac..22e328e1 100644 --- a/miasm2/expression/simplifications_common.py +++ b/miasm2/expression/simplifications_common.py @@ -365,6 +365,14 @@ def simp_cond_factor(e_s, expr): return expr if len(expr.args) < 2: return expr + + if expr.op in ['>>', '<<', 'a>>']: + assert len(expr.args) == 2 + + # Note: the following code is correct for non-commutative operation only if + # there is 2 arguments. Otherwise, the order is not conserved + + # Regroup sub-expression by similar conditions conds = {} not_conds = [] multi_cond = False @@ -380,7 +388,9 @@ def simp_cond_factor(e_s, expr): conds[cond].append(arg) if not multi_cond: return expr - c_out = not_conds[:] + + # Rebuild the new expression + c_out = not_conds for cond, vals in conds.items(): new_src1 = [x.src1 for x in vals] new_src2 = [x.src2 for x in vals] |