diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2015-03-27 14:50:11 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2015-04-01 23:47:37 +0200 |
| commit | b148652ebd8e8b02aa9514cc3d21098c7002d694 (patch) | |
| tree | 7dfa95414e79b5d84c2c89d25d96ea6dfdca1182 /miasm2/arch/x86/arch.py | |
| parent | f9c49e92dada2aa51ca594f435f962617796c116 (diff) | |
| download | miasm-b148652ebd8e8b02aa9514cc3d21098c7002d694.tar.gz miasm-b148652ebd8e8b02aa9514cc3d21098c7002d694.zip | |
Parse_asm: generate asm_label on symbol parsing
For an unknown symbol, instead of generating ExprId('toto'), it will generate
ExprId(asm_label('toto')). As label is generated in the architecture, this label
must be catched in the parse_asm module to be inserted in the current
symbol_pool.
Diffstat (limited to 'miasm2/arch/x86/arch.py')
| -rw-r--r-- | miasm2/arch/x86/arch.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py index 238567ac..ef6a6fb9 100644 --- a/miasm2/arch/x86/arch.py +++ b/miasm2/arch/x86/arch.py @@ -9,6 +9,7 @@ from collections import defaultdict import miasm2.arch.x86.regs as regs_module from miasm2.arch.x86.regs import * from miasm2.ir.ir import * +from miasm2.core.asmbloc import asm_label log = logging.getLogger("x86_arch") console_handler = logging.StreamHandler() @@ -225,7 +226,7 @@ variable, operand, base_expr = gen_base_expr() def ast_id2expr(t): if not t in mn_x86.regs.all_regs_ids_byname: - r = ExprId(t) + r = ExprId(asm_label(t)) else: r = mn_x86.regs.all_regs_ids_byname[t] return r @@ -486,10 +487,13 @@ class instruction_x86(instruction): if self.additional_info.g1.value & 6 and self.name in repeat_mn: return e = self.args[0] - if isinstance(e, ExprId) and not e.name in all_regs_ids_byname: - l = symbol_pool.getby_name_create(e.name) - s = ExprId(l, e.size) - self.args[0] = s + if isinstance(e, ExprId): + if isinstance(e.name, asm_label): + pass + elif not e.name in all_regs_ids_byname: + l = symbol_pool.getby_name_create(e.name) + s = ExprId(l, e.size) + self.args[0] = s elif isinstance(e, ExprInt): ad = e.arg + int(self.offset) + self.l l = symbol_pool.getby_offset_create(ad) |