diff options
| author | Camille Mougey <commial@gmail.com> | 2017-01-12 16:20:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-12 16:20:33 +0100 |
| commit | 97d25c6e584e48b4ff85e529da290db34847868e (patch) | |
| tree | f12ae3b7e6f4870a9deb32f358a79261844a7c97 /miasm2/jitter/codegen.py | |
| parent | 9b8756e6f95e45caa6171d9fe1f6a836291c3577 (diff) | |
| parent | 0e0e1d338af0e7dd3b60be930bbce441295b2cb4 (diff) | |
| download | miasm-97d25c6e584e48b4ff85e529da290db34847868e.tar.gz miasm-97d25c6e584e48b4ff85e529da290db34847868e.zip | |
Merge pull request #473 from serpilliere/Fix_max_exec_self_loop
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) |