about summary refs log tree commit diff stats
path: root/miasm2/expression/simplifications.py
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-06-12 13:09:48 +0200
committerserpilliere <devnull@localhost>2014-06-12 13:09:48 +0200
commit56774f174d5d8c55f2961fb22bb2b2ceee46e3fd (patch)
tree1b14ea50687f0767a909265d72da651fc2fb4f4c /miasm2/expression/simplifications.py
parentd249df3798533f575d4d9199b0ee6469cdd3ca7e (diff)
downloadmiasm-56774f174d5d8c55f2961fb22bb2b2ceee46e3fd.tar.gz
miasm-56774f174d5d8c55f2961fb22bb2b2ceee46e3fd.zip
expression: fix rol/ror simplifications (fix by fperigaud)
Diffstat (limited to 'miasm2/expression/simplifications.py')
-rw-r--r--miasm2/expression/simplifications.py8
1 files changed, 7 insertions, 1 deletions
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 == '%':