diff options
| author | serpilliere <devnull@localhost> | 2012-10-31 15:53:52 +0100 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-10-31 15:53:52 +0100 |
| commit | fc258c7428747b43460caa61f5bcd8dee5d46aec (patch) | |
| tree | 2b9a5738272636e9a118455739f182e5be3e8051 | |
| parent | 1cc3cd4efe85ce967771b865f1b8ac8eeae4e14d (diff) | |
| download | miasm-fc258c7428747b43460caa61f5bcd8dee5d46aec.tar.gz miasm-fc258c7428747b43460caa61f5bcd8dee5d46aec.zip | |
asmbloc: use first instruction in assembly candidate
| -rw-r--r-- | miasm/core/asmbloc.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/miasm/core/asmbloc.py b/miasm/core/asmbloc.py index c1ce2f75..468053ce 100644 --- a/miasm/core/asmbloc.py +++ b/miasm/core/asmbloc.py @@ -719,7 +719,7 @@ def resolve_symbol(group_bloc, dont_erase = []): log_asmbloc.debug("consumed %d rest: %d"%(g.total_max_l, int(tmp))) free_interval[g] = tmp del(free_interval[x]) - g.offset = [group_bloc[x][-1].label, group_bloc[x][-1], 1] + g.offset = [group_bloc[x][-1].label, group_bloc[x][-1], 1] g.fixedblocs = True finish = True break @@ -919,12 +919,17 @@ def asmbloc_final(mnemo, all_blocs, symbol_pool, symb_reloc_off = {}): instr.data = c fini=False break - else: - l_dict = dict([[len(x),i] for i, x in enumerate(candidates)]) - instr.data = candidates[l_dict[len(instr.data)]] + found = False + for cpos, c in enumerate(candidates): + if len(c) == len(instr.data): + instr.data = c + found = True + break + if not found: + raise ValueError('something wrong in instr.data') - if l_dict[len(instr.data)] < len(symbol_reloc_off): - my_s = symbol_reloc_off[l_dict[len(instr.data)]] + if cpos < len(symbol_reloc_off): + my_s = symbol_reloc_off[cpos] else: my_s = None |