summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/instruction.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/v7/instruction.c')
-rw-r--r--plugins/arm/v7/instruction.c97
1 files changed, 92 insertions, 5 deletions
diff --git a/plugins/arm/v7/instruction.c b/plugins/arm/v7/instruction.c
index 1c91b9a..d45979b 100644
--- a/plugins/arm/v7/instruction.c
+++ b/plugins/arm/v7/instruction.c
@@ -30,6 +30,11 @@
#endif
+#include <common/extstr.h>
+
+
+#include "opcodes/hooks.h"
+#include "opcodes/keywords.h"
#include "../instruction-int.h"
@@ -39,6 +44,7 @@ struct _GArmV7Instruction
{
GArmInstruction parent; /* Instance parente */
+ ARMv7Syntax sid; /* Forme de syntaxe */
char encoding; /* Encodage de l'instruction */
bool setflags; /* Mise à jour des drapeaux */
@@ -69,6 +75,12 @@ static void g_armv7_instruction_finalize(GArmV7Instruction *);
/* Indique l'encodage d'une instruction de façon détaillée. */
static const char *g_armv7_instruction_get_encoding(const GArmV7Instruction *);
+/* Fournit le nom humain de l'instruction manipulée. */
+static const char *g_armv7_instruction_get_keyword(const GArmV7Instruction *, AsmSyntax);
+
+/* Complète un désassemblage accompli pour une instruction. */
+static void g_armv7_instruction_call_hook(GArmV7Instruction *, InstrProcessHook, GArchProcessor *, GProcContext *, GExeFormat *);
+
/* Construit un petit résumé concis de l'instruction. */
static char *g_armv7_instruction_build_tooltip(const GArmV7Instruction *);
@@ -102,6 +114,8 @@ static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass)
object_class->finalize = (GObjectFinalizeFunc)g_armv7_instruction_finalize;
instr->get_encoding = (get_instruction_encoding_fc)g_armv7_instruction_get_encoding;
+ instr->get_keyword = (get_instruction_keyword_fc)g_armv7_instruction_get_keyword;
+ instr->call_hook = (call_instruction_hook_fc)g_armv7_instruction_call_hook;
instr->build_tooltip = (build_instruction_tooltip_fc)g_armv7_instruction_build_tooltip;
}
@@ -165,7 +179,8 @@ static void g_armv7_instruction_finalize(GArmV7Instruction *instr)
/******************************************************************************
* *
-* Paramètres : keyword = définition du nom humaine de l'instruction. *
+* Paramètres : uid = identifiant unique attribué à l'instruction. *
+* sid = identifiant unique attribué à sa forme de syntaxe. *
* *
* Description : Crée une instruction pour l'architecture ARMv7. *
* *
@@ -175,15 +190,17 @@ static void g_armv7_instruction_finalize(GArmV7Instruction *instr)
* *
******************************************************************************/
-GArchInstruction *g_armv7_instruction_new(const char *keyword)
+GArchInstruction *g_armv7_instruction_new(itid_t uid, ARMv7Syntax sid)
{
- GArchInstruction *result; /* Structure à retourner */
+ GArmV7Instruction *result; /* Structure à retourner */
result = g_object_new(G_TYPE_ARMV7_INSTRUCTION, NULL);
- G_ARM_INSTRUCTION(result)->keyword = keyword;
+ G_ARCH_INSTRUCTION(result)->uid = uid;
- return result;
+ result->sid = sid;
+
+ return G_ARCH_INSTRUCTION(result);
}
@@ -250,6 +267,76 @@ void g_armv7_instruction_set_encoding(GArmV7Instruction *instr, const char *enco
/******************************************************************************
* *
+* Paramètres : instr = instruction d'assemblage à consulter. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Fournit le nom humain de l'instruction manipulée. *
+* *
+* Retour : Mot clef de bas niveau. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static const char *g_armv7_instruction_get_keyword(const GArmV7Instruction *instr, AsmSyntax syntax)
+{
+ const char *result; /* Désignation à retourner */
+ GArmInstruction *parent; /* Autre forme de l'instance */
+
+ parent = G_ARM_INSTRUCTION(instr);
+
+ if (parent->cached_keyword == NULL)
+ {
+ assert(instr->sid < AOP7_ENC_COUNT);
+
+ parent->cached_keyword = strdup(_armv7_keywords[instr->sid]);
+
+ if (parent->suffix != NULL)
+ parent->cached_keyword = stradd(parent->cached_keyword, parent->suffix);
+
+ }
+
+ result = parent->cached_keyword;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction quelconque à traiter. *
+* type = type de procédure à utiliser. *
+* proc = représentation de l'architecture utilisée. *
+* context = contexte associé à la phase de désassemblage. *
+* format = accès aux données du binaire d'origine. *
+* *
+* Description : Complète un désassemblage accompli pour une instruction. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_instruction_call_hook(GArmV7Instruction *instr, InstrProcessHook type, GArchProcessor *proc, GProcContext *context, GExeFormat *format)
+{
+ instr_hook_fc hook; /* Décrochage à appeler */
+
+ assert(type < IPH_COUNT);
+
+ assert(instr->sid < AOP7_ENC_COUNT);
+
+ hook = _armv7_hooks[instr->sid][type];
+
+ if (hook != NULL)
+ hook(G_ARCH_INSTRUCTION(instr), proc, context, format);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : instr = instruction Dalvik à consulter. *
* *
* Description : Construit un petit résumé concis de l'instruction. *