diff options
| author | serpilliere <devnull@localhost> | 2014-06-12 13:09:48 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2014-06-12 13:09:48 +0200 |
| commit | 56774f174d5d8c55f2961fb22bb2b2ceee46e3fd (patch) | |
| tree | 1b14ea50687f0767a909265d72da651fc2fb4f4c | |
| parent | d249df3798533f575d4d9199b0ee6469cdd3ca7e (diff) | |
| download | miasm-56774f174d5d8c55f2961fb22bb2b2ceee46e3fd.tar.gz miasm-56774f174d5d8c55f2961fb22bb2b2ceee46e3fd.zip | |
expression: fix rol/ror simplifications (fix by fperigaud)
| -rw-r--r-- | miasm2/expression/expression_helper.py | 2 | ||||
| -rw-r--r-- | miasm2/expression/simplifications.py | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/miasm2/expression/expression_helper.py b/miasm2/expression/expression_helper.py index cd59730b..0a4dd3ca 100644 --- a/miasm2/expression/expression_helper.py +++ b/miasm2/expression/expression_helper.py @@ -128,7 +128,7 @@ def merge_sliceto_slice(args): op_propag_cst = ['+', '*', '^', '&', '|', '>>', - '<<', "a>>", ">>>", "/", "%", 'idiv', 'irem'] + '<<', "a>>", ">>>", "<<<", "/", "%", 'idiv', 'irem'] def is_pure_int(e): diff --git a/miasm2/expression/simplifications.py b/miasm2/expression/simplifications.py index 29d19614..756df880 100644 --- a/miasm2/expression/simplifications.py +++ b/miasm2/expression/simplifications.py @@ -23,6 +23,8 @@ def simp_cst_propagation(e_s, e): op = e.op # simpl integer manip # int OP int => int + + # TODO: <<< >>> << >> may be architecture dependant!! if op in op_propag_cst: while (len(args) >= 2 and isinstance(args[-1], ExprInt) and @@ -48,7 +50,11 @@ def simp_cst_propagation(e_s, e): x2 = mod_size2int[i2.arg.size](i2.arg) o = mod_size2uint[i1.arg.size](x1 >> x2) elif op == '>>>': - o = i1.arg >> i2.arg | i1.arg << (i1.size - i2.arg) + rounds = i2.arg % i1.size + o = i1.arg >> rounds | i1.arg << (i1.size - rounds) + elif op == '<<<': + rounds = i2.arg % i1.size + o = i1.arg << rounds | i1.arg >> (i1.size - rounds) elif op == '/': o = i1.arg / i2.arg elif op == '%': |