diff options
| author | serpilliere <devnull@localhost> | 2012-06-01 16:40:03 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-06-01 16:40:03 +0200 |
| commit | 2ec2401129c315c45ea8c22f46b29f1f9ea69547 (patch) | |
| tree | b781cda06cef2a9074ad1638163ff101f3cfbfd2 | |
| parent | a34a6e01e5ca1dafbdc539fcbf28d17df657ef77 (diff) | |
| download | focaccia-miasm-2ec2401129c315c45ea8c22f46b29f1f9ea69547.tar.gz focaccia-miasm-2ec2401129c315c45ea8c22f46b29f1f9ea69547.zip | |
expr: fix exprcompose bugs; ia32sem bug
| -rw-r--r-- | miasm/arch/ia32_sem.py | 2 | ||||
| -rw-r--r-- | miasm/core/asmbloc.py | 4 | ||||
| -rw-r--r-- | miasm/expression/expression_eval_abstract.py | 42 | ||||
| -rw-r--r-- | miasm/expression/expression_helper.py | 10 |
4 files changed, 29 insertions, 29 deletions
diff --git a/miasm/arch/ia32_sem.py b/miasm/arch/ia32_sem.py index e28c1327..018d5636 100644 --- a/miasm/arch/ia32_sem.py +++ b/miasm/arch/ia32_sem.py @@ -1589,7 +1589,7 @@ def ficom(info, a): return e def fcomp(info, a): - e= fcom(a) + e= fcom(info, a) e+=float_pop() e += set_float_cs_eip(info) diff --git a/miasm/core/asmbloc.py b/miasm/core/asmbloc.py index 1860b856..0ad2a1fb 100644 --- a/miasm/core/asmbloc.py +++ b/miasm/core/asmbloc.py @@ -1262,10 +1262,10 @@ def dis_multi_func(in_str, mn, symbol_pool, ad, dont_dis = [], follow_call = Fal all_bloc = split_bloc(all_bloc, symbol_pool, more_ref = call_ad) return all_bloc -def dis_one_bloc(in_str, mnemo, ad): +def dis_one_bloc(in_str, mnemo, ad, **kargs): job_done = set() symbol_pool = asm_symbol_pool() - all_bloc = dis_bloc_all(mnemo, in_str, ad, job_done, symbol_pool, bloc_wd = 1) + all_bloc = dis_bloc_all(mnemo, in_str, ad, job_done, symbol_pool, bloc_wd = 1, **kargs) if len(all_bloc) != 1: return None return all_bloc[0] diff --git a/miasm/expression/expression_eval_abstract.py b/miasm/expression/expression_eval_abstract.py index 5e2d397b..d8a37b40 100644 --- a/miasm/expression/expression_eval_abstract.py +++ b/miasm/expression/expression_eval_abstract.py @@ -716,18 +716,18 @@ class eval_abs: def eval_ExprCompose(self, e, eval_cache = {}): args = [] - for a in e.args: - aa = self.eval_expr(a.arg, eval_cache) + for x, start, stop in e.args: + aa = self.eval_expr(x, eval_cache) if isinstance(aa, ExprTop): return ExprTop() else: - args.append(aa) - for a in args: - if isinstance(a, ExprTop): + args.append((aa, start, stop)) + for x, start, stop in args: + if isinstance(x, ExprTop): return ExprTop() is_int = True is_int_cond = 0 - for x in args: + for x, start, stop in args: if isinstance(x, ExprInt): continue is_int = False @@ -738,26 +738,26 @@ class eval_abs: if not is_int and is_int_cond!=1: - uu = ExprCompose([(a, e.args[i][1], e.args[i][2]) for i, a in enumerate(args)]) + uu = ExprCompose([(a, start, stop) for a, start, stop in args]) return uu if not is_int: rez = 0L total_bit = 0 - for i in xrange(len(e.args)): - if isinstance(args[i], ExprInt): - a = args[i].arg + for xx, start, stop in args: + if isinstance(xx, ExprInt): + a = xx.arg - mask = (1<<(e.args[i][2]-e.args[i][1]))-1 + mask = (1<<(stop-start))-1 a&=mask - a<<=e.args[i][1] - total_bit+=e.args[i][2]-e.args[i][1] + a<<=start + total_bit+=stop-start rez|=a else: - a = args[i] - mask = (1<<(e.args[i][2]-e.args[i][1]))-1 - total_bit+=e.args[i][2]-e.args[i][1] + a = xx + mask = (1<<(stop-start))-1 + total_bit+=stop-start mycond, mysrc1, mysrc2 = a.cond, a.src1.arg&mask, a.src2.arg&mask cond_i = i @@ -771,18 +771,18 @@ class eval_abs: ExprInt(tab_uintsize[total_bit](mysrc1)), ExprInt(tab_uintsize[total_bit](mysrc2))), eval_cache) else: - raise 'cannot return non rounb bytes rez! %X %X'%(total_bit, rez) + raise 'cannot return non round bytes rez! %X %X'%(total_bit, rez) rez = 0L total_bit = 0 - for i in xrange(len(e.args)): - a = args[i].arg - mask = (1<<(e.args[i][2]-e.args[i][1]))-1 + for xx, start, stop in args: + a = xx.arg + mask = (1<<(stop-start))-1 a&=mask a<<=e.args[i][1] - total_bit+=e.args[i][2]-e.args[i][1] + total_bit+=stop-start rez|=a if total_bit in tab_uintsize: return ExprInt(tab_uintsize[total_bit](rez)) diff --git a/miasm/expression/expression_helper.py b/miasm/expression/expression_helper.py index 8cf422bb..37a2a273 100644 --- a/miasm/expression/expression_helper.py +++ b/miasm/expression/expression_helper.py @@ -40,7 +40,7 @@ def merge_sliceto_slice(args): sources_int = {} for a in args: if isinstance(a[0], ExprInt): - #sources_int[a.start] = a + # sources_int[a.start] = a # copy ExprInt because we will inplace modify arg just below # /!\ TODO XXX never ever modify inplace args... sources_int[a[1]] = (ExprInt(a[0].arg.__class__(a[0].arg)), @@ -54,13 +54,13 @@ def merge_sliceto_slice(args): non_slice[a[1]] = a - #find max stop to determine size + # find max stop to determine size max_size = None for a in args: if max_size == None or max_size < a[2]: max_size = a[2] - #first simplify all num slices + # first simplify all num slices final_sources = [] sorted_s = [] for x in sources_int.values(): @@ -72,7 +72,7 @@ def merge_sliceto_slice(args): while sorted_s: start, v = sorted_s.pop() - out = e.reload_expr() + out = v[0].reload_expr(), v[1], v[2] while sorted_s: if sorted_s[-1][1][2] != start: break @@ -510,7 +510,7 @@ def expr_simp_w(e): elif isinstance(arg, ExprInt): total_bit = e.stop-e.start - mask = uint64((uint64(1)<<(e.stop-e.start))-1) + mask = uint64((1<<(e.stop-e.start))-1) if total_bit in tab_size_int: return ExprInt(tab_size_int[total_bit]((uint64((arg.arg)>>e.start)) & mask)) else: |