summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-01-27 23:17:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-01-27 23:17:56 (GMT)
commit36a006b2ac60c0cc1a2e2bea00d88508294be7f0 (patch)
treed63cfb60ad652c759ede239faa6e85eb6b913ad3 /src/arch
parente5e7408e52f33039db6315f82b294e604503ad78 (diff)
Fixed links between instructions for conditional branches.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/link.c32
1 files changed, 14 insertions, 18 deletions
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));
}