about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/expression/expression_helper.py2
-rw-r--r--miasm2/expression/simplifications.py8
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 == '%':