summaryrefslogtreecommitdiff
path: root/plugins/arm
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm')
-rw-r--r--plugins/arm/v7/operands/limitation.c8
-rw-r--r--plugins/arm/v7/operands/maccess.c127
-rw-r--r--plugins/arm/v7/operands/offset.c76
-rw-r--r--plugins/arm/v7/operands/rotation.c89
-rw-r--r--plugins/arm/v7/operands/shift.c29
5 files changed, 46 insertions, 283 deletions
diff --git a/plugins/arm/v7/operands/limitation.c b/plugins/arm/v7/operands/limitation.c
index b3c6d07..f2e8373 100644
--- a/plugins/arm/v7/operands/limitation.c
+++ b/plugins/arm/v7/operands/limitation.c
@@ -456,15 +456,11 @@ static bool g_armv7_limitation_operand_load(GArmV7LimitationOperand *operand, GO
{
extra = GET_ARMV7_LIMITATION_OP_EXTRA(operand);
- LOCK_GOBJECT_EXTRA(extra);
-
result = unpack_uleb128(&value, pbuf);
if (result)
extra->type = value;
- UNLOCK_GOBJECT_EXTRA(extra);
-
}
return result;
@@ -500,12 +496,8 @@ static bool g_armv7_limitation_operand_store(GArmV7LimitationOperand *operand, G
{
extra = GET_ARMV7_LIMITATION_OP_EXTRA(operand);
- LOCK_GOBJECT_EXTRA(extra);
-
result = pack_uleb128((uleb128_t []){ extra->type }, pbuf);
- UNLOCK_GOBJECT_EXTRA(extra);
-
}
return result;
diff --git a/plugins/arm/v7/operands/maccess.c b/plugins/arm/v7/operands/maccess.c
index 3eb3116..d503b12 100644
--- a/plugins/arm/v7/operands/maccess.c
+++ b/plugins/arm/v7/operands/maccess.c
@@ -99,12 +99,6 @@ static void g_armv7_maccess_operand_update_inner_instances(GArmV7MAccessOperand
/* Fournit l'empreinte d'un candidat à une centralisation. */
static guint g_armv7_maccess_operand_hash(const GArmV7MAccessOperand *, bool);
-/* Charge un contenu depuis une mémoire tampon. */
-static bool g_armv7_maccess_operand_load(GArmV7MAccessOperand *, GObjectStorage *, packed_buffer_t *);
-
-/* Sauvegarde un contenu dans une mémoire tampon. */
-static bool g_armv7_maccess_operand_store(GArmV7MAccessOperand *, GObjectStorage *, packed_buffer_t *);
-
/* ---------------------------------------------------------------------------------- */
@@ -150,8 +144,8 @@ static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass)
operand->update_inner = (operand_update_inners_fc)g_armv7_maccess_operand_update_inner_instances;
operand->hash = (operand_hash_fc)g_armv7_maccess_operand_hash;
- operand->load = (load_operand_fc)g_armv7_maccess_operand_load;
- operand->store = (store_operand_fc)g_armv7_maccess_operand_store;
+ operand->load = g_arch_operand_load_generic_fixed_3;
+ operand->store = g_arch_operand_store_generic_fixed;
}
@@ -638,28 +632,28 @@ static void g_armv7_maccess_operand_update_inner_instances(GArmV7MAccessOperand
switch (i)
{
case 0:
- g_object_unref(G_OBJECT(operand->base));
+ g_clear_object(&operand->base);
operand->base = instances[i];
break;
case 1:
if (operand->offset != NULL)
{
- g_object_unref(G_OBJECT(operand->offset));
+ g_clear_object(&operand->offset);
operand->offset = instances[i];
}
else
{
assert(count == 2);
- g_object_unref(G_OBJECT(operand->shift));
+ g_clear_object(&operand->shift);
operand->shift = instances[i];
}
break;
case 2:
- g_object_unref(G_OBJECT(operand->shift));
+ g_clear_object(&operand->shift);
operand->shift = instances[i];
break;
@@ -716,112 +710,3 @@ static guint g_armv7_maccess_operand_hash(const GArmV7MAccessOperand *operand, b
return result;
}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = élément GLib à constuire. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à lire. *
-* *
-* Description : Charge un contenu depuis une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_armv7_maccess_operand_load(GArmV7MAccessOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- GSerializableObject *obj; /* Instance à manipuler */
-
- parent = G_ARCH_OPERAND_CLASS(g_armv7_maccess_operand_parent_class);
-
- result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
-
- if (result)
- {
- obj = g_object_storage_unpack_object(storage, "operands", pbuf);
-
- result = (obj != NULL);
-
- if (result)
- operand->base = G_ARCH_OPERAND(obj);
-
- }
-
- if (result)
- {
- obj = g_object_storage_unpack_object(storage, "operands", pbuf);
-
- result = (obj != NULL);
-
- if (result)
- operand->offset = G_ARCH_OPERAND(obj);
-
- }
-
- if (result)
- {
- obj = g_object_storage_unpack_object(storage, "operands", pbuf);
-
- result = (obj != NULL);
-
- if (result)
- operand->shift = G_ARCH_OPERAND(obj);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = élément GLib à consulter. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à remplir. *
-* *
-* Description : Sauvegarde un contenu dans une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_armv7_maccess_operand_store(GArmV7MAccessOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- GSerializableObject *obj; /* Instance à manipuler */
-
- parent = G_ARCH_OPERAND_CLASS(g_armv7_maccess_operand_parent_class);
-
- result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
-
- if (result)
- {
- obj = G_SERIALIZABLE_OBJECT(operand->base);
- result = g_object_storage_pack_object(storage, "operands", obj, pbuf);
- }
-
- if (result)
- {
- obj = G_SERIALIZABLE_OBJECT(operand->offset);
- result = g_object_storage_pack_object(storage, "operands", obj, pbuf);
- }
-
- if (result)
- {
- obj = G_SERIALIZABLE_OBJECT(operand->shift);
- result = g_object_storage_pack_object(storage, "operands", obj, pbuf);
- }
-
- return result;
-
-}
diff --git a/plugins/arm/v7/operands/offset.c b/plugins/arm/v7/operands/offset.c
index 1634230..79c5cf9 100644
--- a/plugins/arm/v7/operands/offset.c
+++ b/plugins/arm/v7/operands/offset.c
@@ -24,6 +24,7 @@
#include "offset.h"
+#include <assert.h>
#include <stdio.h>
#include <string.h>
@@ -85,11 +86,11 @@ static GArchOperand *g_armv7_offset_operand_get_inner_operand_from_path(const GA
/* Traduit un opérande en version humainement lisible. */
static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *, GBufferLine *);
-/* Charge un contenu depuis une mémoire tampon. */
-static bool g_armv7_offset_operand_load(GArmV7OffsetOperand *, GObjectStorage *, packed_buffer_t *);
+/* Fournit une liste de candidats embarqués par un candidat. */
+static GArchOperand **g_armv7_offset_operand_list_inner_instances(const GArmV7OffsetOperand *, size_t *);
-/* Sauvegarde un contenu dans une mémoire tampon. */
-static bool g_armv7_offset_operand_store(GArmV7OffsetOperand *, GObjectStorage *, packed_buffer_t *);
+/* Met à jour une liste de candidats embarqués par un candidat. */
+static void g_armv7_offset_operand_update_inner_instances(GArmV7OffsetOperand *, GArchOperand **, size_t);
@@ -132,8 +133,11 @@ static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *klass)
operand->print = (operand_print_fc)g_armv7_offset_operand_print;
- operand->load = (load_operand_fc)g_armv7_offset_operand_load;
- operand->store = (store_operand_fc)g_armv7_offset_operand_store;
+ operand->list_inner = (operand_list_inners_fc)g_armv7_offset_operand_list_inner_instances;
+ operand->update_inner = (operand_update_inners_fc)g_armv7_offset_operand_update_inner_instances;
+
+ operand->load = g_arch_operand_load_generic_fixed_1;
+ operand->store = g_arch_operand_store_generic_fixed;
}
@@ -379,38 +383,27 @@ static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *operand, GBu
/******************************************************************************
* *
-* Paramètres : operand = élément GLib à constuire. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à lire. *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* count = quantité d'instances à l'unicité internes. *
* *
-* Description : Charge un contenu depuis une mémoire tampon. *
+* Description : Fournit une liste de candidats embarqués par un candidat. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : Liste de candidats internes ou NULL si aucun. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_armv7_offset_operand_load(GArmV7OffsetOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
+static GArchOperand **g_armv7_offset_operand_list_inner_instances(const GArmV7OffsetOperand *operand, size_t *count)
{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- GSerializableObject *value; /* Valeur du décalage */
-
- parent = G_ARCH_OPERAND_CLASS(g_armv7_offset_operand_parent_class);
+ GArchOperand **result; /* Instances à retourner */
- result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
-
- if (result)
- {
- value = g_object_storage_unpack_object(storage, "operands", pbuf);
+ *count = 1;
- result = (value != NULL);
+ result = malloc(*count * sizeof(GArchOperand *));
- if (result)
- operand->value = G_ARCH_OPERAND(value);
-
- }
+ result[0] = operand->value;
+ g_object_ref(G_OBJECT(result[0]));
return result;
@@ -419,34 +412,25 @@ static bool g_armv7_offset_operand_load(GArmV7OffsetOperand *operand, GObjectSto
/******************************************************************************
* *
-* Paramètres : operand = élément GLib à consulter. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à remplir. *
+* 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 : Sauvegarde un contenu dans une mémoire tampon. *
+* Description : Met à jour une liste de candidats embarqués par un candidat. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_armv7_offset_operand_store(GArmV7OffsetOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
+static void g_armv7_offset_operand_update_inner_instances(GArmV7OffsetOperand *operand, GArchOperand **instances, size_t count)
{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- GSerializableObject *value; /* Valeur du décalage */
+ assert(count == 1);
- parent = G_ARCH_OPERAND_CLASS(g_armv7_offset_operand_parent_class);
-
- result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
-
- if (result)
- {
- value = G_SERIALIZABLE_OBJECT(operand->value);
- result = g_object_storage_pack_object(storage, "operands", value, pbuf);
- }
+ g_clear_object(&operand->value);
- return result;
+ operand->value = instances[0];
+ g_object_ref(G_OBJECT(instances[0]));
}
diff --git a/plugins/arm/v7/operands/rotation.c b/plugins/arm/v7/operands/rotation.c
index f90c76b..8136401 100644
--- a/plugins/arm/v7/operands/rotation.c
+++ b/plugins/arm/v7/operands/rotation.c
@@ -93,12 +93,6 @@ static GArchOperand **g_armv7_rotation_operand_list_inner_instances(const GArmV7
/* Met à jour une liste de candidats embarqués par un candidat. */
static void g_armv7_rotation_operand_update_inner_instances(GArmV7RotationOperand *, GArchOperand **, size_t);
-/* Charge un contenu depuis une mémoire tampon. */
-static bool g_armv7_rotation_operand_load(GArmV7RotationOperand *, GObjectStorage *, packed_buffer_t *);
-
-/* Sauvegarde un contenu dans une mémoire tampon. */
-static bool g_armv7_rotation_operand_store(GArmV7RotationOperand *, GObjectStorage *, packed_buffer_t *);
-
/* ---------------------------------------------------------------------------------- */
@@ -143,8 +137,8 @@ static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *klas
operand->list_inner = (operand_list_inners_fc)g_armv7_rotation_operand_list_inner_instances;
operand->update_inner = (operand_update_inners_fc)g_armv7_rotation_operand_update_inner_instances;
- operand->load = (load_operand_fc)g_armv7_rotation_operand_load;
- operand->store = (store_operand_fc)g_armv7_rotation_operand_store;
+ operand->load = g_arch_operand_load_generic_fixed_1;
+ operand->store = g_arch_operand_store_generic_fixed;
}
@@ -454,82 +448,9 @@ static void g_armv7_rotation_operand_update_inner_instances(GArmV7RotationOperan
{
assert(count == 1);
- g_object_unref(G_OBJECT(operand->value));
- operand->value = instances[0];
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = élément GLib à constuire. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à lire. *
-* *
-* Description : Charge un contenu depuis une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_armv7_rotation_operand_load(GArmV7RotationOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- GSerializableObject *value; /* Valeur de la rotation */
-
- parent = G_ARCH_OPERAND_CLASS(g_armv7_rotation_operand_parent_class);
-
- result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
-
- if (result)
- {
- value = g_object_storage_unpack_object(storage, "operands", pbuf);
-
- result = (value != NULL);
-
- if (result)
- operand->value = G_ARCH_OPERAND(value);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = élément GLib à consulter. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à remplir. *
-* *
-* Description : Sauvegarde un contenu dans une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_armv7_rotation_operand_store(GArmV7RotationOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- GSerializableObject *value; /* Valeur de la rotation */
-
- parent = G_ARCH_OPERAND_CLASS(g_armv7_rotation_operand_parent_class);
-
- result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
-
- if (result)
- {
- value = G_SERIALIZABLE_OBJECT(operand->value);
- result = g_object_storage_pack_object(storage, "operands", value, pbuf);
- }
+ g_clear_object(&operand->value);
- return result;
+ operand->value = instances[0];
+ g_object_ref(G_OBJECT(instances[0]));
}
diff --git a/plugins/arm/v7/operands/shift.c b/plugins/arm/v7/operands/shift.c
index 55f2a22..ccdfe5c 100644
--- a/plugins/arm/v7/operands/shift.c
+++ b/plugins/arm/v7/operands/shift.c
@@ -537,8 +537,10 @@ static void g_armv7_shift_operand_update_inner_instances(GArmV7ShiftOperand *ope
{
assert(count == 1);
- g_object_unref(G_OBJECT(operand->shift_value));
+ g_clear_object(&operand->shift_value);
+
operand->shift_value = instances[0];
+ g_object_ref(G_OBJECT(instances[0]));
}
@@ -603,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);
@@ -613,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;
@@ -659,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);
@@ -669,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;