summaryrefslogtreecommitdiff
path: root/src/arch/x86
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-06-16 22:46:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-06-16 22:46:35 (GMT)
commit23c7cd436e2ec980a68e6d12a6d8a750e357763c (patch)
tree0c27434a3ab3946e9b4766ae8ebe28ab399d9d84 /src/arch/x86
parentdf1f4c4e1a5bb929f4345b1273d16558c0ba77de (diff)
Made links between lines of code (x86 only).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@79 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/x86')
-rw-r--r--src/arch/x86/instruction.c75
-rw-r--r--src/arch/x86/operand.c20
-rw-r--r--src/arch/x86/operand.h4
3 files changed, 97 insertions, 2 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;
+
+}
diff --git a/src/arch/x86/operand.c b/src/arch/x86/operand.c
index 5e01fd7..8f218fc 100644
--- a/src/arch/x86/operand.c
+++ b/src/arch/x86/operand.c
@@ -30,7 +30,6 @@
#include "registers.h"
-#include "../immediate.h"
#include "../operand.h"
#include "../operand-int.h"
#include "../../common/extstr.h"
@@ -787,6 +786,25 @@ static char *g_x86_relative_operand_get_text(const GX86RelativeOperand *operand,
}
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* *
+* Description : Fournit l'adresse relative représentée par une opérande X86. *
+* *
+* Retour : Valeur portée par l'opérande. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const GImmOperand *g_x86_relative_operand_get_value(const GX86RelativeOperand *operand)
+{
+ return operand->immediate;
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* OPERANDES D'EMPLACEMENTS MEMOIRE */
diff --git a/src/arch/x86/operand.h b/src/arch/x86/operand.h
index 1139fe2..9f4db09 100644
--- a/src/arch/x86/operand.h
+++ b/src/arch/x86/operand.h
@@ -28,6 +28,7 @@
#include <stdbool.h>
+#include "../immediate.h"
#include "../instruction.h"
@@ -129,6 +130,9 @@ GType g_x86_relative_operand_get_type(void);
/* Crée un opérande X86 d'adresse relative. */
GArchOperand *g_x86_relative_operand_new(const bin_t *, off_t *, off_t, AsmOperandSize, vmpa_t);
+/* Fournit l'adresse relative représentée par une opérande X86. */
+const GImmOperand *g_x86_relative_operand_get_value(const GX86RelativeOperand *);
+
/* ------------------------ OPERANDES D'EMPLACEMENTS MEMOIRE ------------------------ */