diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-01-06 16:20:46 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-01-12 15:38:53 +0100 |
| commit | d65f83036b23c825f3c68030df294cfebf4c51d8 (patch) | |
| tree | 4ad919af15fea89b9accb6e6095606dde110d09e /miasm2/jitter/codegen.py | |
| parent | fd1f440961b24872a5a9c0da19cfc94d1d955386 (diff) | |
| download | miasm-d65f83036b23c825f3c68030df294cfebf4c51d8.tar.gz miasm-d65f83036b23c825f3c68030df294cfebf4c51d8.zip | |
Jitter: fix max exec self loop
Diffstat (limited to 'miasm2/jitter/codegen.py')
| -rw-r--r-- | miasm2/jitter/codegen.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py index fff707e5..2503e104 100644 --- a/miasm2/jitter/codegen.py +++ b/miasm2/jitter/codegen.py @@ -324,10 +324,20 @@ class CGen(object): return out def gen_goto_code(self, attrib, instr_offsets, dst): + if isinstance(dst, asm_label) and dst.offset is None: + # Generate goto for local labels + return ['goto %s;' % dst.name] + offset = None + if isinstance(dst, asm_label) and dst.offset is not None: + offset = dst.offset + elif isinstance(dst, (int, long)): + offset = dst out = [] - if isinstance(dst, asm_label): - out.append('goto %s;' % dst.name) - elif dst in instr_offsets: + if (offset is not None and + offset > attrib.instr.offset and + offset in instr_offsets): + # Only generate goto for next instructions. + # (consecutive instructions) lbl = self.ir_arch.symbol_pool.getby_offset_create(dst) out += self.gen_post_code(attrib) out += self.gen_post_instr_checks(attrib, dst) |