about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2016-01-21 21:25:08 +0100
committerCamille Mougey <commial@gmail.com>2016-01-21 21:25:08 +0100
commitaeeb1918b47ef9fc0be0b57bc916aa7f39f22387 (patch)
tree09df69b7069ee92724a578264641dfdb493318bf
parentd49e05f1aef8da814fa7bfc1b99e7051e51db0b0 (diff)
parent8d2a5d2dd267f2240e14c5ebe238dd0f44a2474e (diff)
downloadmiasm-aeeb1918b47ef9fc0be0b57bc916aa7f39f22387.tar.gz
miasm-aeeb1918b47ef9fc0be0b57bc916aa7f39f22387.zip
Merge pull request #307 from serpilliere/fix_add_instr
Fix asmbloc
-rw-r--r--miasm2/core/asmbloc.py9
-rw-r--r--miasm2/ir/ir.py2
2 files changed, 7 insertions, 4 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py
index a6d652be..3517d452 100644
--- a/miasm2/core/asmbloc.py
+++ b/miasm2/core/asmbloc.py
@@ -103,7 +103,8 @@ class asm_constraint_to(asm_constraint):
 
 class asm_bloc(object):
 
-    def __init__(self, label=None, alignment=1):
+    def __init__(self, label, alignment=1):
+        assert isinstance(label, asm_label)
         self.bto = set()
         self.lines = []
         self.label = label
@@ -165,8 +166,10 @@ class asm_bloc(object):
         return new_bloc
 
     def get_range(self):
+        """Returns the offset hull of an asm_bloc"""
         if len(self.lines):
-            return self.lines[0].offset, self.lines[-1].offset
+            return (self.lines[0].offset,
+                    self.lines[-1].offset + self.lines[-1].l)
         else:
             return 0, 0
 
@@ -543,7 +546,7 @@ def split_bloc(mnemo, attrib, pool_bin, blocs,
         a, b = cb.get_range()
 
         for off in bloc_dst:
-            if not (off > a and off <= b):
+            if not (off > a and off < b):
                 continue
             l = symbol_pool.getby_offset_create(off)
             new_b = cb.split(off, l)
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py
index f957fcab..9d90f79a 100644
--- a/miasm2/ir/ir.py
+++ b/miasm2/ir/ir.py
@@ -202,7 +202,7 @@ class ir(object):
         return self.blocs.get(label, None)
 
     def add_instr(self, l, ad=0, gen_pc_updt = False):
-        b = asm_bloc(l)
+        b = asm_bloc(self.gen_label())
         b.lines = [l]
         self.add_bloc(b, gen_pc_updt)