about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--example/disasm/file.py4
-rw-r--r--example/ida/ctype_propagation.py1
-rw-r--r--miasm2/core/asmblock.py4
-rw-r--r--miasm2/core/cpu.py2
-rw-r--r--miasm2/core/parse_asm.py26
6 files changed, 8 insertions, 35 deletions
diff --git a/README.md b/README.md
index 118051df..570bee22 100644
--- a/README.md
+++ b/README.md
@@ -165,8 +165,8 @@ Disassembling the shellcode at address `0`:
 >>> from miasm2.analysis.machine import Machine
 >>> machine = Machine('x86_32')
 >>> mdis = machine.dis_engine(c.bin_stream)
->>> blocks = mdis.dis_multiblock(0)
->>> for block in blocks:
+>>> asmcfg = mdis.dis_multiblock(0)
+>>> for block in asmcfg.blocks:
 ...  print block
 ...
 loc_0000000000000000:0x00000000
@@ -269,7 +269,7 @@ Initializing the IR pool:
 
 ```
 >>> ira = machine.ira()
->>> for block in blocks:
+>>> for block in asmcfg.blocks:
 ...    ira.add_block(block)
 ...
 ```
diff --git a/example/disasm/file.py b/example/disasm/file.py
index 88ba6162..196e1b1a 100644
--- a/example/disasm/file.py
+++ b/example/disasm/file.py
@@ -13,6 +13,6 @@ cont = Container.from_stream(open(sys.argv[1]))
 mdis = dis_x86_32(cont.bin_stream)
 # Inform the engine to avoid disassembling null instructions
 mdis.dont_dis_nulstart_bloc = True
-blocks = mdis.dis_multiblock(addr)
+asmcfg = mdis.dis_multiblock(addr)
 
-open('graph.dot', 'w').write(blocks.dot())
+open('graph.dot', 'w').write(asmcfg.dot())
diff --git a/example/ida/ctype_propagation.py b/example/ida/ctype_propagation.py
index d35835dc..db324833 100644
--- a/example/ida/ctype_propagation.py
+++ b/example/ida/ctype_propagation.py
@@ -268,7 +268,6 @@ def analyse_function():
     iraCallStackFixer = get_ira_call_fixer(ira)
     ir_arch = iraCallStackFixer(mdis.symbol_pool)
 
-
     asmcfg = mdis.dis_multiblock(addr)
     # Generate IR
     for block in asmcfg.blocks:
diff --git a/miasm2/core/asmblock.py b/miasm2/core/asmblock.py
index 35b7e1db..08ff25e9 100644
--- a/miasm2/core/asmblock.py
+++ b/miasm2/core/asmblock.py
@@ -521,7 +521,7 @@ class AsmSymbolPool(object):
         return "".join("%s\n" % loc_key for loc_key in self._loc_keys)
 
     def __getitem__(self, item):
-        warnings.warn('DEPRECATION WARNING: use "offset_to_loc_key" or "name_to_loc_key"')
+        warnings.warn('DEPRECATION WARNING: use "getby_name" or "getby_offset"')
         if item in self._name_to_loc_key:
             return self._name_to_loc_key[item]
         if item in self._offset_to_loc_key:
@@ -529,7 +529,7 @@ class AsmSymbolPool(object):
         raise KeyError('unknown symbol %r' % item)
 
     def __contains__(self, item):
-        warnings.warn('DEPRECATION WARNING: use "offset_to_loc_key" or "name_to_loc_key"')
+        warnings.warn('DEPRECATION WARNING: use "getby_name" or "getby_offset"')
         return item in self._name_to_loc_key or item in self._offset_to_loc_key
 
     def merge(self, symbol_pool):
diff --git a/miasm2/core/cpu.py b/miasm2/core/cpu.py
index a142ab77..80f81aff 100644
--- a/miasm2/core/cpu.py
+++ b/miasm2/core/cpu.py
@@ -1030,7 +1030,7 @@ class instruction(object):
                 if name == '_':
                     fixed_expr[exprloc] = self.get_asm_next_offset(exprloc)
                     continue
-                if not name in symbols:
+                if symbols.getby_name(name) is None:
                     raise ValueError('Unresolved symbol: %r' % exprloc)
 
                 offset = symbols.loc_key_to_offset(loc_key)
diff --git a/miasm2/core/parse_asm.py b/miasm2/core/parse_asm.py
index 86871c37..3b97cbb6 100644
--- a/miasm2/core/parse_asm.py
+++ b/miasm2/core/parse_asm.py
@@ -73,30 +73,6 @@ def guess_next_new_label(symbol_pool):
         i += 1
 
 
-def replace_expr_labels(expr, symbol_pool, replace_id):
-    """Create LocKey of the expression @expr in the @symbol_pool
-    Update @replace_id"""
-
-    if not expr.is_loc():
-        return expr
-
-    old_name = symbol_pool.loc_key_to_name(expr.loc_key)
-    new_lbl = symbol_pool.getby_name_create(old_name)
-    replace_id[expr] = ExprLoc(new_lbl, expr.size)
-    return replace_id[expr]
-
-
-def replace_orphan_labels(instr, symbol_pool):
-    """Link orphan labels used by @instr to the @symbol_pool"""
-
-    for i, arg in enumerate(instr.args):
-        replace_id = {}
-        arg.visit(lambda e: replace_expr_labels(e,
-                                                symbol_pool,
-                                                replace_id))
-        instr.args[i] = instr.args[i].replace_expr(replace_id)
-
-
 STATE_NO_BLOC = 0
 STATE_IN_BLOC = 1
 
@@ -224,8 +200,6 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
         line = line.strip(' ').strip('\t')
         instr = mnemo.fromstring(line, symbol_pool, attrib)
 
-        replace_orphan_labels(instr, symbol_pool)
-
         if instr.dstflow():
             instr.dstflow2label(symbol_pool)
         lines.append(instr)