summaryrefslogtreecommitdiff
path: root/src/analysis/disass/links.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-04-20 12:07:19 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-04-20 12:07:19 (GMT)
commit59f319d9a6961a7424c7b32f49aa7ac1045a1d4c (patch)
treee9d62c684dd8d8f5e141b9332994041bd2371f9a /src/analysis/disass/links.c
parent8962a4e61411c8362d5f4be63496977164b886a8 (diff)
Protected all concurrent accesses to sources and destinations of instructions.
Diffstat (limited to 'src/analysis/disass/links.c')
-rw-r--r--src/analysis/disass/links.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c
index 86663cc..f52029b 100644
--- a/src/analysis/disass/links.c
+++ b/src/analysis/disass/links.c
@@ -51,6 +51,7 @@ static void convert_immediate_into_target(GArchInstruction *, size_t, const GBin
void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
{
+ bool has_src; /* Présence de sources ? */
GArchInstruction **others; /* Instructions diverses liées */
InstructionLinkType *types; /* Types de lien existants */
size_t count; /* Nbre de sources affichées */
@@ -61,7 +62,11 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
* on ne peut pas créer de lien plus naturel que l'existant.
*/
- if (!g_arch_instruction_has_sources(instr))
+ g_arch_instruction_rlock_src(instr);
+ has_src = g_arch_instruction_has_sources(instr);
+ g_arch_instruction_runlock_src(instr);
+
+ if (!has_src)
return;
/**
@@ -79,6 +84,7 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
* On s'assure que le lien naturel est valide.
*/
+ g_arch_instruction_rlock_dest(prev);
count = g_arch_instruction_get_destinations(prev, &others, &types, NULL);
for (i = 0; i < count; i++)
@@ -89,12 +95,15 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
if (types[i] == ILT_LOOP) break;
}
+ g_arch_instruction_runlock_dest(prev);
+
if (count > 0 && i < count) return;
/**
* On vérifie que le lien n'existe pas déjà avant d'en créer un...
*/
+ g_arch_instruction_rlock_src(instr);
count = g_arch_instruction_get_sources(instr, &others, &types);
for (i = 0; i < count; i++)
@@ -103,6 +112,8 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
if (others[i] == prev && types[i] == ILT_JUMP_IF_FALSE) break;
}
+ g_arch_instruction_runlock_src(instr);
+
if (i == count)
g_arch_instruction_link_with(prev, instr, ILT_EXEC_FLOW);