diff options
| author | serpilliere <devnull@localhost> | 2014-08-21 09:23:53 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2014-08-21 09:23:53 +0200 |
| commit | b8ef731f42da12c857e6104aef47eb407d106809 (patch) | |
| tree | 609a13aec743dcd699723f8b3b6394c7c233d769 | |
| parent | 495970a6c5665ec6a9ed8773601c6c11cb8ec041 (diff) | |
| download | miasm-b8ef731f42da12c857e6104aef47eb407d106809.tar.gz miasm-b8ef731f42da12c857e6104aef47eb407d106809.zip | |
Core: getbits use arch attrib (and can swap bytes); getbytes simply return bytes
| -rw-r--r-- | example/test_dis.py | 3 | ||||
| -rw-r--r-- | miasm2/arch/arm/arch.py | 4 | ||||
| -rw-r--r-- | miasm2/arch/mips32/arch.py | 2 | ||||
| -rw-r--r-- | miasm2/arch/msp430/arch.py | 2 | ||||
| -rw-r--r-- | miasm2/arch/sh4/arch.py | 2 | ||||
| -rw-r--r-- | miasm2/core/cpu.py | 16 |
6 files changed, 16 insertions, 13 deletions
diff --git a/example/test_dis.py b/example/test_dis.py index 7ce0cc31..ee71b7a2 100644 --- a/example/test_dis.py +++ b/example/test_dis.py @@ -112,6 +112,9 @@ elif b.startswith('\x7fELF'): if bs is None or options.shiftoffset is not None: + + if options.shiftoffset is None: + options.shiftoffset = "0" shift = int(options.shiftoffset, 16) log.warning('fallback to string input (offset=%s)' % hex(shift)) bs = bin_stream_str(b, shift=shift) diff --git a/miasm2/arch/arm/arch.py b/miasm2/arch/arm/arch.py index 22932042..e4721d06 100644 --- a/miasm2/arch/arm/arch.py +++ b/miasm2/arch/arm/arch.py @@ -518,7 +518,7 @@ class mn_arm(cls_mn): return info @classmethod - def getbits(cls, bs, start, n): + def getbits(cls, bs, attrib, start, n): if not n: return 0 o = 0 @@ -633,7 +633,7 @@ class mn_armt(cls_mn): return info @classmethod - def getbits(cls, bs, start, n): + def getbits(cls, bs, attrib, start, n): if not n: return 0 o = 0 diff --git a/miasm2/arch/mips32/arch.py b/miasm2/arch/mips32/arch.py index 9d452e68..d8420a65 100644 --- a/miasm2/arch/mips32/arch.py +++ b/miasm2/arch/mips32/arch.py @@ -206,7 +206,7 @@ class mn_mips32b(cls_mn): return info @classmethod - def getbits(cls, bs, start, n): + def getbits(cls, bs, attrib, start, n): if not n: return 0 o = 0 diff --git a/miasm2/arch/msp430/arch.py b/miasm2/arch/msp430/arch.py index ac62dd3e..0e3b4acd 100644 --- a/miasm2/arch/msp430/arch.py +++ b/miasm2/arch/msp430/arch.py @@ -239,7 +239,7 @@ class mn_msp430(cls_mn): assert l % 16 == 00, "len %r" % l @classmethod - def getbits(cls, bs, start, n): + def getbits(cls, bs, attrib, start, n): if not n: return 0 o = 0 diff --git a/miasm2/arch/sh4/arch.py b/miasm2/arch/sh4/arch.py index 61c909cc..edd1a9ce 100644 --- a/miasm2/arch/sh4/arch.py +++ b/miasm2/arch/sh4/arch.py @@ -482,7 +482,7 @@ class mn_sh4(cls_mn): return info @classmethod - def getbits(cls, bs, start, n): + def getbits(cls, bs, attrib, start, n): if not n: return 0 o = 0 diff --git a/miasm2/core/cpu.py b/miasm2/core/cpu.py index 42c4566d..a2bccbd3 100644 --- a/miasm2/core/cpu.py +++ b/miasm2/core/cpu.py @@ -1020,7 +1020,7 @@ class cls_mn(object): instruction = instruction @classmethod - def guess_mnemo(cls, bs, mode, pre_dis_info, offset): + def guess_mnemo(cls, bs, attrib, pre_dis_info, offset): candidates = [] candidates = set() @@ -1040,14 +1040,14 @@ class cls_mn(object): # print bvalo, 'len', l, fmask, fbits, fname, flen, 'TTT', bs_l * 8, offset_b, l if flen is not None: # print 'flen' - l = flen(mode, fname_values) + l = flen(attrib, fname_values) # print 'len', fname, l if l is not None: # print fname, hex(bs_l), l if bs_l * 8 - offset_b < l: continue # print hex(offset_b) - v = cls.getbits(bs, offset_b, l) + v = cls.getbits(bs, attrib, offset_b, l) # print 'TEST', bval, fname, offset_b, cpt, (l, fmask, fbits), # hex(v), hex(v & fmask), hex(fbits), v & fmask == fbits offset_b += l @@ -1063,7 +1063,7 @@ class cls_mn(object): else: todo.append((dict(fname_values), (nb, v), offset_b)) - candidates = [c for c in candidates] # if c.mode == mode] + candidates = [c for c in candidates] # if c.attrib == attrib] if not candidates: raise Disasm_Exception('cannot disasm (guess) at %X' % offset) @@ -1117,7 +1117,7 @@ class cls_mn(object): return True @classmethod - def getbits(cls, bs, offset_b, l): + def getbits(cls, bs, attrib, offset_b, l): return bs.getbits(offset_b, l) @classmethod @@ -1125,8 +1125,8 @@ class cls_mn(object): return bs.getbytes(offset, l) @classmethod - def pre_dis(cls, v_o, mode_o, offset): - return {}, v_o, mode_o, offset, 0 + def pre_dis(cls, v_o, attrib, offset): + return {}, v_o, attrib, offset, 0 def post_dis(self): return self @@ -1213,7 +1213,7 @@ class cls_mn(object): if bs_l * 8 - offset_b < l: getok = False break - bv = cls.getbits(bs, offset_b, l) + bv = cls.getbits(bs, mode, offset_b, l) offset_b += l if not f.fname in fname_values: fname_values[f.fname] = bv |