From 36a006b2ac60c0cc1a2e2bea00d88508294be7f0 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 28 Jan 2017 00:17:56 +0100 Subject: Fixed links between instructions for conditional branches. --- ChangeLog | 5 +++++ src/arch/link.c | 32 ++++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index bfaf59a..b22f4c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 17-01-28 Cyrille Bagard + * src/arch/link.c: + Fix links between instructions for conditional branches. + +17-01-28 Cyrille Bagard + * 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)); } -- cgit v0.11.2-87-g4458