diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2014-10-31 10:41:18 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2014-10-31 10:41:18 +0100 |
| commit | 80cfb30b725cf4d53dea151755a3328f18db68c3 (patch) | |
| tree | 37b6e8d0e6a39783a5e82e3e3e73894bae6ea86c /miasm2/expression | |
| parent | 37a2072c9efc9980638a58d4464c6e87e9863bbf (diff) | |
| download | miasm-80cfb30b725cf4d53dea151755a3328f18db68c3.tar.gz miasm-80cfb30b725cf4d53dea151755a3328f18db68c3.zip | |
Expression: fix umod/udiv in expression simplification
Diffstat (limited to 'miasm2/expression')
| -rw-r--r-- | miasm2/expression/expression_helper.py | 3 | ||||
| -rw-r--r-- | miasm2/expression/simplifications_common.py | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/miasm2/expression/expression_helper.py b/miasm2/expression/expression_helper.py index 92f46324..9c98b08f 100644 --- a/miasm2/expression/expression_helper.py +++ b/miasm2/expression/expression_helper.py @@ -128,7 +128,8 @@ def merge_sliceto_slice(args): op_propag_cst = ['+', '*', '^', '&', '|', '>>', - '<<', "a>>", ">>>", "<<<", "/", "%", 'idiv', 'imod'] + '<<', "a>>", ">>>", "<<<", + "/", "%", 'idiv', 'imod', 'umod', 'udiv'] def is_pure_int(e): diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py index 4f712bf0..489869f3 100644 --- a/miasm2/expression/simplifications_common.py +++ b/miasm2/expression/simplifications_common.py @@ -65,6 +65,18 @@ def simp_cst_propagation(e_s, e): x1 = mod_size2int[i1.arg.size](i1.arg) x2 = mod_size2int[i2.arg.size](i2.arg) o = mod_size2uint[i1.arg.size](x1 % x2) + elif op == 'umod': + assert(i2.arg.arg) + x1 = mod_size2uint[i1.arg.size](i1.arg) + x2 = mod_size2uint[i2.arg.size](i2.arg) + o = mod_size2uint[i1.arg.size](x1 % x2) + elif op == 'udiv': + assert(i2.arg.arg) + x1 = mod_size2uint[i1.arg.size](i1.arg) + x2 = mod_size2uint[i2.arg.size](i2.arg) + o = mod_size2uint[i1.arg.size](x1 / x2) + + o = ExprInt_fromsize(i1.size, o) args.append(o) @@ -115,7 +127,7 @@ def simp_cst_propagation(e_s, e): # op A => A if op in ['+', '*', '^', '&', '|', '>>', '<<', - 'a>>', '<<<', '>>>', 'idiv', 'imod'] and len(args) == 1: + 'a>>', '<<<', '>>>', 'idiv', 'imod', 'umod', 'udiv'] and len(args) == 1: return args[0] # A-B => A + (-B) |