summaryrefslogtreecommitdiff
path: root/src/analysis/disass/links.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/disass/links.c')
-rw-r--r--src/analysis/disass/links.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c
index d67040b..e1bc58c 100644
--- a/src/analysis/disass/links.c
+++ b/src/analysis/disass/links.c
@@ -53,9 +53,9 @@ 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 ? */
- instr_link_t *others; /* Instructions diverses liées */
size_t count; /* Nbre de sources affichées */
+ bool has_src; /* Présence de sources ? */
+ instr_link_t *other; /* Instruction diverse liée */
size_t i; /* Boucle de parcours */
bool no_natural; /* Aucun lien naturel présent */
bool no_need; /* Pas de besoin pour ce lien */
@@ -65,17 +65,22 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
* on ne peut pas créer de lien plus naturel que l'existant.
*/
- g_arch_instruction_rlock_src(instr);
+ g_arch_instruction_lock_src(instr);
- count = g_arch_instruction_get_sources(instr, &others);
+ count = g_arch_instruction_count_sources(instr);
has_src = false;
for (i = 0; i < count && !has_src; i++)
- if (others[i].type != ILT_REF)
+ {
+ other = g_arch_instruction_get_source(instr, i);
+
+ if (other->type != ILT_REF)
has_src = true;
- g_arch_instruction_runlock_src(instr);
+ }
+
+ g_arch_instruction_unlock_src(instr);
if (!has_src)
return;
@@ -96,15 +101,18 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
* déjà en place.
*/
- g_arch_instruction_rlock_dest(prev);
+ g_arch_instruction_lock_dest(prev);
- count = g_arch_instruction_get_destinations(prev, &others);
+ count = g_arch_instruction_count_destinations(prev);
no_natural = true;
no_need = (count > 0);
for (i = 0; i < count && no_natural; i++)
- switch (others[i].type)
+ {
+ other = g_arch_instruction_get_destination(prev, i);
+
+ switch (other->type)
{
case ILT_EXEC_FLOW:
no_natural = false;
@@ -112,7 +120,7 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
case ILT_JUMP_IF_TRUE:
case ILT_JUMP_IF_FALSE:
- if (others[i].linked != instr)
+ if (other->linked != instr)
no_need = false;
else
{
@@ -126,20 +134,25 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
}
+ }
+
check_done:
- g_arch_instruction_runlock_dest(prev);
+ g_arch_instruction_unlock_dest(prev);
if (no_natural && !no_need)
{
/* Vérification de la cohérence de l'ensemble */
#ifndef NDEBUG
- g_arch_instruction_rlock_src(instr);
- count = g_arch_instruction_get_sources(instr, &others);
+ g_arch_instruction_lock_src(instr);
+ count = g_arch_instruction_count_sources(instr);
for (i = 0; i < count; i++)
- switch (others[i].type)
+ {
+ other = g_arch_instruction_get_source(instr, i);
+
+ switch (other->type)
{
case ILT_EXEC_FLOW:
assert(false);
@@ -151,7 +164,7 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
case ILT_JUMP_IF_FALSE:
case ILT_LOOP:
case ILT_CATCH_EXCEPTION:
- assert(others[i].linked != prev);
+ assert(other->linked != prev);
break;
default:
@@ -159,7 +172,9 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
}
- g_arch_instruction_runlock_src(instr);
+ }
+
+ g_arch_instruction_unlock_src(instr);
#endif