summaryrefslogtreecommitdiff
path: root/src/arch/instruction.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r--src/arch/instruction.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 06d3e71..20b5f3a 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* instruction.c - gestion générique des instructions
*
- * Copyright (C) 2008-2012 Cyrille Bagard
+ * Copyright (C) 2008-2013 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -24,6 +24,7 @@
#include "instruction.h"
+#include <stdarg.h>
#include <string.h>
@@ -350,6 +351,7 @@ bool g_arch_instruction_is_return(const GArchInstruction *instr)
* Paramètres : instr = instruction dont les informations sont à consulter. *
* dest = ligne visée par la liaison (côté destination). *
* type = type de lien à construire. *
+* ... = éventuelles informations complémentaires. *
* *
* Description : Etablit un lien entre deux instructions. *
* *
@@ -359,8 +361,10 @@ bool g_arch_instruction_is_return(const GArchInstruction *instr)
* *
******************************************************************************/
-void g_arch_instruction_link_with(GArchInstruction *instr, GArchInstruction *dest, InstructionLinkType type)
+void g_arch_instruction_link_with(GArchInstruction *instr, GArchInstruction *dest, InstructionLinkType type, ...)
{
+ va_list ap; /* Gestion des variations */
+
/* Côté destination */
dest->from = (GArchInstruction **)realloc(dest->from,
@@ -376,10 +380,24 @@ void g_arch_instruction_link_with(GArchInstruction *instr, GArchInstruction *des
instr->to_count * sizeof(GArchInstruction *));
instr->links_type = (InstructionLinkType *)realloc(instr->links_type,
instr->to_count * sizeof(InstructionLinkType));
+ instr->links_info = (link_extra_info *)realloc(instr->links_info,
+ instr->to_count * sizeof(link_extra_info));
instr->to[instr->to_count - 1] = dest;
instr->links_type[instr->to_count - 1] = type;
+ va_start(ap, type);
+
+ switch (type)
+ {
+ case ILT_CASE_JUMP:
+ instr->links_info[instr->to_count - 1].imm = va_arg(ap, GImmOperand *);
+ break;
+ default:
+ break;
+ }
+
+ va_end(ap);
}
@@ -429,6 +447,7 @@ bool g_arch_instruction_has_destinations(const GArchInstruction *instr)
* Paramètres : instr = instruction dont les informations sont à consulter. *
* dests = liste des instructions de destination. [OUT] *
* types = liste des types de liens présents. [OUT] *
+* info = éventuelles informations complémentaires. [OUT] *
* *
* Description : Fournit les destinations d'une instruction donnée. *
* *
@@ -438,10 +457,15 @@ bool g_arch_instruction_has_destinations(const GArchInstruction *instr)
* *
******************************************************************************/
-size_t g_arch_instruction_get_destinations(const GArchInstruction *instr, GArchInstruction ***dests, InstructionLinkType **types)
+size_t g_arch_instruction_get_destinations(const GArchInstruction *instr, GArchInstruction ***dests, InstructionLinkType **types, link_extra_info **info)
{
*dests = instr->to;
- *types = instr->links_type;
+
+ if (types != NULL)
+ *types = instr->links_type;
+
+ if (info != NULL)
+ *info = instr->links_info;
return instr->to_count;