summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/operands/shift.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/v7/operands/shift.c')
-rw-r--r--plugins/arm/v7/operands/shift.c150
1 files changed, 120 insertions, 30 deletions
diff --git a/plugins/arm/v7/operands/shift.c b/plugins/arm/v7/operands/shift.c
index 8c00753..ee18cf0 100644
--- a/plugins/arm/v7/operands/shift.c
+++ b/plugins/arm/v7/operands/shift.c
@@ -24,13 +24,16 @@
#include "shift.h"
+#include <assert.h>
#include <stdio.h>
#include <string.h>
-#include <arch/operand-int.h>
#include <common/sort.h>
-#include <gtkext/gtkblockdisplay.h>
+#include <core/columns.h>
+
+
+#include "../operand-int.h"
@@ -50,7 +53,7 @@ typedef struct _a7shiftop_extra_data_t
/* Définition d'un opérande visant une opérande de décalage ARMv7 (instance) */
struct _GArmV7ShiftOperand
{
- GArchOperand parent; /* Instance parente */
+ GArmV7Operand parent; /* Instance parente */
GArchOperand *shift_value; /* Valeur du décalage */
@@ -60,7 +63,7 @@ struct _GArmV7ShiftOperand
/* Définition d'un opérande visant une opérande de décalage ARMv7 (classe) */
struct _GArmV7ShiftOperandClass
{
- GArchOperandClass parent; /* Classe parente */
+ GArmV7OperandClass parent; /* Classe parente */
};
@@ -69,9 +72,9 @@ struct _GArmV7ShiftOperandClass
* Accès aux informations éventuellement déportées.
*/
-#if __SIZEOF_INT__ == __SIZEOF_LONG__
+#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__
-# define GET_ARMV7_SHIFT_OP_EXTRA(op) (a7shiftop_extra_data_t *)&op->extra
+# define GET_ARMV7_SHIFT_OP_EXTRA(op) ((a7shiftop_extra_data_t *)&((GArchOperand *)op)->extra)
#else
@@ -109,6 +112,15 @@ static GArchOperand *g_armv7_shift_operand_get_inner_operand_from_path(const GAr
/* Traduit un opérande en version humainement lisible. */
static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *, GBufferLine *);
+/* Fournit une liste de candidats embarqués par un candidat. */
+static GArchOperand **g_armv7_shift_operand_list_inner_instances(const GArmV7ShiftOperand *, size_t *);
+
+/* Met à jour une liste de candidats embarqués par un candidat. */
+static void g_armv7_shift_operand_update_inner_instances(GArmV7ShiftOperand *, GArchOperand **, size_t);
+
+/* Fournit l'empreinte d'un candidat à une centralisation. */
+static guint g_armv7_shift_operand_hash(const GArmV7ShiftOperand *, bool);
+
/* Charge un contenu depuis une mémoire tampon. */
static bool g_armv7_shift_operand_load(GArmV7ShiftOperand *, GObjectStorage *, packed_buffer_t *);
@@ -123,7 +135,7 @@ static bool g_armv7_shift_operand_store(GArmV7ShiftOperand *, GObjectStorage *,
/* Indique le type défini par la GLib pour une opérande de décalage ARMv7. */
-G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARCH_OPERAND);
+G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARMV7_OPERAND);
/******************************************************************************
@@ -156,6 +168,10 @@ static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *klass)
operand->print = (operand_print_fc)g_armv7_shift_operand_print;
+ operand->list_inner = (operand_list_inners_fc)g_armv7_shift_operand_list_inner_instances;
+ operand->update_inner = (operand_update_inners_fc)g_armv7_shift_operand_update_inner_instances;
+ operand->hash = (operand_hash_fc)g_armv7_shift_operand_hash;
+
operand->load = (load_operand_fc)g_armv7_shift_operand_load;
operand->store = (store_operand_fc)g_armv7_shift_operand_store;
@@ -476,6 +492,101 @@ static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *operand, GBuff
/******************************************************************************
* *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* count = quantité d'instances à l'unicité internes. *
+* *
+* Description : Fournit une liste de candidats embarqués par un candidat. *
+* *
+* Retour : Liste de candidats internes ou NULL si aucun. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GArchOperand **g_armv7_shift_operand_list_inner_instances(const GArmV7ShiftOperand *operand, size_t *count)
+{
+ GArchOperand **result; /* Instances à retourner */
+
+ *count = 1;
+
+ result = malloc(*count * sizeof(GArchOperand *));
+
+ result[0] = operand->shift_value;
+ g_object_ref(G_OBJECT(result[0]));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* instances = liste de candidats internes devenus singletons. *
+* count = quantité d'instances à l'unicité internes. *
+* *
+* Description : Met à jour une liste de candidats embarqués par un candidat. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_shift_operand_update_inner_instances(GArmV7ShiftOperand *operand, GArchOperand **instances, size_t count)
+{
+ assert(count == 1);
+
+ g_clear_object(&operand->shift_value);
+
+ operand->shift_value = instances[0];
+ g_object_ref(G_OBJECT(instances[0]));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* lock = précise le besoin en verrouillage. *
+* *
+* Description : Fournit l'empreinte d'un candidat à une centralisation. *
+* *
+* Retour : Empreinte de l'élément représenté. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static guint g_armv7_shift_operand_hash(const GArmV7ShiftOperand *operand, bool lock)
+{
+ guint result; /* Valeur à retourner */
+ a7shiftop_extra_data_t *extra; /* Données insérées à consulter*/
+ GArchOperandClass *class; /* Classe parente normalisée */
+ a7shiftop_extra_data_t *op_extra; /* Données internes à manipuler*/
+
+ extra = GET_ARMV7_SHIFT_OP_EXTRA(G_ARMV7_SHIFT_OPERAND(operand));
+
+ if (lock)
+ LOCK_GOBJECT_EXTRA(extra);
+
+ class = G_ARCH_OPERAND_CLASS(g_armv7_shift_operand_parent_class);
+ result = class->hash(G_ARCH_OPERAND(operand), false);
+
+ op_extra = GET_ARMV7_SHIFT_OP_EXTRA(operand);
+
+ result ^= op_extra->shift_type;
+
+ if (lock)
+ UNLOCK_GOBJECT_EXTRA(extra);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : operand = élément GLib à constuire. *
* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à lire. *
@@ -494,7 +605,6 @@ static bool g_armv7_shift_operand_load(GArmV7ShiftOperand *operand, GObjectStora
GArchOperandClass *parent; /* Classe parente à consulter */
a7shiftop_extra_data_t *extra; /* Données insérées à modifier */
uleb128_t value; /* Valeur ULEB128 à charger */
- GSerializableObject *shift_value; /* Valeur du décalage */
parent = G_ARCH_OPERAND_CLASS(g_armv7_shift_operand_parent_class);
@@ -504,27 +614,15 @@ static bool g_armv7_shift_operand_load(GArmV7ShiftOperand *operand, GObjectStora
{
extra = GET_ARMV7_SHIFT_OP_EXTRA(operand);
- LOCK_GOBJECT_EXTRA(extra);
-
result = unpack_uleb128(&value, pbuf);
if (result)
extra->shift_type = value;
- UNLOCK_GOBJECT_EXTRA(extra);
-
}
if (result)
- {
- shift_value = g_object_storage_unpack_object(storage, "operands", pbuf);
-
- result = (shift_value != NULL);
-
- if (result)
- operand->shift_value = G_ARCH_OPERAND(shift_value);
-
- }
+ result = _g_arch_operand_load_inner_instances(G_ARCH_OPERAND(operand), storage, pbuf, 1);
return result;
@@ -550,7 +648,6 @@ static bool g_armv7_shift_operand_store(GArmV7ShiftOperand *operand, GObjectStor
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
a7shiftop_extra_data_t *extra; /* Données insérées à modifier */
- GSerializableObject *shift_value; /* Valeur du décalage */
parent = G_ARCH_OPERAND_CLASS(g_armv7_shift_operand_parent_class);
@@ -560,19 +657,12 @@ static bool g_armv7_shift_operand_store(GArmV7ShiftOperand *operand, GObjectStor
{
extra = GET_ARMV7_SHIFT_OP_EXTRA(operand);
- LOCK_GOBJECT_EXTRA(extra);
-
result = pack_uleb128((uleb128_t []){ extra->shift_type }, pbuf);
- UNLOCK_GOBJECT_EXTRA(extra);
-
}
if (result)
- {
- shift_value = G_SERIALIZABLE_OBJECT(operand->shift_value);
- result = g_object_storage_pack_object(storage, "operands", shift_value, pbuf);
- }
+ result = _g_arch_operand_store_inner_instances(G_ARCH_OPERAND(operand), storage, pbuf, true);
return result;