summaryrefslogtreecommitdiff
path: root/src/arch/arm/v7/operands
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-05-22 15:43:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-05-22 15:43:43 (GMT)
commit7577eadd4e871d467f747c4927a1b1984d6a7606 (patch)
treee72a2fd5c1619e60402a678b0559079ed267eab0 /src/arch/arm/v7/operands
parent33aa90b022e7d711a733ca7eb62c0b285f974317 (diff)
Extended the compiler to transform all the new ARMv7 encoding definitions.
Diffstat (limited to 'src/arch/arm/v7/operands')
-rw-r--r--src/arch/arm/v7/operands/Makefile.am3
-rw-r--r--src/arch/arm/v7/operands/coproc.c221
-rw-r--r--src/arch/arm/v7/operands/coproc.h61
-rw-r--r--src/arch/arm/v7/operands/estate.c219
-rw-r--r--src/arch/arm/v7/operands/estate.h61
-rw-r--r--src/arch/arm/v7/operands/limitation.c258
-rw-r--r--src/arch/arm/v7/operands/limitation.h77
-rw-r--r--src/arch/arm/v7/operands/maccess.c46
-rw-r--r--src/arch/arm/v7/operands/maccess.h5
9 files changed, 943 insertions, 8 deletions
diff --git a/src/arch/arm/v7/operands/Makefile.am b/src/arch/arm/v7/operands/Makefile.am
index a33e175..8cf73b8 100644
--- a/src/arch/arm/v7/operands/Makefile.am
+++ b/src/arch/arm/v7/operands/Makefile.am
@@ -2,6 +2,9 @@
noinst_LTLIBRARIES = libarcharmv7operands.la
libarcharmv7operands_la_SOURCES = \
+ coproc.h coproc.c \
+ estate.h estate.c \
+ limitation.h limitation.c \
maccess.h maccess.c \
offset.h offset.c \
reglist.h reglist.c \
diff --git a/src/arch/arm/v7/operands/coproc.c b/src/arch/arm/v7/operands/coproc.c
new file mode 100644
index 0000000..c816b37
--- /dev/null
+++ b/src/arch/arm/v7/operands/coproc.c
@@ -0,0 +1,221 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * coproc.c - décallages de valeurs
+ *
+ * Copyright (C) 2016 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 "coproc.h"
+
+
+#include "../../../operand-int.h"
+
+
+
+/* Définition d'un opérande représentant un co-processeur (instance) */
+struct _GArmV7CoprocOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ uint8_t index; /* Indice du co-processeur */
+
+};
+
+
+/* Définition d'un opérande représentant un co-processeur (classe) */
+struct _GArmV7CoprocOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des coprocs de domaine et d'accès. */
+static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *);
+
+/* Initialise une instance de coproc de domaine et d'accès. */
+static void g_armv7_coproc_operand_init(GArmV7CoprocOperand *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini par la GLib pour un co-processeur ARM. */
+G_DEFINE_TYPE(GArmV7CoprocOperand, g_armv7_coproc_operand, G_TYPE_ARCH_OPERAND);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des co-processeurs ARM. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GArchOperandClass *operand; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+ operand = G_ARCH_OPERAND_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_coproc_operand_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_armv7_coproc_operand_finalize;
+
+ operand->print = (operand_print_fc)g_armv7_coproc_operand_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise une instance de co-processeur ARM. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_coproc_operand_init(GArmV7CoprocOperand *operand)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_coproc_operand_parent_class)->dispose(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_coproc_operand_parent_class)->finalize(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : raw = valeur brute du co-processeur à considérer. *
+* *
+* Description : Crée une représentation d'un co-processeur ARM. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_coproc_operand_new(uint8_t raw)
+{
+ GArmV7CoprocOperand *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_COPROC_OPERAND, NULL);
+
+ result->index = raw;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* line = ligne tampon où imprimer l'opérande donné. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Traduit un opérande en version humainement lisible. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ char name[5]; /* Mot clef principal */
+ size_t nlen; /* Taille de ce mot clef */
+
+ nlen = snprintf(name, sizeof(name), "p%hhu", operand->index);
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, name, nlen, RTT_REGISTER);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Fournit l'indice d'un co-processeur ARM. *
+* *
+* Retour : Inditifiant représentant le co-processeur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *operand)
+{
+ return operand->index;
+
+}
diff --git a/src/arch/arm/v7/operands/coproc.h b/src/arch/arm/v7/operands/coproc.h
new file mode 100644
index 0000000..4920cef
--- /dev/null
+++ b/src/arch/arm/v7/operands/coproc.h
@@ -0,0 +1,61 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * coproc.h - prototypes pour les décallages de valeurs
+ *
+ * Copyright (C) 2016 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_OPERANDS_COPROC_H
+#define _ARCH_ARM_V7_OPERANDS_COPROC_H
+
+
+#include <glib-object.h>
+
+
+#include "../../../operand.h"
+
+
+
+#define G_TYPE_ARMV7_COPROC_OPERAND g_armv7_coproc_operand_get_type()
+#define G_ARMV7_COPROC_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_coproc_operand_get_type(), GArmV7CoprocOperand))
+#define G_IS_ARMV7_COPROC_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_coproc_operand_get_type()))
+#define G_ARMV7_COPROC_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_COPROC_OPERAND, GArmV7CoprocOperandClass))
+#define G_IS_ARMV7_COPROC_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_COPROC_OPERAND))
+#define G_ARMV7_COPROC_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_COPROC_OPERAND, GArmV7CoprocOperandClass))
+
+
+/* Définition d'un opérande représentant un co-processeur (instance) */
+typedef struct _GArmV7CoprocOperand GArmV7CoprocOperand;
+
+/* Définition d'un opérande représentant un co-processeur (classe) */
+typedef struct _GArmV7CoprocOperandClass GArmV7CoprocOperandClass;
+
+
+/* Indique le type défini par la GLib pour un co-processeur ARM. */
+GType g_armv7_coproc_operand_get_type(void);
+
+/* Crée une représentation d'un co-processeur ARM. */
+GArchOperand *g_armv7_coproc_operand_new(uint8_t);
+
+/* Fournit l'indice d'un co-processeur ARM. */
+uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *);
+
+
+
+#endif /* _ARCH_ARM_V7_OPERANDS_COPROC_H */
diff --git a/src/arch/arm/v7/operands/estate.c b/src/arch/arm/v7/operands/estate.c
new file mode 100644
index 0000000..214508a
--- /dev/null
+++ b/src/arch/arm/v7/operands/estate.c
@@ -0,0 +1,219 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * endian.c - décallages de valeurs
+ *
+ * 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 "estate.h"
+
+
+#include "../../../operand-int.h"
+
+
+
+/* Définition d'un opérande affichant le choix d'un boutisme (instance) */
+struct _GArmV7EndianOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ bool big; /* Grand boutisme à afficher ? */
+
+};
+
+
+/* Définition d'un opérande affichant le choix d'un boutisme (classe) */
+struct _GArmV7EndianOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des affichages de boutisme. */
+static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *);
+
+/* Initialise une instance d'affichage de boutisme. */
+static void g_armv7_endian_operand_init(GArmV7EndianOperand *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_endian_operand_print(const GArmV7EndianOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini par la GLib pour une endian de domaine et d'accès. */
+G_DEFINE_TYPE(GArmV7EndianOperand, g_armv7_endian_operand, G_TYPE_ARCH_OPERAND);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des affichages de boutisme. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GArchOperandClass *operand; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+ operand = G_ARCH_OPERAND_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_endian_operand_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_armv7_endian_operand_finalize;
+
+ operand->print = (operand_print_fc)g_armv7_endian_operand_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise une instance d'affichage de boutisme. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_endian_operand_init(GArmV7EndianOperand *operand)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_endian_operand_parent_class)->dispose(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_endian_operand_parent_class)->finalize(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : big = indication sur le boutisme à représenter. *
+* *
+* Description : Crée une représentation de boutisme ARMv7. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_endian_operand_new(bool big)
+{
+ GArmV7EndianOperand *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_ENDIAN_OPERAND, NULL);
+
+ result->big = big;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* line = ligne tampon où imprimer l'opérande donné. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Traduit un opérande en version humainement lisible. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_endian_operand_print(const GArmV7EndianOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ if (operand->big)
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "BE", 2, RTT_KEY_WORD);
+ else
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "LE", 2, RTT_KEY_WORD);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Indique le type de boutisme représenté. *
+* *
+* Retour : Type de boutisme. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *operand)
+{
+ return operand->big;
+
+}
diff --git a/src/arch/arm/v7/operands/estate.h b/src/arch/arm/v7/operands/estate.h
new file mode 100644
index 0000000..903c1ab
--- /dev/null
+++ b/src/arch/arm/v7/operands/estate.h
@@ -0,0 +1,61 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * estate.h - prototypes pour le basculement de boutisme
+ *
+ * Copyright (C) 2016 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_OPERANDS_ESTATE_H
+#define _ARCH_ARM_V7_OPERANDS_ESTATE_H
+
+
+#include <glib-object.h>
+
+
+#include "../../../operand.h"
+
+
+
+#define G_TYPE_ARMV7_ENDIAN_OPERAND g_armv7_endian_operand_get_type()
+#define G_ARMV7_ENDIAN_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_endian_operand_get_type(), GArmV7EndianOperand))
+#define G_IS_ARMV7_ENDIAN_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_endian_operand_get_type()))
+#define G_ARMV7_ENDIAN_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_ENDIAN_OPERAND, GArmV7EndianOperandClass))
+#define G_IS_ARMV7_ENDIAN_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_ENDIAN_OPERAND))
+#define G_ARMV7_ENDIAN_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_ENDIAN_OPERAND, GArmV7EndianOperandClass))
+
+
+/* Définition d'un opérande affichant le choix d'un boutisme (instance) */
+typedef struct _GArmV7EndianOperand GArmV7EndianOperand;
+
+/* Définition d'un opérande affichant le choix d'un boutisme (classe) */
+typedef struct _GArmV7EndianOperandClass GArmV7EndianOperandClass;
+
+
+/* Indique le type défini par la GLib pour une endian de domaine et d'accès. */
+GType g_armv7_endian_operand_get_type(void);
+
+/* Crée une représentation de boutisme ARMv7. */
+GArchOperand *g_armv7_endian_operand_new(bool);
+
+/* Indique le type de boutisme représenté. */
+bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *);
+
+
+
+#endif /* _ARCH_ARM_V7_OPERANDS_ESTATE_H */
diff --git a/src/arch/arm/v7/operands/limitation.c b/src/arch/arm/v7/operands/limitation.c
new file mode 100644
index 0000000..4d1d661
--- /dev/null
+++ b/src/arch/arm/v7/operands/limitation.c
@@ -0,0 +1,258 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * limitation.c - décallages de valeurs
+ *
+ * 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 "limitation.h"
+
+
+#include "../../../operand-int.h"
+
+
+
+/* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */
+struct _GArmV7LimitationOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ BarrierLimitationType type; /* Type de limitation */
+
+};
+
+
+/* Définition d'un opérande déterminant une limitation de domaine et d'accès (classe) */
+struct _GArmV7LimitationOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des co-processeurs ARM. */
+static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *);
+
+/* Initialise une instance de co-processeur ARM. */
+static void g_armv7_limitation_operand_init(GArmV7LimitationOperand *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */
+G_DEFINE_TYPE(GArmV7LimitationOperand, g_armv7_limitation_operand, G_TYPE_ARCH_OPERAND);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des limitations de domaine et d'accès. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GArchOperandClass *operand; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+ operand = G_ARCH_OPERAND_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_limitation_operand_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_armv7_limitation_operand_finalize;
+
+ operand->print = (operand_print_fc)g_armv7_limitation_operand_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise une instance de limitation de domaine et d'accès. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_limitation_operand_init(GArmV7LimitationOperand *operand)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_limitation_operand_parent_class)->dispose(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_limitation_operand_parent_class)->finalize(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : raw = valeur brute de la limitation à considérer. *
+* *
+* Description : Crée une représentation d'une limitation pour barrière. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_limitation_operand_new(uint8_t raw)
+{
+ GArmV7LimitationOperand *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_LIMITATION_OPERAND, NULL);
+
+ if (raw < 0b0010 || raw > 0b1111)
+ result->type = BLT_RESERVED;
+
+ else
+ result->type = raw;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* line = ligne tampon où imprimer l'opérande donné. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Traduit un opérande en version humainement lisible. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ switch (operand->type)
+ {
+ case BLT_SY:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "SY", 2, RTT_KEY_WORD);
+ break;
+
+ case BLT_ST:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "ST", 2, RTT_KEY_WORD);
+ break;
+
+ case BLT_ISH:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "ISH", 3, RTT_KEY_WORD);
+ break;
+
+ case BLT_ISHST:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "ISHST", 5, RTT_KEY_WORD);
+ break;
+
+ case BLT_NSH:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "NSH", 3, RTT_KEY_WORD);
+ break;
+
+ case BLT_NSHST:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "NSHST", 5, RTT_KEY_WORD);
+ break;
+
+ case BLT_OSH:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "OSH", 3, RTT_KEY_WORD);
+ break;
+
+ case BLT_OSHST:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "OSHST", 5, RTT_KEY_WORD);
+ break;
+
+ default:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "(reserved)", 10, RTT_KEY_WORD);
+ break;
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Indique le type de limitation représentée. *
+* *
+* Retour : Type de limitation d'accès et de domaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7LimitationOperand *operand)
+{
+ return operand->type;
+
+}
diff --git a/src/arch/arm/v7/operands/limitation.h b/src/arch/arm/v7/operands/limitation.h
new file mode 100644
index 0000000..1b2bcca
--- /dev/null
+++ b/src/arch/arm/v7/operands/limitation.h
@@ -0,0 +1,77 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * limitation.h - prototypes pour les décallages de valeurs
+ *
+ * Copyright (C) 2016 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_OPERANDS_LIMITATION_H
+#define _ARCH_ARM_V7_OPERANDS_LIMITATION_H
+
+
+#include <glib-object.h>
+
+
+#include "../../../operand.h"
+
+
+
+#define G_TYPE_ARMV7_LIMITATION_OPERAND g_armv7_limitation_operand_get_type()
+#define G_ARMV7_LIMITATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_limitation_operand_get_type(), GArmV7LimitationOperand))
+#define G_IS_ARMV7_LIMITATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_limitation_operand_get_type()))
+#define G_ARMV7_LIMITATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_LIMITATION_OPERAND, GArmV7LimitationOperandClass))
+#define G_IS_ARMV7_LIMITATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_LIMITATION_OPERAND))
+#define G_ARMV7_LIMITATION_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_LIMITATION_OPERAND, GArmV7LimitationOperandClass))
+
+
+/* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */
+typedef struct _GArmV7LimitationOperand GArmV7LimitationOperand;
+
+/* Définition d'un opérande déterminant une limitation de domaine et d'accès (classe) */
+typedef struct _GArmV7LimitationOperandClass GArmV7LimitationOperandClass;
+
+
+/* Types de limitation domaine & accès */
+typedef enum _BarrierLimitationType
+{
+ BLT_RESERVED = 0,
+ BLT_SY = 0b1111,
+ BLT_ST = 0b1110,
+ BLT_ISH = 0b1011,
+ BLT_ISHST = 0b1010,
+ BLT_NSH = 0b0111,
+ BLT_NSHST = 0b0110,
+ BLT_OSH = 0b0011,
+ BLT_OSHST = 0b0010
+
+} BarrierLimitationType;
+
+
+/* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */
+GType g_armv7_limitation_operand_get_type(void);
+
+/* Crée une représentation d'une limitation pour barrière. */
+GArchOperand *g_armv7_limitation_operand_new(uint8_t);
+
+/* Indique le type de limitation représentée. */
+BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7LimitationOperand *);
+
+
+
+#endif /* _ARCH_ARM_V7_OPERANDS_LIMITATION_H */
diff --git a/src/arch/arm/v7/operands/maccess.c b/src/arch/arm/v7/operands/maccess.c
index 56ad0a3..e3e62fb 100644
--- a/src/arch/arm/v7/operands/maccess.c
+++ b/src/arch/arm/v7/operands/maccess.c
@@ -24,6 +24,9 @@
#include "maccess.h"
+#include <assert.h>
+
+
#include "../../../operand-int.h"
@@ -36,6 +39,7 @@ struct _GArmV7MAccessOperand
GArchOperand *base; /* Base de l'accès en mémoire */
GArchOperand *offset; /* Décallage pour l'adresse */
GArchOperand *shift; /* Décallage pour le décallage */
+ bool not_post_indexed; /* Positio du décallage */
bool write_back; /* Mise à jour de la base */
};
@@ -164,10 +168,11 @@ static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *operand)
/******************************************************************************
* *
-* Paramètres : base = représente le registre de la base d'accès. *
-* offset = détermine le décallage entre l'adresse et la base. *
-* shift = opération de décallage pour jouer sur le décallage. *
-* writeb = indique une mise à jour de la base après usage. *
+* Paramètres : base = représente le registre de la base d'accès. *
+* offset = détermine le décallage entre l'adresse et la base. *
+* shift = opération de décallage pour jouer sur le décallage.*
+* indexed = précise la forme donnée au décallage à appliquer. *
+* wback = indique une mise à jour de la base après usage. *
* *
* Description : Crée un accès à la mémoire depuis une base et un décallage. *
* *
@@ -177,7 +182,7 @@ static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *operand)
* *
******************************************************************************/
-GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool writeb)
+GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool indexed, bool wback)
{
GArmV7MAccessOperand *result; /* Structure à retourner */
@@ -186,7 +191,9 @@ GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offs
result->base = base;
result->offset = offset;
result->shift = shift;
- result->write_back = writeb;
+
+ result->not_post_indexed = indexed;
+ result->write_back = wback;
return G_ARCH_OPERAND(result);
@@ -213,6 +220,9 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, G
g_arch_operand_print(operand->base, line, syntax);
+ if (!operand->not_post_indexed)
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK);
+
if (operand->offset != NULL)
{
g_buffer_line_insert_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT);
@@ -224,6 +234,8 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, G
if (operand->shift != NULL)
{
+ assert(operand->not_post_indexed);
+
g_buffer_line_insert_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT);
g_buffer_line_insert_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW);
@@ -231,7 +243,8 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, G
}
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK);
+ if (operand->not_post_indexed)
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK);
if (operand->write_back)
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "!", 1, RTT_PUNCT);
@@ -300,6 +313,25 @@ GArchOperand *g_armv7_maccess_operand_get_shift(const GArmV7MAccessOperand *oper
* *
* Paramètres : operand = opérande à consulter. *
* *
+* Description : Indique si le décallage est post-indexé. *
+* *
+* Retour : Statut des opérations menées. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv7_maccess_operand_is_post_indexed(const GArmV7MAccessOperand *operand)
+{
+ return !operand->not_post_indexed;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
* Description : Indique si la base est mise à jour après usage. *
* *
* Retour : Statut des opérations menées. *
diff --git a/src/arch/arm/v7/operands/maccess.h b/src/arch/arm/v7/operands/maccess.h
index 8684891..3bfd30e 100644
--- a/src/arch/arm/v7/operands/maccess.h
+++ b/src/arch/arm/v7/operands/maccess.h
@@ -53,7 +53,7 @@ typedef struct _GArmV7MAccessOperandClass GArmV7MAccessOperandClass;
GType g_armv7_maccess_operand_get_type(void);
/* Crée un accès à la mémoire depuis une base et un décallage. */
-GArchOperand *g_armv7_maccess_operand_new(GArchOperand *, GArchOperand *, GArchOperand *, bool);
+GArchOperand *g_armv7_maccess_operand_new(GArchOperand *, GArchOperand *, GArchOperand *, bool, bool);
/* Founit la base d'un accès à la mémoire. */
GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *);
@@ -64,6 +64,9 @@ GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *);
/* Founit le décallage d'un décallage pour un accès mémoire. */
GArchOperand *g_armv7_maccess_operand_get_shift(const GArmV7MAccessOperand *);
+/* Indique si le décallage est post-indexé. */
+bool g_armv7_maccess_operand_is_post_indexed(const GArmV7MAccessOperand *);
+
/* Indique si la base est mise à jour après usage. */
bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *);