summaryrefslogtreecommitdiff
path: root/src/arch/arm
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-10-01 20:44:39 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-10-01 20:44:39 (GMT)
commitada6b756efd6ca109f6c46aa4d3eb11c17ad6b84 (patch)
treeef182c00ffb3881f6537e96dfa07acb875ac0846 /src/arch/arm
parent15c0cc127f0f4551c88de6c0d46b7d38f4b3ed4b (diff)
Prepared the ground for the ARMv7 architecture.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@408 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm')
-rw-r--r--src/arch/arm/Makefile.am10
-rw-r--r--src/arch/arm/cond.h (renamed from src/arch/arm/encoding.h)20
-rw-r--r--src/arch/arm/instruction-int.h3
-rw-r--r--src/arch/arm/instruction.c101
-rw-r--r--src/arch/arm/instruction.h36
-rw-r--r--src/arch/arm/processor-int.h50
-rw-r--r--src/arch/arm/processor.c119
-rw-r--r--src/arch/arm/processor.h18
-rw-r--r--src/arch/arm/register-int.h56
-rw-r--r--src/arch/arm/register.c204
-rw-r--r--src/arch/arm/register.h56
-rw-r--r--src/arch/arm/v7/Makefile.am17
-rw-r--r--src/arch/arm/v7/instruction.c206
-rw-r--r--src/arch/arm/v7/instruction.h63
-rw-r--r--src/arch/arm/v7/processor.c173
-rw-r--r--src/arch/arm/v7/processor.h56
-rw-r--r--src/arch/arm/v7/register.c229
-rw-r--r--src/arch/arm/v7/register.h56
18 files changed, 1287 insertions, 186 deletions
diff --git a/src/arch/arm/Makefile.am b/src/arch/arm/Makefile.am
index c480a47..9bf0fe9 100644
--- a/src/arch/arm/Makefile.am
+++ b/src/arch/arm/Makefile.am
@@ -2,13 +2,15 @@
noinst_LTLIBRARIES = libarcharm.la
libarcharm_la_SOURCES = \
- encoding.h \
+ cond.h \
instruction-int.h \
instruction.h instruction.c \
- processor.h processor.c
+ processor.h processor.c \
+ register-int.h \
+ register.h register.c
libarcharm_la_LIBADD = \
- v456/libarcharmv456.la
+ v7/libarcharmv7.la
libarcharm_la_CFLAGS = $(AM_CFLAGS)
@@ -18,4 +20,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
-SUBDIRS = v456
+SUBDIRS = v7
diff --git a/src/arch/arm/encoding.h b/src/arch/arm/cond.h
index 733c6b2..942c243 100644
--- a/src/arch/arm/encoding.h
+++ b/src/arch/arm/cond.h
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * encoding.h - prototypes pour le décodage des instructions ARM
+ * encoding.h - prototypes pour le décodage des conditions d'exécution ARM
*
* Copyright (C) 2013 Cyrille Bagard
*
@@ -26,16 +26,17 @@
-
-
-
-
/**
+ * Les conditions d'exécutions sont partagées par les architectures ARM :
+ *
+ * ARMv7 Instruction Details
+ * § A8.3 Conditional execution
+ *
* ARMv8 Instruction Set Overview.
* § 4.3 Condition Codes.
+ *
*/
-
/* Liste des conditions possibles */
typedef enum _ArmCondCode
{
@@ -60,11 +61,4 @@ typedef enum _ArmCondCode
-#define INSTR_TO_COND(i) (((i) & 0xf0000000) >> 28)
-
-
-
-
-
-
#endif /* _ARCH_ARM_ENCODING_H */
diff --git a/src/arch/arm/instruction-int.h b/src/arch/arm/instruction-int.h
index 1189045..d87bcc4 100644
--- a/src/arch/arm/instruction-int.h
+++ b/src/arch/arm/instruction-int.h
@@ -25,6 +25,7 @@
#define _ARCH_ARM_INSTRUCTION_INT_H
+#include "instruction.h"
#include "../instruction-int.h"
@@ -34,6 +35,8 @@ struct _GArmInstruction
{
GArchInstruction parent; /* A laisser en premier */
+ ArmCondCode cond; /* Condition d'exécution */
+
};
/* Définition générique d'une instruction d'architecture ARM (classe) */
diff --git a/src/arch/arm/instruction.c b/src/arch/arm/instruction.c
index 77dd621..5ea3926 100644
--- a/src/arch/arm/instruction.c
+++ b/src/arch/arm/instruction.c
@@ -28,29 +28,29 @@
-
-
-/* Initialise la classe des instructions pour Arm. */
+/* Initialise la classe des instructions ARM. */
static void g_arm_instruction_class_init(GArmInstructionClass *);
-/* Initialise une instance d'opérande d'architecture Arm. */
+/* Initialise une instance de instruction ARM. */
static void g_arm_instruction_init(GArmInstruction *);
+/* Supprime toutes les références externes. */
+static void g_arm_instruction_dispose(GArmInstruction *);
+/* Procède à la libération totale de la mémoire. */
+static void g_arm_instruction_finalize(GArmInstruction *);
-
-/* Indique le type défini pour une instruction d'architecture Arm. */
-G_DEFINE_TYPE(GArmInstruction, g_arm_instruction, G_TYPE_ARCH_INSTRUCTION);
-
+/* Indique le type défini pour une représentation d'une instruction ARM. */
+G_DEFINE_TYPE(GArmInstruction, g_arm_instruction, G_TYPE_ARM_INSTRUCTION);
/******************************************************************************
* *
* Paramètres : klass = classe à initialiser. *
* *
-* Description : Initialise la classe des instructions pour ARM. *
+* Description : Initialise la classe des instructions ARM. *
* *
* Retour : - *
* *
@@ -60,6 +60,12 @@ G_DEFINE_TYPE(GArmInstruction, g_arm_instruction, G_TYPE_ARCH_INSTRUCTION);
static void g_arm_instruction_class_init(GArmInstructionClass *klass)
{
+ GObjectClass *object_class; /* Autre version de la classe */
+
+ object_class = G_OBJECT_CLASS(klass);
+
+ object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_instruction_dispose;
+ object_class->finalize = (GObjectFinalizeFunc)g_arm_instruction_finalize;
}
@@ -68,7 +74,7 @@ static void g_arm_instruction_class_init(GArmInstructionClass *klass)
* *
* Paramètres : instr = instance à initialiser. *
* *
-* Description : Initialise une instance d'instruction d'architecture ARM. *
+* Description : Initialise une instance d'instruction ARM. *
* *
* Retour : - *
* *
@@ -78,51 +84,82 @@ static void g_arm_instruction_class_init(GArmInstructionClass *klass)
static void g_arm_instruction_init(GArmInstruction *instr)
{
- GArchInstruction *parent; /* Instance parente */
- parent = G_ARCH_INSTRUCTION(instr);
+}
- /* ... TODO ! */
-}
+/******************************************************************************
+* *
+* Paramètres : instr = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+static void g_arm_instruction_dispose(GArmInstruction *instr)
+{
+ G_OBJECT_CLASS(g_arm_instruction_parent_class)->dispose(G_OBJECT(instr));
+}
-/* ---------------------------------------------------------------------------------- */
-/* AIDE A LA MISE EN PLACE D'INSTRUCTIONS */
-/* ---------------------------------------------------------------------------------- */
+/******************************************************************************
+* *
+* Paramètres : instr = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+static void g_arm_instruction_finalize(GArmInstruction *instr)
+{
+ G_OBJECT_CLASS(g_arm_instruction_parent_class)->finalize(G_OBJECT(instr));
+}
-#if 0
/******************************************************************************
* *
-* Paramètres : data = flux de données à analyser. *
-* pos = position courante dans ce flux. *
-* end = limite des données à analyser. *
+* Paramètres : instr = instruction ARM à mettre à jour. *
+* cond = condition d'exécution de l'instruction. *
* *
-* Description : Recherche l'identifiant de la prochaine instruction. *
+* Description : Définit les conditions d'exécution d'une instruction ARM. *
* *
-* Retour : Identifiant de la prochaine instruction à tenter de charger. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-ArmOpcodes arm_guess_next_instruction(const bin_t *data, off_t pos, off_t end)
+void g_armv7_instruction_set_cond(GArmInstruction *instr, ArmCondCode cond)
{
- ArmOpcodes result; /* Identifiant à retourner */
+ instr->cond = cond;
- result = (ArmOpcodes)data[pos];
+}
- /* Si l'instruction est marquée comme non utilisée... */
- if (_instructions[result].keyword == NULL)
- result = DOP_COUNT;
- return result;
+/******************************************************************************
+* *
+* Paramètres : instr = instruction ARM à consulter. *
+* *
+* Description : Indique les conditions d'exécution d'une instruction ARM. *
+* *
+* Retour : Condition d'exécution de l'instruction. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
-}
+ArmCondCode g_armv7_instruction_get_cond(const GArmInstruction *instr)
+{
+ return instr->cond;
-#endif
+}
diff --git a/src/arch/arm/instruction.h b/src/arch/arm/instruction.h
index 0725726..0736015 100644
--- a/src/arch/arm/instruction.h
+++ b/src/arch/arm/instruction.h
@@ -25,37 +25,37 @@
#define _ARCH_ARM_INSTRUCTION_H
-#include "../instruction.h"
+#include <glib-object.h>
+#include <stdint.h>
+#include "cond.h"
-#define G_TYPE_ARM_INSTRUCTION g_arm_instruction_get_type()
-#define G_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_instruction_get_type(), GArmInstruction))
-#define G_IS_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_instruction_get_type()))
-#define G_ARM_INSTRUCTION_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_arm_instruction_get_type(), GArmInstructionIface))
-/* Définition générique d'une instruction d'architecture ARM (instance) */
+#define G_TYPE_ARM_INSTRUCTION g_arm_instruction_get_type()
+#define G_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_instruction_get_type(), GArmInstruction))
+#define G_IS_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_instruction_get_type()))
+#define G_ARM_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_INSTRUCTION, GArmInstructionClass))
+#define G_IS_ARM_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_INSTRUCTION))
+#define G_ARM_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_INSTRUCTION, GArmInstructionClass))
+
+
+/* Définition d'une instruction d'architecture ARM (instance) */
typedef struct _GArmInstruction GArmInstruction;
-/* Définition générique d'une instruction d'architecture ARM (classe) */
+/* Définition d'une instruction d'architecture ARM (classe) */
typedef struct _GArmInstructionClass GArmInstructionClass;
-/* Indique le type défini pour une instruction d'architecture ARM. */
+/* Indique le type défini pour une représentation d'une instruction ARM. */
GType g_arm_instruction_get_type(void);
+/* Définit les conditions d'exécution d'une instruction ARM. */
+void g_armv7_instruction_set_cond(GArmInstruction *, ArmCondCode);
-
-/* --------------------- AIDE A LA MISE EN PLACE D'INSTRUCTIONS --------------------- */
-
-
-/* Recherche l'identifiant de la prochaine instruction. */
-//ArmOpcodes arm_guess_next_instruction(const bin_t *, off_t, off_t);
-
-
-
-/* ------------------------ AIDE A LA PHASE DE DECOMPILATION ------------------------ */
+/* Indique les conditions d'exécution d'une instruction ARM. */
+ArmCondCode g_armv7_instruction_get_cond(const GArmInstruction *);
diff --git a/src/arch/arm/processor-int.h b/src/arch/arm/processor-int.h
new file mode 100644
index 0000000..48f8151
--- /dev/null
+++ b/src/arch/arm/processor-int.h
@@ -0,0 +1,50 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * instruction-int.h - prototypes pour la définition générique interne des processeurs ARM
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_PROCESSOR_INT_H
+#define _ARCH_ARM_PROCESSOR_INT_H
+
+
+#include "processor.h"
+#include "../processor-int.h"
+
+
+
+/* Définition du processeur ARM (instance) */
+struct _GArmProcessor
+{
+ GArchProcessor parent; /* Instance parente */
+
+};
+
+
+/* Définition du processeur ARM (classe) */
+struct _GArmProcessorClass
+{
+ GArchProcessorClass parent; /* Classe parente */
+
+};
+
+
+
+#endif /* _ARCH_ARM_PROCESSOR_INT_H */
diff --git a/src/arch/arm/processor.c b/src/arch/arm/processor.c
index 4bd342f..2c676be 100644
--- a/src/arch/arm/processor.c
+++ b/src/arch/arm/processor.c
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* processor.c - manipulation du processeur ARM
*
- * Copyright (C) 2010-2013 Cyrille Bagard
+ * Copyright (C) 2014 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -24,32 +24,14 @@
#include "processor.h"
-//#include "instruction.h"
-//#include "opcodes.h"
-#include "../processor-int.h"
+#include "processor-int.h"
-/* Définition du processeur ARM (instance) */
-struct _GArmProcessor
-{
- GArchProcessor parent; /* Instance parente */
-
-};
-
-
-/* Définition du processeur ARM (classe) */
-struct _GArmProcessorClass
-{
- GArchProcessorClass parent; /* Classe parente */
-
-};
-
-
-/* Initialise la classe des processeurs ARM. */
+/* Initialise la classe des registres ARM. */
static void g_arm_processor_class_init(GArmProcessorClass *);
-/* Initialise une instance de processeur ARM. */
+/* Initialise une instance de registre ARM. */
static void g_arm_processor_init(GArmProcessor *);
/* Supprime toutes les références externes. */
@@ -58,15 +40,12 @@ static void g_arm_processor_dispose(GArmProcessor *);
/* Procède à la libération totale de la mémoire. */
static void g_arm_processor_finalize(GArmProcessor *);
-/* Décode une instruction dans un flux de données. */
-static GArchInstruction *g_arm_processor_decode_instruction(const GArmProcessor *, GProcContext *, const bin_t *, off_t *, off_t, vmpa_t, GBinFormat *);
/* Indique le type défini par la GLib pour le processeur ARM. */
G_DEFINE_TYPE(GArmProcessor, g_arm_processor, G_TYPE_ARCH_PROCESSOR);
-
/******************************************************************************
* *
* Paramètres : klass = classe à initialiser. *
@@ -81,17 +60,12 @@ G_DEFINE_TYPE(GArmProcessor, g_arm_processor, G_TYPE_ARCH_PROCESSOR);
static void g_arm_processor_class_init(GArmProcessorClass *klass)
{
- GObjectClass *object; /* Autre version de la classe */
- GArchProcessorClass *proc; /* Encore une autre vision... */
-
- object = G_OBJECT_CLASS(klass);
-
- object->dispose = (GObjectFinalizeFunc/* ! */)g_arm_processor_dispose;
- object->finalize = (GObjectFinalizeFunc)g_arm_processor_finalize;
+ GObjectClass *object_class; /* Autre version de la classe */
- proc = G_ARCH_PROCESSOR_CLASS(klass);
+ object_class = G_OBJECT_CLASS(klass);
- proc->decode = (decode_instruction_fc)g_arm_processor_decode_instruction;
+ object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_processor_dispose;
+ object_class->finalize = (GObjectFinalizeFunc)g_arm_processor_finalize;
}
@@ -110,13 +84,6 @@ static void g_arm_processor_class_init(GArmProcessorClass *klass)
static void g_arm_processor_init(GArmProcessor *proc)
{
- GArchProcessor *parent; /* Instance parente */
-
- parent = G_ARCH_PROCESSOR(proc);
-
- parent->endianness = SRE_LITTLE;
- parent->memsize = MDS_32_BITS;
- parent->inssize = MDS_32_BITS;
}
@@ -142,7 +109,7 @@ static void g_arm_processor_dispose(GArmProcessor *proc)
/******************************************************************************
* *
-* Paramètres : bookmark = instance d'objet GLib à traiter. *
+* Paramètres : proc = instance d'objet GLib à traiter. *
* *
* Description : Procède à la libération totale de la mémoire. *
* *
@@ -157,71 +124,3 @@ static void g_arm_processor_finalize(GArmProcessor *proc)
G_OBJECT_CLASS(g_arm_processor_parent_class)->finalize(G_OBJECT(proc));
}
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Crée le support de l'architecture ARM. *
-* *
-* Retour : Architecture mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GArchProcessor *g_arm_processor_new(void)
-{
- GArchProcessor *result; /* Structure à retourner */
-
- result = g_object_new(G_TYPE_ARM_PROCESSOR, NULL);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : proc = architecture visée par la procédure. *
-* ctx = contexte lié à l'exécution du processeur. *
-* data = flux de données à analyser. *
-* pos = position courante dans ce flux. [OUT] *
-* end = limite des données à analyser. *
-* addr = adresse virtuelle de l'instruction. *
-* format = format du fichier contenant le code. *
-* *
-* Description : Décode une instruction dans un flux de données. *
-* *
-* Retour : Instruction mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-#include "encoding.h"
-extern GArchInstruction *try_to_decode_arm_v456_instr(bin_t *);
-
-static GArchInstruction *g_arm_processor_decode_instruction(const GArmProcessor *proc, GProcContext *ctx, const bin_t *data, off_t *pos, off_t end, vmpa_t addr, GBinFormat *format)
-{
- GArchInstruction *result; /* Instruction à renvoyer */
-
-
- uint32_t *instr;
-
- if (data == NULL)
- return NULL;
-
-
- instr = (uint32_t *)(data + *pos);
-
-
- //printf("[0x%08x] cond=%x\n", *instr, INSTR_TO_COND(*instr));
-
- result = try_to_decode_arm_v456_instr(data + *pos);
-
- if (result != NULL) *pos += 4;
-
- return result;
-
-}
diff --git a/src/arch/arm/processor.h b/src/arch/arm/processor.h
index d98306c..425652d 100644
--- a/src/arch/arm/processor.h
+++ b/src/arch/arm/processor.h
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* processor.h - prototypes pour la manipulation du processeur ARM
*
- * Copyright (C) 2010 Cyrille Bagard
+ * Copyright (C) 2014 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -25,14 +25,17 @@
#define _ARCH_ARM_PROCESSOR_H
-#include "../processor.h"
+#include <glib-object.h>
+#include <stdint.h>
-#define G_TYPE_ARM_PROCESSOR g_arm_processor_get_type()
-#define G_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_processor_get_type(), GArmProcessor))
-#define G_IS_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_processor_get_type()))
-#define G_ARM_PROCESSOR_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_arm_processor_get_type(), GArmProcessorIface))
+#define G_TYPE_ARM_PROCESSOR g_arm_processor_get_type()
+#define G_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_processor_get_type(), GArmProcessor))
+#define G_IS_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_processor_get_type()))
+#define G_ARM_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_PROCESSOR, GArmProcessorClass))
+#define G_IS_ARM_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_PROCESSOR))
+#define G_ARM_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_PROCESSOR, GArmProcessorClass))
/* Définition du processeur ARM (instance) */
@@ -45,9 +48,6 @@ typedef struct _GArmProcessorClass GArmProcessorClass;
/* Indique le type défini par la GLib pour le processeur ARM. */
GType g_arm_processor_get_type(void);
-/* Crée le support de l'architecture ARM. */
-GArchProcessor *g_arm_processor_new(void);
-
#endif /* _ARCH_ARM_PROCESSOR_H */
diff --git a/src/arch/arm/register-int.h b/src/arch/arm/register-int.h
new file mode 100644
index 0000000..4ea0bc9
--- /dev/null
+++ b/src/arch/arm/register-int.h
@@ -0,0 +1,56 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * register-int.h - définitions internes pour la représentation d'un registre ARM
+ *
+ * Copyright (C) 2012-2013 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_REGISTER_INT_H
+#define _ARCH_ARM_REGISTER_INT_H
+
+
+
+#include "register.h"
+#include "../register-int.h"
+
+
+
+#define MAX_REGNAME_LEN 8
+
+
+/* Représentation d'un registre ARM (instance) */
+struct _GArmRegister
+{
+ GArchRegister parent; /* A laisser en premier */
+
+ uint8_t index; /* Indice du registre */
+
+};
+
+
+/* Représentation d'un registre ARM (classe) */
+struct _GArmRegisterClass
+{
+ GArchRegisterClass parent; /* A laisser en premier */
+
+};
+
+
+
+#endif /* _ARCH_ARM_REGISTER_INT_H */
diff --git a/src/arch/arm/register.c b/src/arch/arm/register.c
new file mode 100644
index 0000000..dd287ca
--- /dev/null
+++ b/src/arch/arm/register.c
@@ -0,0 +1,204 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * registers.c - aides auxiliaires relatives aux registres ARM
+ *
+ * Copyright (C) 2010-2013 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "register.h"
+
+
+#include "register-int.h"
+
+
+
+/* Initialise la classe des registres ARM. */
+static void g_arm_register_class_init(GArmRegisterClass *);
+
+/* Initialise une instance de registre ARM. */
+static void g_arm_register_init(GArmRegister *);
+
+/* Supprime toutes les références externes. */
+static void g_arm_register_dispose(GArmRegister *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_arm_register_finalize(GArmRegister *);
+
+/* Produit une empreinte à partir d'un registre. */
+static guint g_arm_register_hash(const GArmRegister *);
+
+/* Compare un registre avec un autre. */
+static int g_arm_register_compare(const GArmRegister *, const GArmRegister *);
+
+
+
+/* Indique le type défini pour une représentation d'un registre ARM. */
+G_DEFINE_TYPE(GArmRegister, g_arm_register, G_TYPE_ARCH_REGISTER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des registres Arm. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arm_register_class_init(GArmRegisterClass *klass)
+{
+ GObjectClass *object_class; /* Autre version de la classe */
+ GArchRegisterClass *register_class; /* Classe de haut niveau */
+
+ object_class = G_OBJECT_CLASS(klass);
+ register_class = G_ARCH_REGISTER_CLASS(klass);
+
+ object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_register_dispose;
+ object_class->finalize = (GObjectFinalizeFunc)g_arm_register_finalize;
+
+ register_class->hash = (reg_hash_fc)g_arm_register_hash;
+ register_class->compare = (reg_compare_fc)g_arm_register_compare;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = instance à initialiser. *
+* *
+* Description : Initialise une instance de registre ARM. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arm_register_init(GArmRegister *reg)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arm_register_dispose(GArmRegister *reg)
+{
+ G_OBJECT_CLASS(g_arm_register_parent_class)->dispose(G_OBJECT(reg));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arm_register_finalize(GArmRegister *reg)
+{
+ G_OBJECT_CLASS(g_arm_register_parent_class)->finalize(G_OBJECT(reg));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = registre à consulter. *
+* *
+* Description : Fournit l'indice d'un registre ARM. *
+* *
+* Retour : Inditifiant représentant le registre. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint8_t g_arm_register_get_index(const GArmRegister *reg)
+{
+ return reg->index;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = opérande à consulter pour le calcul. *
+* *
+* Description : Produit une empreinte à partir d'un registre. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static guint g_arm_register_hash(const GArmRegister *reg)
+{
+ return reg->index;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* *
+* Description : Compare un registre avec un autre. *
+* *
+* Retour : Bilan de la comparaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int g_arm_register_compare(const GArmRegister *a, const GArmRegister *b)
+{
+ int result; /* Bilan à retourner */
+
+ if (a->index < b->index)
+ result = -1;
+ else if (a->index > b->index)
+ result = 1;
+ else
+ result = 0;
+
+ return result;
+
+}
diff --git a/src/arch/arm/register.h b/src/arch/arm/register.h
new file mode 100644
index 0000000..0c24d21
--- /dev/null
+++ b/src/arch/arm/register.h
@@ -0,0 +1,56 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * registers.h - prototypes pour les aides auxiliaires relatives aux registres ARM
+ *
+ * Copyright (C) 2010-2012 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_REGISTER_H
+#define _ARCH_ARM_REGISTER_H
+
+
+#include <glib-object.h>
+#include <stdint.h>
+
+
+
+#define G_TYPE_ARM_REGISTER g_arm_register_get_type()
+#define G_ARM_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_register_get_type(), GArmRegister))
+#define G_IS_ARM_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_register_get_type()))
+#define G_ARM_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_REGISTER, GArmRegisterClass))
+#define G_IS_ARM_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_REGISTER))
+#define G_ARM_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_REGISTER, GArmRegisterClass))
+
+
+/* Représentation d'un registre ARM (instance) */
+typedef struct _GArmRegister GArmRegister;
+
+/* Représentation d'un registre ARM (classe) */
+typedef struct _GArmRegisterClass GArmRegisterClass;
+
+
+/* Indique le type défini pour une représentation d'un registre ARM. */
+GType g_arm_register_get_type(void);
+
+/* Fournit l'indice d'un registre ARM. */
+uint8_t g_arm_register_get_index(const GArmRegister *);
+
+
+
+#endif /* _ARCH_ARM_REGISTER_H */
diff --git a/src/arch/arm/v7/Makefile.am b/src/arch/arm/v7/Makefile.am
new file mode 100644
index 0000000..1ac1c76
--- /dev/null
+++ b/src/arch/arm/v7/Makefile.am
@@ -0,0 +1,17 @@
+
+noinst_LTLIBRARIES = libarcharmv7.la
+
+libarcharmv7_la_SOURCES = \
+ instruction.h instruction.c \
+ processor.h processor.c \
+ register.h register.c
+
+libarcharmv7_la_CFLAGS = $(AM_CFLAGS)
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+
+SUBDIRS = #opdefs
diff --git a/src/arch/arm/v7/instruction.c b/src/arch/arm/v7/instruction.c
new file mode 100644
index 0000000..0fc95c9
--- /dev/null
+++ b/src/arch/arm/v7/instruction.c
@@ -0,0 +1,206 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * instruction.c - gestion des instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "instruction.h"
+
+
+#include "../instruction-int.h"
+
+
+
+/* Définition d'une instruction d'architecture ARMv7 (instance) */
+struct _GArmV7Instruction
+{
+ GArmInstruction parent; /* Instance parente */
+
+ bool setflags; /* Mise à jour des drapeaux */
+
+};
+
+
+/* Définition d'une instruction d'architecture ARMv7 (classe) */
+struct _GArmV7InstructionClass
+{
+ GArmInstructionClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des instructions ARMv7. */
+static void g_armv7_instruction_class_init(GArmV7InstructionClass *);
+
+/* Initialise une instance d'instruction ARMv7. */
+static void g_armv7_instruction_init(GArmV7Instruction *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_instruction_dispose(GArmV7Instruction *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_instruction_finalize(GArmV7Instruction *);
+
+
+
+/* Indique le type défini pour une représentation d'une instruction ARMv7. */
+G_DEFINE_TYPE(GArmV7Instruction, g_armv7_instruction, G_TYPE_ARM_INSTRUCTION);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des instructions ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass)
+{
+ GObjectClass *object_class; /* Autre version de la classe */
+
+ object_class = G_OBJECT_CLASS(klass);
+
+ object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_instruction_dispose;
+ object_class->finalize = (GObjectFinalizeFunc)g_armv7_instruction_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instance à initialiser. *
+* *
+* Description : Initialise une instance d'instruction ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_instruction_init(GArmV7Instruction *instr)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_instruction_dispose(GArmV7Instruction *instr)
+{
+ G_OBJECT_CLASS(g_armv7_instruction_parent_class)->dispose(G_OBJECT(instr));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_instruction_finalize(GArmV7Instruction *instr)
+{
+ G_OBJECT_CLASS(g_armv7_instruction_parent_class)->finalize(G_OBJECT(instr));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Crée une instruction pour l'architecture ARMv7. *
+* *
+* Retour : Adresse de la structure mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArmV7Instruction *g_armv7_instruction_new(void)
+{
+ GArmV7Instruction *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_INSTRUCTION, NULL);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction ARMv7 à mettre à jour. *
+* set = statut à enregistrer. *
+* *
+* Description : Définit si une instruction ARMv7 met à jour les drapeaux. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_armv7_instruction_define_setflags(GArmV7Instruction *instr, bool set)
+{
+ instr->setflags = set;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction ARMv7 à consulter. *
+* *
+* Description : Indique si une instruction ARMv7 met à jour les drapeaux. *
+* *
+* Retour : Statut des incidences de l'instruction. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv7_instruction_get_setflags(const GArmV7Instruction *instr)
+{
+ return instr->setflags;
+
+}
diff --git a/src/arch/arm/v7/instruction.h b/src/arch/arm/v7/instruction.h
new file mode 100644
index 0000000..0265911
--- /dev/null
+++ b/src/arch/arm/v7/instruction.h
@@ -0,0 +1,63 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * instruction.h - prototypes pour la gestion des instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_V7_INSTRUCTION_H
+#define _ARCH_ARM_V7_INSTRUCTION_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+
+
+#define G_TYPE_ARMV7_INSTRUCTION g_armv7_instruction_get_type()
+#define G_ARMV7_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_instruction_get_type(), GArmV7Instruction))
+#define G_IS_ARMV7_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_instruction_get_type()))
+#define G_ARMV7_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_INSTRUCTION, GArmV7InstructionClass))
+#define G_IS_ARMV7_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_INSTRUCTION))
+#define G_ARMV7_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_INSTRUCTION, GArmV7InstructionClass))
+
+
+/* Définition d'une instruction d'architecture ARMv7 (instance) */
+typedef struct _GArmV7Instruction GArmV7Instruction;
+
+/* Définition d'une instruction d'architecture ARMv7 (classe) */
+typedef struct _GArmV7InstructionClass GArmV7InstructionClass;
+
+
+/* Indique le type défini pour une représentation d'une instruction ARMv7. */
+GType g_armv7_instruction_get_type(void);
+
+/* Crée une instruction pour l'architecture ARMv7. */
+GArmV7Instruction *g_armv7_instruction_new(void);
+
+/* Définit si une instruction ARMv7 met à jour les drapeaux. */
+void g_armv7_instruction_define_setflags(GArmV7Instruction *, bool);
+
+/* Indique si une instruction ARMv7 met à jour les drapeaux. */
+bool g_armv7_instruction_get_setflags(const GArmV7Instruction *);
+
+
+
+#endif /* _ARCH_ARM_V7_INSTRUCTION_H */
diff --git a/src/arch/arm/v7/processor.c b/src/arch/arm/v7/processor.c
new file mode 100644
index 0000000..bcd44e9
--- /dev/null
+++ b/src/arch/arm/v7/processor.c
@@ -0,0 +1,173 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * processor.c - manipulation du processeur ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "processor.h"
+
+
+#include "../processor-int.h"
+
+
+
+/* Définition du processeur ARMv7 (instance) */
+struct _GArmV7Processor
+{
+ GArmProcessor parent; /* Instance parente */
+
+};
+
+
+/* Définition du processeur ARMv7 (classe) */
+struct _GArmV7ProcessorClass
+{
+ GArmProcessorClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des registres ARMv7. */
+static void g_armv7_processor_class_init(GArmV7ProcessorClass *);
+
+/* Initialise une instance de registre ARMv7. */
+static void g_armv7_processor_init(GArmV7Processor *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_processor_dispose(GArmV7Processor *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_processor_finalize(GArmV7Processor *);
+
+
+
+/* Indique le type défini par la GLib pour le processeur ARMv7. */
+G_DEFINE_TYPE(GArmV7Processor, g_armv7_processor, G_TYPE_ARM_PROCESSOR);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des processeurs ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_processor_class_init(GArmV7ProcessorClass *klass)
+{
+ GObjectClass *object_class; /* Autre version de la classe */
+
+ object_class = G_OBJECT_CLASS(klass);
+
+ object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_processor_dispose;
+ object_class->finalize = (GObjectFinalizeFunc)g_armv7_processor_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : proc = instance à initialiser. *
+* *
+* Description : Initialise une instance de processeur ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_processor_init(GArmV7Processor *proc)
+{
+
+ GArchProcessor *parent; /* Instance parente */
+
+ parent = G_ARCH_PROCESSOR(proc);
+
+ parent->endianness = SRE_LITTLE;
+ parent->memsize = MDS_32_BITS;
+ parent->inssize = MDS_32_BITS;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : proc = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_processor_dispose(GArmV7Processor *proc)
+{
+ G_OBJECT_CLASS(g_armv7_processor_parent_class)->dispose(G_OBJECT(proc));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : proc = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_processor_finalize(GArmV7Processor *proc)
+{
+ G_OBJECT_CLASS(g_armv7_processor_parent_class)->finalize(G_OBJECT(proc));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Crée le support de l'architecture ARMv7. *
+* *
+* Retour : Adresse de la structure mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArmV7Processor *g_armv7_processor_new(void)
+{
+ GArmV7Processor *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_PROCESSOR, NULL);
+
+ return result;
+
+}
diff --git a/src/arch/arm/v7/processor.h b/src/arch/arm/v7/processor.h
new file mode 100644
index 0000000..0361c55
--- /dev/null
+++ b/src/arch/arm/v7/processor.h
@@ -0,0 +1,56 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * processor.h - prototypes pour la manipulation du processeur ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_V7_PROCESSOR_H
+#define _ARCH_ARM_V7_PROCESSOR_H
+
+
+#include <glib-object.h>
+#include <stdint.h>
+
+
+
+#define G_TYPE_ARMV7_PROCESSOR g_armv7_processor_get_type()
+#define G_ARMV7_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_processor_get_type(), GArmV7Processor))
+#define G_IS_ARMV7_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_processor_get_type()))
+#define G_ARMV7_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_PROCESSOR, GArmV7ProcessorClass))
+#define G_IS_ARMV7_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_PROCESSOR))
+#define G_ARMV7_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_PROCESSOR, GArmV7ProcessorClass))
+
+
+/* Définition du processeur ARMv7 (instance) */
+typedef struct _GArmV7Processor GArmV7Processor;
+
+/* Définition du processeur ARMv7 (classe) */
+typedef struct _GArmV7ProcessorClass GArmV7ProcessorClass;
+
+
+/* Indique le type défini par la GLib pour le processeur ARMv7. */
+GType g_armv7_processor_get_type(void);
+
+/* Crée le support de l'architecture ARMv7. */
+GArmV7Processor *g_armv7_processor_new(void);
+
+
+
+#endif /* _ARCH_ARM_V7_PROCESSOR_H */
diff --git a/src/arch/arm/v7/register.c b/src/arch/arm/v7/register.c
new file mode 100644
index 0000000..f9bb731
--- /dev/null
+++ b/src/arch/arm/v7/register.c
@@ -0,0 +1,229 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * registers.c - aides auxiliaires relatives aux registres ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "register.h"
+
+
+#include <stdio.h>
+
+
+#include "../register-int.h"
+
+
+
+/* Représentation d'un registre ARMv7 (instance) */
+struct _GArmV7Register
+{
+ GArmRegister parent; /* Instance parente */
+
+};
+
+
+/* Représentation d'un registre ARMv7 (classe) */
+struct _GArmV7RegisterClass
+{
+ GArmRegisterClass parent; /* Classe parente */
+
+};
+
+
+#define MAX_REGNAME_LEN 8
+
+
+/* Initialise la classe des registres ARMv7. */
+static void g_armv7_register_class_init(GArmV7RegisterClass *);
+
+/* Initialise une instance de registre ARMv7. */
+static void g_armv7_register_init(GArmV7Register *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_register_dispose(GArmV7Register *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_register_finalize(GArmV7Register *);
+
+/* Traduit un registre en version humainement lisible. */
+static void g_armv7_register_print(const GArmV7Register *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini pour une représentation d'un registre ARMv7. */
+G_DEFINE_TYPE(GArmV7Register, g_armv7_register, G_TYPE_ARM_REGISTER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des registres ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_register_class_init(GArmV7RegisterClass *klass)
+{
+ GObjectClass *object_class; /* Autre version de la classe */
+ GArchRegisterClass *reg_class; /* Classe de haut niveau */
+
+ object_class = G_OBJECT_CLASS(klass);
+ reg_class = G_ARCH_REGISTER_CLASS(klass);
+
+ object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_register_dispose;
+ object_class->finalize = (GObjectFinalizeFunc)g_armv7_register_finalize;
+
+ reg_class->print = (reg_print_fc)g_armv7_register_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = instance à initialiser. *
+* *
+* Description : Initialise une instance de registre ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_register_init(GArmV7Register *reg)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_register_dispose(GArmV7Register *reg)
+{
+ G_OBJECT_CLASS(g_armv7_register_parent_class)->dispose(G_OBJECT(reg));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_register_finalize(GArmV7Register *reg)
+{
+ G_OBJECT_CLASS(g_armv7_register_parent_class)->finalize(G_OBJECT(reg));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : index = indice du registre correspondant. *
+* *
+* Description : Crée une réprésentation de registre ARMv7. *
+* *
+* Retour : Adresse de la structure mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArmV7Register *g_armv7_register_new(uint8_t index)
+{
+ GArmV7Register *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_REGISTER, NULL);
+
+ G_ARM_REGISTER(result)->index = index;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = registre à transcrire. *
+* line = ligne tampon où imprimer l'opérande donné. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Traduit un registre en version humainement lisible. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_register_print(const GArmV7Register *reg, GBufferLine *line, AsmSyntax syntax)
+{
+ char key[MAX_REGNAME_LEN]; /* Mot clef principal */
+ size_t klen; /* Taille de ce mot clef */
+
+ switch (G_ARM_REGISTER(reg)->index)
+ {
+ case 0 ... 12:
+ klen = snprintf(key, MAX_REGNAME_LEN, "r%hhu", G_ARM_REGISTER(reg)->index);
+ break;
+ case 13:
+ klen = snprintf(key, MAX_REGNAME_LEN, "sp");
+ break;
+ case 14:
+ klen = snprintf(key, MAX_REGNAME_LEN, "lr");
+ break;
+ case 15:
+ klen = snprintf(key, MAX_REGNAME_LEN, "pc");
+ break;
+ case 16:
+ klen = snprintf(key, MAX_REGNAME_LEN, "cpsr");
+ break;
+ case 17:
+ klen = snprintf(key, MAX_REGNAME_LEN, "spsr");
+ break;
+ default:
+ klen = snprintf(key, MAX_REGNAME_LEN, "r??");
+ break;
+ }
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER);
+
+}
diff --git a/src/arch/arm/v7/register.h b/src/arch/arm/v7/register.h
new file mode 100644
index 0000000..ab71995
--- /dev/null
+++ b/src/arch/arm/v7/register.h
@@ -0,0 +1,56 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * registers.h - prototypes pour les aides auxiliaires relatives aux registres ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_V7_REGISTER_H
+#define _ARCH_ARM_V7_REGISTER_H
+
+
+#include <glib-object.h>
+#include <stdint.h>
+
+
+
+#define G_TYPE_ARMV7_REGISTER g_armv7_register_get_type()
+#define G_ARMV7_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_register_get_type(), GArmV7Register))
+#define G_IS_ARMV7_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_register_get_type()))
+#define G_ARMV7_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_REGISTER, GArmV7RegisterClass))
+#define G_IS_ARMV7_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_REGISTER))
+#define G_ARMV7_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_REGISTER, GArmV7RegisterClass))
+
+
+/* Représentation d'un registre ARMv7 (instance) */
+typedef struct _GArmV7Register GArmV7Register;
+
+/* Représentation d'un registre ARMv7 (classe) */
+typedef struct _GArmV7RegisterClass GArmV7RegisterClass;
+
+
+/* Indique le type défini pour une représentation d'un registre ARMv7. */
+GType g_armv7_register_get_type(void);
+
+/* Crée une réprésentation de registre ARMv7. */
+GArmV7Register *g_armv7_register_new(uint8_t);
+
+
+
+#endif /* _ARCH_ARM_V7_REGISTER_H */