diff options
| author | serpilliere <devnull@localhost> | 2012-07-04 09:44:23 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-07-04 09:44:23 +0200 |
| commit | de1f8324bee530930d75f0053d5fabbb0cf413d2 (patch) | |
| tree | 734a0d872b6def1f6d5e57951d45efbafb641cee | |
| parent | 807d1e75a965aed44485956f54329d2082554363 (diff) | |
| download | miasm-de1f8324bee530930d75f0053d5fabbb0cf413d2.tar.gz miasm-de1f8324bee530930d75f0053d5fabbb0cf413d2.zip | |
expression_helper: fix exprcompose simplification
| -rw-r--r-- | example/expression/manip_expression6.py | 5 | ||||
| -rw-r--r-- | miasm/expression/expression_helper.py | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/example/expression/manip_expression6.py b/example/expression/manip_expression6.py index 024de0f4..180022e1 100644 --- a/example/expression/manip_expression6.py +++ b/example/expression/manip_expression6.py @@ -102,6 +102,11 @@ to_test = [(ExprInt32(5)+c+a+b-a+ExprInt32(1)-ExprInt32(5)), ExprCond(ExprInt32(0), b, a), ExprInt32(0x80000000)[31:32], + ExprCompose([(ExprInt16(0x1337)[:8], 0, 8),(ExprInt16(0x1337)[8:16], 8, 16)]), + + ExprCompose([(ExprInt32(0x1337beef)[8:16], 8, 16), + (ExprInt32(0x1337beef)[:8], 0, 8), + (ExprInt32(0x1337beef)[16:32], 16, 32)]), ] diff --git a/miasm/expression/expression_helper.py b/miasm/expression/expression_helper.py index d2c239c1..c0b2ba46 100644 --- a/miasm/expression/expression_helper.py +++ b/miasm/expression/expression_helper.py @@ -53,8 +53,6 @@ def merge_sliceto_slice(args): sources[a[0].arg].append(a) else: non_slice[a[1]] = a - - # find max stop to determine size max_size = None for a in args: @@ -72,15 +70,14 @@ def merge_sliceto_slice(args): sorted_s.sort() while sorted_s: start, v = sorted_s.pop() - out = v[0].copy(), v[1], v[2] + out = [v[0].copy(), v[1], v[2]] while sorted_s: if sorted_s[-1][1][2] != start: break start = sorted_s[-1][1][1] - - a = uint64((int(out[0].arg) << (out[1] - start )) + sorted_s[-1][1][0].arg) - out.arg = ExprInt(uint32(a)) + a = uint64((int(out[0].arg) << (out[1] - start )) + int(sorted_s[-1][1][0].arg)) + out[0].arg = a sorted_s.pop() out[1] = start |