summaryrefslogtreecommitdiff
path: root/src/arch/x86/instruction.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/instruction.c')
-rw-r--r--src/arch/x86/instruction.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/src/arch/x86/instruction.c b/src/arch/x86/instruction.c
index f9dd828..67a1fe0 100644
--- a/src/arch/x86/instruction.c
+++ b/src/arch/x86/instruction.c
@@ -24,6 +24,7 @@
#include "instruction.h"
+#include "operand.h"
#include "../instruction-int.h"
#include "../../common/extstr.h"
@@ -312,7 +313,8 @@ static x86_instruction _instructions[XOP_COUNT] = {
/* Traduit une instruction en version humainement lisible. */
static const char *x86_get_instruction_text(const GX86Instruction *, const exe_format *, AsmSyntax);
-
+/* Informe sur une éventuelle référence à une autre instruction. */
+static InstructionLinkType x86_get_instruction_link(const GX86Instruction *, vmpa_t *);
@@ -359,6 +361,7 @@ static void g_x86_instruction_init(GX86Instruction *instr)
parent = G_ARCH_INSTRUCTION(instr);
parent->get_text = (get_instruction_text_fc)x86_get_instruction_text;
+ parent->get_link = (get_instruction_link_fc)x86_get_instruction_link;
}
@@ -510,3 +513,73 @@ static const char *x86_get_instruction_text(const GX86Instruction *instr, const
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction à consulter. *
+* addr = eventuelle adresse associée à faire connaître. [OUT] *
+* *
+* Description : Informe sur une éventuelle référence à une autre instruction.*
+* *
+* Retour : Type de lien trouvé ou ILT_NONE si aucun. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static InstructionLinkType x86_get_instruction_link(const GX86Instruction *instr, vmpa_t *addr)
+{
+ InstructionLinkType result; /* Type de lien à retourner */
+ const GX86RelativeOperand *relative; /* Adresse relative */
+
+ switch (instr->type)
+ {
+ case XOP_JO_REL8:
+ case XOP_JNO_REL8:
+ case XOP_JB_REL8:
+ case XOP_JNB_REL8:
+ case XOP_JE_REL8:
+ case XOP_JNE_REL8:
+ case XOP_JNA_REL8:
+ case XOP_JA_REL8:
+ case XOP_JS_REL8:
+ case XOP_JNS_REL8:
+ case XOP_JP_REL8:
+ case XOP_JNP_REL8:
+ case XOP_JL_REL8:
+ case XOP_JNL_REL8:
+ case XOP_JNG_REL8:
+ case XOP_JG_REL8:
+ relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
+ if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP_IF_TRUE;
+ else result = ILT_NONE;
+ break;
+
+ case XOP_CALL_REL1632:
+ relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
+ if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_CALL;
+ else result = ILT_NONE;
+ break;
+
+ case XOP_JMP_REL1632:
+ relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
+ if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP;
+ else result = ILT_NONE;
+ break;
+
+ case XOP_JMP_REL8:
+ relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
+ if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP;
+ else result = ILT_NONE;
+ break;
+
+ default:
+ result = ILT_NONE;
+ break;
+
+ }
+
+ return result;
+
+}