diff options
| author | Camille Mougey <commial@gmail.com> | 2016-01-28 16:07:53 +0100 |
|---|---|---|
| committer | Camille Mougey <commial@gmail.com> | 2016-01-28 16:07:53 +0100 |
| commit | d2588f52509c2f87c41b1dc533e7d725acd5f9be (patch) | |
| tree | 7141051adf6a9fb7a3c25f998e9a08037a6e1560 | |
| parent | c73fa6e7b3a4f528dc6c03d79e3957d9e027cd17 (diff) | |
| parent | eb29a073527ccf3eb1168c4cd6dc26f89533ee2c (diff) | |
| download | miasm-d2588f52509c2f87c41b1dc533e7d725acd5f9be.tar.gz miasm-d2588f52509c2f87c41b1dc533e7d725acd5f9be.zip | |
Merge pull request #311 from serpilliere/dont_dis_bb
Dont dis bb
| -rw-r--r-- | miasm2/core/asmbloc.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py index aa26cfbf..a4427206 100644 --- a/miasm2/core/asmbloc.py +++ b/miasm2/core/asmbloc.py @@ -259,7 +259,8 @@ class asm_block_bad(asm_bloc): ERROR_TYPES = {-1: "Unknown error", 0: "Unable to disassemble", - 1: "Reach a null starting block", + 1: "Null starting block", + 2: "Address forbidden by dont_dis", } def __init__(self, label=None, alignment=1, errno=-1, *args, **kwargs): @@ -426,7 +427,18 @@ def dis_bloc(mnemo, pool_bin, label, offset, job_done, symbol_pool, if in_delayslot: delayslot_count -= 1 - if offset in dont_dis or (lines_cpt > 0 and offset in split_dis): + if offset in dont_dis: + if not cur_block.lines: + job_done.add(offset) + # Block is empty -> bad block + cur_block = asm_block_bad(label, errno=2) + else: + # Block is not empty, stop the desassembly pass and add a + # constraint to the next block + cur_block.add_cst(offset, asm_constraint.c_next, symbol_pool) + break + + if lines_cpt > 0 and offset in split_dis: cur_block.add_cst(offset, asm_constraint.c_next, symbol_pool) offsets_to_dis.add(offset) break @@ -450,6 +462,7 @@ def dis_bloc(mnemo, pool_bin, label, offset, job_done, symbol_pool, if instr is None: log_asmbloc.warning("cannot disasm at %X", int(off_i)) if not cur_block.lines: + job_done.add(offset) # Block is empty -> bad block cur_block = asm_block_bad(label, errno=0) else: @@ -547,19 +560,6 @@ def dis_bloc_all(mnemo, pool_bin, offset, job_done, symbol_pool, dont_dis=[], continue if n in job_done: continue - - if n in dont_dis: - continue - dd_flag = False - for dd in dont_dis: - if not isinstance(dd, tuple): - continue - dd_a, dd_b = dd - if dd_a <= n < dd_b: - dd_flag = True - break - if dd_flag: - continue label = symbol_pool.getby_offset_create(n) cur_block, nexts = dis_bloc(mnemo, pool_bin, label, n, job_done, symbol_pool, dont_dis, split_dis, |