diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/arch/link.c | 32 |
2 files changed, 19 insertions, 18 deletions
@@ -1,5 +1,10 @@ 17-01-28 Cyrille Bagard <nocbos@gmail.com> + * src/arch/link.c: + Fix links between instructions for conditional branches. + +17-01-28 Cyrille Bagard <nocbos@gmail.com> + * src/analysis/disass/links.c: Establish natural links between instructions only when relevant. diff --git a/src/arch/link.c b/src/arch/link.c index 0e11521..dfc2bd5 100644 --- a/src/arch/link.c +++ b/src/arch/link.c @@ -98,8 +98,9 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC bool defined; /* Adresse définie ? */ vmpa2t addr; /* Adresse de destination */ virt_t virt; /* Adresse virtuelle */ - instr_iter_t *iter; /* Parcours d'instructions */ GArchInstruction *target; /* Ligne visée par la référence*/ + const mrange_t *range; /* Emplacement d'instruction */ + vmpa2t next; /* Position suivante */ assert(g_arch_instruction_count_operands(instr) > index); @@ -124,31 +125,26 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC if (defined) { - iter = g_arch_processor_get_iter_from_address(proc, &addr); + target = g_arch_processor_find_instr_by_address(proc, &addr); - if (iter != NULL) + if (target != NULL) { - target = get_instruction_iterator_current(iter); - - if (target != NULL) - { - g_arch_instruction_link_with(instr, target, ILT_JUMP_IF_TRUE); + g_arch_instruction_link_with(instr, target, ILT_JUMP_IF_TRUE); - g_object_unref(G_OBJECT(target)); - - } + g_object_unref(G_OBJECT(target)); - target = get_instruction_iterator_next(iter); + } - if (target != NULL) - { - g_arch_instruction_link_with(instr, target, ILT_JUMP_IF_FALSE); + range = g_arch_instruction_get_range(instr); + compute_mrange_end_addr(range, &next); - g_object_unref(G_OBJECT(target)); + target = g_arch_processor_find_instr_by_address(proc, &next); - } + if (target != NULL) + { + g_arch_instruction_link_with(instr, target, ILT_JUMP_IF_FALSE); - delete_instruction_iterator(iter); + g_object_unref(G_OBJECT(target)); } |