diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2016-01-28 15:20:50 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2016-01-28 15:37:57 +0100 |
| commit | eb29a073527ccf3eb1168c4cd6dc26f89533ee2c (patch) | |
| tree | 7141051adf6a9fb7a3c25f998e9a08037a6e1560 | |
| parent | 915b9c8f716f0b76546e6c399fbcb6e3a318b374 (diff) | |
| download | miasm-eb29a073527ccf3eb1168c4cd6dc26f89533ee2c.tar.gz miasm-eb29a073527ccf3eb1168c4cd6dc26f89533ee2c.zip | |
Core/asmbloc: generate bad block on dont_dis
| -rw-r--r-- | miasm2/core/asmbloc.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py index 73c93b3f..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 @@ -548,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, |