diff options
| -rw-r--r-- | miasm2/arch/arm/arch.py | 3 | ||||
| -rw-r--r-- | miasm2/core/asmbloc.py | 28 | ||||
| -rw-r--r-- | miasm2/core/cpu.py | 6 |
3 files changed, 11 insertions, 26 deletions
diff --git a/miasm2/arch/arm/arch.py b/miasm2/arch/arm/arch.py index fe1c4fd4..dbcb62de 100644 --- a/miasm2/arch/arm/arch.py +++ b/miasm2/arch/arm/arch.py @@ -336,6 +336,9 @@ class instruction_arm(instruction): args = [a for a in self.args] return args + def get_asm_offset(self, x): + # LDR XXX, [PC, offset] => PC is self.offset+8 + return ExprInt_from(x, self.offset+8) class instruction_armt(instruction_arm): diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py index 98d6d2d7..5770c82b 100644 --- a/miasm2/core/asmbloc.py +++ b/miasm2/core/asmbloc.py @@ -961,42 +961,22 @@ def asmbloc_final(mnemo, mode, blocs, symbol_pool, symb_reloc_off=None, conserva my_symb_reloc_off[b.label] = [] for instr in b.lines: if isinstance(instr, asm_raw): - offset_i += instr.l # len(instr.data) + offset_i += instr.l continue - # if not [True for a in instr.arg if mnemo.has_symb(a)]: - # offset_i+=len(instr.data) - # continue - sav_a = instr.args[:] # [a.expr for a in instr.args] - # print [str(x) for x in sav_a] + sav_a = instr.args[:] + instr.offset = b.label.offset_g + offset_i args_e = instr.resolve_args_with_symbols(symbols) for i, e in enumerate(args_e): - # print 'ee', e.size, e instr.args[i] = e - instr.offset = b.label.offset_g + offset_i if instr.dstflow(): - # instr.l = len(instr.data) instr.fixDstOffset() - """ - lbls = {} - xxx = instr.getdstflow() - if len(xxx) !=1: - raise ValueError('multi dst ?!') - label = mnemo.get_label(xxx[0]) - is_mem = mnemo.is_mem(xxx[0]) - lbls[label.name] = label.offset_g - instr.fixdst(lbls, b.label.offset_g+b.blen, is_mem) - """ - # else: - # instr.arg = [mnemo.fix_symbol(a, symbol_pool) - # for a in instr.arg] - # pass + symbol_reloc_off = [] old_l = instr.l c, candidates = conservative_asm( mnemo, mode, instr, symbol_reloc_off, conservative) - # print "XXXX", instr # print candidates for i, e in enumerate(sav_a): instr.args[i] = e diff --git a/miasm2/core/cpu.py b/miasm2/core/cpu.py index c01759f4..b1034327 100644 --- a/miasm2/core/cpu.py +++ b/miasm2/core/cpu.py @@ -960,6 +960,9 @@ class instruction(object): o += self.gen_args(args) return o + def get_asm_offset(self, x): + return ExprInt_from(x, self.offset) + def resolve_args_with_symbols(self, symbols=None): if symbols is None: symbols = {} @@ -978,8 +981,7 @@ class instruction(object): name = x.name # special symbol if name == '$': - value = ExprInt_from(x, self.offset) - fixed_ids[x] = value + fixed_ids[x] = self.get_asm_offset(x) continue if not name in symbols: continue |