From faa334f84ea2ddac65358dde0f05c074747f4e39 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 8 Mar 2017 20:27:15 +0100 Subject: Fixed conditions for adding missing natural execution flow links. --- ChangeLog | 5 +++++ src/analysis/disass/links.c | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 835f35a..8a60475 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ 17-03-08 Cyrille Bagard * src/analysis/disass/links.c: + Fix conditions for adding missing natural execution flow links. + +17-03-08 Cyrille Bagard + + * src/analysis/disass/links.c: Update code. * src/arch/instruction.h: diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c index 295b4b6..cf33677 100644 --- a/src/analysis/disass/links.c +++ b/src/analysis/disass/links.c @@ -54,11 +54,11 @@ static void convert_immediate_into_target(GArchInstruction *, size_t, GBinFormat void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev) { bool has_src; /* Présence de sources ? */ - bool no_natural; /* Aucun lien naturel présent */ - bool no_need; /* Pas de besoin pour ce lien */ instr_link_t *others; /* Instructions diverses liées */ size_t count; /* Nbre de sources affichées */ size_t i; /* Boucle de parcours */ + bool no_natural; /* Aucun lien naturel présent */ + bool no_need; /* Pas de besoin pour ce lien */ /** * Si rien ne vient séparer les deux instructions, @@ -66,7 +66,15 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev) */ g_arch_instruction_rlock_src(instr); - has_src = g_arch_instruction_has_sources(instr); + + count = g_arch_instruction_get_sources(instr, &others); + + has_src = false; + + for (i = 0; i < count && !has_src; i++) + if (others[i].type != ILT_REF) + has_src = true; + g_arch_instruction_runlock_src(instr); if (!has_src) @@ -88,12 +96,13 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev) * déjà en place. */ - no_natural = true; - no_need = true; - g_arch_instruction_rlock_dest(prev); + count = g_arch_instruction_get_destinations(prev, &others); + no_natural = true; + no_need = (count > 0); + for (i = 0; i < count && no_natural; i++) switch (others[i].type) { -- cgit v0.11.2-87-g4458