summaryrefslogtreecommitdiff
path: root/src/arch/operands/immediate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/operands/immediate.c')
-rw-r--r--src/arch/operands/immediate.c1052
1 files changed, 268 insertions, 784 deletions
diff --git a/src/arch/operands/immediate.c b/src/arch/operands/immediate.c
index cb39fce..f40c645 100644
--- a/src/arch/operands/immediate.c
+++ b/src/arch/operands/immediate.c
@@ -31,100 +31,25 @@
#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>
-#include <string.h>
#include <i18n.h>
+#include "immediate-int.h"
+#include "known.h"
#include "rename-int.h"
#include "targetable-int.h"
-#include "../operand-int.h"
#include "../../common/asm.h"
#include "../../common/extstr.h"
-#include "../../core/logs.h"
-#include "../../format/format.h"
-#include "../../glibext/objhole.h"
-#include "../../gtkext/gtkblockdisplay.h"
+#include "../../common/sort.h"
+#include "../../core/columns.h"
/* ------------------------- OPERANDE POUR VALEUR IMMEDIATE ------------------------- */
-/* Etats particuliers d'un opérande de valeur immédiate */
-typedef enum _ImmOpFlag
-{
- IOF_ZERO_PADDING_BY_DEFAULT, /* Bourrage avec 0 par défaut ?*/
- IOF_ZERO_PADDING, /* Bourrage avec 0 ? */
-
-} ImmOpFlag;
-
-/* Informations glissées dans la structure GObject de GArchInstruction */
-typedef union _immop_obj_extra
-{
- struct
- {
- MemoryDataSize size; /* Taille de l'opérande */
-
- ImmOperandDisplay def_display; /* Type par défaut d'affichage */
- ImmOperandDisplay display; /* Format général d'affichage */
- ImmOpFlag flags; /* Informations diverses */
-
- };
-
- gint lock; /* Gestion d'accès aux fanions */
-
-} immop_obj_extra;
-
-/* Définition d'un opérande de valeur numérique (instance) */
-struct _GImmOperand
-{
- GArchOperand parent; /* Instance parente */
-
- uint64_t raw; /* Valeur transtypée */
-
-#if __SIZEOF_INT__ == __SIZEOF_LONG__
-
- /**
- * L'inclusion des informations suivantes dépend de l'architecture.
- *
- * Si la structure GObject possède un trou, on remplit de préférence
- * ce dernier.
- */
-
- immop_obj_extra extra; /* Externalisation embarquée */
-
-#endif
-
-};
-
-/**
- * Accès aux informations éventuellement déportées.
- */
-
-#if __SIZEOF_INT__ == __SIZEOF_LONG__
-
-# define INIT_IMM_OP_EXTRA(op) op->extra.lock = 0
-
-# define GET_IMM_OP_EXTRA(op) &op->extra
-
-#else
-
-# define INIT_IMM_OP_EXTRA(op) INIT_GOBJECT_EXTRA(G_OBJECT(op))
-
-# define GET_IMM_OP_EXTRA(op) GET_GOBJECT_EXTRA(G_OBJECT(op), immop_obj_extra)
-
-#endif
-
-/* Définition d'un opérande de valeur numérique (classe) */
-struct _GImmOperandClass
-{
- GArchOperandClass parent; /* Classe parente */
-
-};
-
-
/* Initialise la classe des opérandes de valeur immédiate. */
static void g_imm_operand_class_init(GImmOperandClass *);
@@ -143,81 +68,51 @@ static void g_imm_operand_dispose(GImmOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_imm_operand_finalize(GImmOperand *);
-/* Compare un opérande avec un autre. */
-static int g_imm_operand_compare(const GImmOperand *, const GImmOperand *);
-
/* Construit la chaîne de caractères correspondant à l'opérande. */
static size_t _g_imm_operand_to_string(const GImmOperand *, ImmOperandDisplay, char [IMM_MAX_SIZE]);
/* Traduit un opérande en version humainement lisible. */
static void g_imm_operand_print(const GImmOperand *, GBufferLine *);
-/* Construit un petit résumé concis de l'opérande. */
-static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinary *);
-
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_imm_operand_unserialize(GImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
-
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_imm_operand_serialize(const GImmOperand *, GAsmStorage *, packed_buffer_t *);
-/* Obtient l'adresse de la cible visée par un opérande. */
-static bool g_imm_operand_get_addr(const GImmOperand *, const vmpa2t *, GBinFormat *, GArchProcessor *, vmpa2t *);
-
-/* Construit un opérande de représentation alternative. */
-static GRenamedOperand *g_imm_operand_build(const GImmOperand *, const char *);
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
-/* ----------------------- REMPLACEMENT DE VALEURS IMMEDIATES ----------------------- */
-
+/* Compare un opérande avec un autre. */
+static int g_imm_operand_compare(const GImmOperand *, const GImmOperand *, bool);
-/* Définition d'un remplacement d'opérande de valeur numérique (instance) */
-struct _GKnownImmOperand
-{
- GImmOperand parent; /* Instance parente */
+#ifdef INCLUDE_GTK_SUPPORT
- char *alt_text; /* Alternative humaine */
+/* Construit un petit résumé concis de l'opérande. */
+static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinary *);
-};
+#endif
-/* Définition d'un remplacement d'opérande de valeur numérique (classe) */
-struct _GKnownImmOperandClass
-{
- GImmOperandClass parent; /* Classe parente */
+/* Fournit l'empreinte d'un candidat à une centralisation. */
+static guint g_imm_operand_hash(const GImmOperand *, bool);
-};
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_imm_operand_load(GImmOperand *, GObjectStorage *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_imm_operand_store(GImmOperand *, GObjectStorage *, packed_buffer_t *);
-/* Initialise la classe des remplacements d'opérandes. */
-static void g_known_imm_operand_class_init(GKnownImmOperandClass *);
-/* Initialise un remplacement d'opérande de valeur immédiate. */
-static void g_known_imm_operand_init(GKnownImmOperand *);
-/* Procède à l'initialisation de l'interface de renommage. */
-static void g_known_imm_operand_renamed_interface_init(GRenamedOperandInterface *);
+/* ---------------------- COMMUNICATION D'UN CIBLAGE POTENTIEL ---------------------- */
-/* Supprime toutes les références externes. */
-static void g_known_imm_operand_dispose(GKnownImmOperand *);
-/* Procède à la libération totale de la mémoire. */
-static void g_known_imm_operand_finalize(GKnownImmOperand *);
+/* Obtient l'adresse de la cible visée par un opérande. */
+static bool g_imm_operand_get_addr(const GImmOperand *, const vmpa2t *, GBinFormat *, GArchProcessor *, vmpa2t *);
-/* Compare un opérande avec un autre. */
-static int g_known_imm_operand_compare(const GKnownImmOperand *, const GKnownImmOperand *);
-/* Traduit un opérande en version humainement lisible. */
-static void g_known_imm_operand_print(const GKnownImmOperand *, GBufferLine *);
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_known_imm_operand_unserialize(GKnownImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
+/* ---------------------- CONSTRUCTION D'UN CONTENU ALTERNATIF ---------------------- */
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_known_imm_operand_serialize(const GKnownImmOperand *, GAsmStorage *, packed_buffer_t *);
-/* Fournit un texte comme représentation alternative d'opérande. */
-static const char *g_known_imm_operand_get_text(const GKnownImmOperand *);
+/* Construit un opérande de représentation alternative. */
+static GRenamedOperand *g_imm_operand_build(const GImmOperand *, const char *);
@@ -257,10 +152,14 @@ static void g_imm_operand_class_init(GImmOperandClass *klass)
operand->compare = (operand_compare_fc)g_imm_operand_compare;
operand->print = (operand_print_fc)g_imm_operand_print;
+#ifdef INCLUDE_GTK_SUPPORT
operand->build_tooltip = (operand_build_tooltip_fc)g_imm_operand_build_tooltip;
+#endif
+
+ operand->hash = (operand_hash_fc)g_imm_operand_hash;
- operand->unserialize = (unserialize_operand_fc)g_imm_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_imm_operand_serialize;
+ operand->load = (load_operand_fc)g_imm_operand_load;
+ operand->store = (store_operand_fc)g_imm_operand_store;
}
@@ -279,13 +178,13 @@ static void g_imm_operand_class_init(GImmOperandClass *klass)
static void g_imm_operand_init(GImmOperand *operand)
{
- operand->raw = 0;
-
- INIT_IMM_OP_EXTRA(operand);
+ GET_IMM_OP_EXTRA(operand)->size = MDS_UNDEFINED;
GET_IMM_OP_EXTRA(operand)->def_display = IOD_HEX;
GET_IMM_OP_EXTRA(operand)->display = IOD_COUNT;
+ operand->raw = 0;
+
}
@@ -384,7 +283,7 @@ static void g_imm_operand_finalize(GImmOperand *operand)
GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinContent *content, vmpa2t *addr, bool *low, SourceEndian endian)
{
GImmOperand *result; /* Opérande à retourner */
- immop_obj_extra *extra; /* Données insérées à modifier */
+ immop_extra_data_t *extra; /* Données insérées à modifier */
uint8_t uval8; /* Valeur sur 8 bits */
uint16_t uval16; /* Valeur sur 16 bits */
uint32_t uval32; /* Valeur sur 32 bits */
@@ -495,7 +394,7 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten
GArchOperand *g_imm_operand_new_from_value(MemoryDataSize size, uint64_t value)
{
GImmOperand *result; /* Opérande à retourner */
- immop_obj_extra *extra; /* Données insérées à modifier */
+ immop_extra_data_t *extra; /* Données insérées à modifier */
if (size == MDS_UNDEFINED)
result = NULL;
@@ -519,98 +418,6 @@ GArchOperand *g_imm_operand_new_from_value(MemoryDataSize size, uint64_t value)
/******************************************************************************
* *
-* Paramètres : a = premier opérande à consulter. *
-* b = second opérande à consulter. *
-* *
-* Description : Compare un opérande avec un autre. *
-* *
-* Retour : Bilan de la comparaison. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static int g_imm_operand_compare(const GImmOperand *a, const GImmOperand *b)
-{
- int result; /* Bilan à retourner */
- immop_obj_extra *ea; /* Données insérées à modifier */
- immop_obj_extra *eb; /* Données insérées à modifier */
-
- ea = GET_IMM_OP_EXTRA(a);
- eb = GET_IMM_OP_EXTRA(b);
-
- g_bit_lock(&ea->lock, HOLE_LOCK_BIT);
- g_bit_lock(&eb->lock, HOLE_LOCK_BIT);
-
- if (ea->size < eb->size)
- {
- result = -1;
- goto done;
- }
- else if (ea->size > eb->size)
- {
- result = 1;
- goto done;
- }
-
- if (a->raw < b->raw)
- {
- result = -1;
- goto done;
- }
- else if (a->raw > b->raw)
- {
- result = 1;
- goto done;
- }
-
- if (ea->def_display < eb->def_display)
- {
- result = -1;
- goto done;
- }
- else if (ea->def_display > eb->def_display)
- {
- result = 1;
- goto done;
- }
-
- if (ea->display < eb->display)
- {
- result = -1;
- goto done;
- }
- else if (ea->display > eb->display)
- {
- result = 1;
- goto done;
- }
-
- if (ea->flags < eb->flags)
- {
- result = -1;
- goto done;
- }
- else if (ea->flags > eb->flags)
- {
- result = 1;
- goto done;
- }
-
- result = 0;
-
- done:
-
- g_bit_unlock(&eb->lock, HOLE_LOCK_BIT);
- g_bit_unlock(&ea->lock, HOLE_LOCK_BIT);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : operand = structure dont le contenu est à consulter. *
* *
* Description : Renseigne la taille de la valeur indiquée à la construction. *
@@ -624,15 +431,15 @@ static int g_imm_operand_compare(const GImmOperand *a, const GImmOperand *b)
MemoryDataSize g_imm_operand_get_size(const GImmOperand *operand)
{
MemoryDataSize result; /* Taille à retourner */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
result = extra->size;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -656,7 +463,7 @@ MemoryDataSize g_imm_operand_get_size(const GImmOperand *operand)
bool g_imm_operand_get_value(const GImmOperand *operand, MemoryDataSize size, ...)
{
bool result; /* Bilan à retourner */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
va_list ap; /* Liste des compléments */
uint8_t *uval8; /* Valeur sur 8 bits */
uint16_t *uval16; /* Valeur sur 16 bits */
@@ -671,7 +478,7 @@ bool g_imm_operand_get_value(const GImmOperand *operand, MemoryDataSize size, ..
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
if (extra->size != size)
goto exit;
@@ -726,7 +533,7 @@ bool g_imm_operand_get_value(const GImmOperand *operand, MemoryDataSize size, ..
exit:
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -768,141 +575,19 @@ uint64_t g_imm_operand_get_raw_value(const GImmOperand *operand)
void g_imm_operand_set_value(GImmOperand *operand, MemoryDataSize size, uint64_t value)
{
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
assert(size != MDS_UNDEFINED);
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
extra->size = size;
operand->raw = value;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = structure dont le contenu est à consulter. *
-* *
-* Description : Indique si une valeur est complétée par des zéros par défaut.*
-* *
-* Retour : true si des zéro sont ajoutés à l'affichage, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool g_imm_operand_get_default_padding(const GImmOperand *operand)
-{
- bool result; /* Statut à retourner */
- immop_obj_extra *extra; /* Données insérées à modifier */
-
- extra = GET_IMM_OP_EXTRA(operand);
-
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
-
- result = (extra->flags & IOF_ZERO_PADDING_BY_DEFAULT);
-
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = structure dont le contenu est à actualiser. [OUT] *
-* state = true si des zéro sont à ajouter, false sinon. *
-* *
-* Description : Précise si des zéro doivent compléter l'affichage ou non. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_imm_operand_set_default_padding(GImmOperand *operand, bool state)
-{
- immop_obj_extra *extra; /* Données insérées à modifier */
-
- extra = GET_IMM_OP_EXTRA(operand);
-
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
-
- if (state)
- extra->flags |= IOF_ZERO_PADDING_BY_DEFAULT;
- else
- extra->flags &= ~IOF_ZERO_PADDING_BY_DEFAULT;
-
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = structure dont le contenu est à actualiser. [OUT] *
-* state = true si des zéro sont à ajouter, false sinon. *
-* *
-* Description : Précise si des zéro doivent compléter l'affichage ou non. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_imm_operand_pad(GImmOperand *operand, bool state)
-{
- immop_obj_extra *extra; /* Données insérées à modifier */
-
- extra = GET_IMM_OP_EXTRA(operand);
-
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
-
- if (state)
- extra->flags |= (IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING);
- else
- extra->flags &= ~(IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING);
-
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = structure dont le contenu est à consulter. *
-* *
-* Description : Indique si une valeur est complétée par des zéros. *
-* *
-* Retour : true si des zéro sont ajoutés à l'affichage, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool g_imm_operand_does_padding(const GImmOperand *operand)
-{
- bool result; /* Statut à retourner */
- immop_obj_extra *extra; /* Données insérées à modifier */
-
- extra = GET_IMM_OP_EXTRA(operand);
-
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
-
- result = (extra->flags & (IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING));
-
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
-
- return result;
+ UNLOCK_GOBJECT_EXTRA(extra);
}
@@ -922,15 +607,15 @@ bool g_imm_operand_does_padding(const GImmOperand *operand)
void g_imm_operand_set_default_display(GImmOperand *operand, ImmOperandDisplay display)
{
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
extra->def_display = display;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
}
@@ -950,15 +635,15 @@ void g_imm_operand_set_default_display(GImmOperand *operand, ImmOperandDisplay d
ImmOperandDisplay g_imm_operand_get_default_display(const GImmOperand *operand)
{
ImmOperandDisplay result; /* Affichage à retourner */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
result = extra->def_display;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -980,15 +665,15 @@ ImmOperandDisplay g_imm_operand_get_default_display(const GImmOperand *operand)
void g_imm_operand_set_display(GImmOperand *operand, ImmOperandDisplay display)
{
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
extra->display = display;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
}
@@ -1008,18 +693,18 @@ void g_imm_operand_set_display(GImmOperand *operand, ImmOperandDisplay display)
ImmOperandDisplay g_imm_operand_get_display(const GImmOperand *operand)
{
ImmOperandDisplay result; /* Affichage à retourner */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
if (extra->display != IOD_COUNT)
result = extra->display;
else
result = extra->def_display;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -1041,11 +726,11 @@ ImmOperandDisplay g_imm_operand_get_display(const GImmOperand *operand)
bool g_imm_operand_is_negative(const GImmOperand *operand)
{
bool result; /* Bilan à renvoyer */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
switch (extra->size)
{
@@ -1065,7 +750,7 @@ bool g_imm_operand_is_negative(const GImmOperand *operand)
break;
}
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -1108,7 +793,7 @@ bool g_imm_operand_is_null(const GImmOperand *operand)
static size_t _g_imm_operand_to_string(const GImmOperand *operand, ImmOperandDisplay display, char value[IMM_MAX_SIZE])
{
size_t result; /* Longueur à retourner */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
unsigned int range; /* Catégorie de la taille */
const char *prefix; /* Entrée en matière */
const char *suffix; /* Sortie de matière */
@@ -1132,7 +817,7 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, ImmOperandDis
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ //LOCK_GOBJECT_EXTRA(extra);
range = MDS_RANGE(extra->size);
@@ -1173,7 +858,7 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, ImmOperandDis
/* Drapeau de remplissage ? */
- do_padding = (extra->flags & (IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING));
+ do_padding = g_arch_operand_has_flag(G_ARCH_OPERAND(operand), IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING);
if (do_padding)
{
@@ -1297,7 +982,7 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, ImmOperandDis
}
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ //UNLOCK_GOBJECT_EXTRA(extra);
assert(result > 0);
@@ -1361,94 +1046,6 @@ static void g_imm_operand_print(const GImmOperand *operand, GBufferLine *line)
/******************************************************************************
* *
-* Paramètres : operand = opérande à consulter. *
-* binary = informations relatives au binaire chargé. *
-* *
-* Description : Construit un petit résumé concis de l'opérande. *
-* *
-* Retour : Chaîne de caractères à libérer après usage ou NULL. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static char *g_imm_operand_build_tooltip(const GImmOperand *operand, const GLoadedBinary *binary)
-{
- char *result; /* Description à retourner */
- char value[IMM_MAX_SIZE]; /* Conversion artificielle */
- char *conv; /* Affichage de la Conversion */
-
- if (operand->raw <= UCHAR_MAX && isprint(operand->raw))
- switch (operand->raw)
- {
- case '&':
- asprintf(&result, _("Character: '&amp;'"));
- break;
- case '<':
- asprintf(&result, _("Character: '&lt;'"));
- break;
- case '>':
- asprintf(&result, _("Character: '&gt;'"));
- break;
- default:
- asprintf(&result, _("Character: '%c'"), (char)operand->raw);
- break;
- }
-
- else
- asprintf(&result, _("Character: &lt;not printable&gt;"));
-
- /* Binaire */
-
- _g_imm_operand_to_string(operand, IOD_BIN, value);
-
- asprintf(&conv, _("Binary: %s"), value);
-
- result = stradd(result, "\n");
- result = stradd(result, conv);
-
- free(conv);
-
- /* Octal */
-
- _g_imm_operand_to_string(operand, IOD_OCT, value);
-
- asprintf(&conv, _("Octal: %s"), value);
-
- result = stradd(result, "\n");
- result = stradd(result, conv);
-
- free(conv);
-
- /* Décimal */
-
- _g_imm_operand_to_string(operand, IOD_DEC, value);
-
- asprintf(&conv, _("Decimal: %s"), value);
-
- result = stradd(result, "\n");
- result = stradd(result, conv);
-
- free(conv);
-
- /* Hexadécimal */
-
- _g_imm_operand_to_string(operand, IOD_HEX, value);
-
- asprintf(&conv, _("Hexadecimal: %s"), value);
-
- result = stradd(result, "\n");
- result = stradd(result, conv);
-
- free(conv);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : operand = opérande à traiter. *
* pos = valeur résultante. [OUT] *
* *
@@ -1463,18 +1060,18 @@ static char *g_imm_operand_build_tooltip(const GImmOperand *operand, const GLoad
bool g_imm_operand_to_phys_t(const GImmOperand *operand, phys_t *pos)
{
bool result; /* Bilan à renvoyer */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
result = !MDS_IS_SIGNED(extra->size);
if (result)
*pos = operand->raw;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -1497,18 +1094,18 @@ bool g_imm_operand_to_phys_t(const GImmOperand *operand, phys_t *pos)
bool g_imm_operand_to_virt_t(const GImmOperand *operand, virt_t *addr)
{
bool result; /* Bilan à renvoyer */
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
result = !MDS_IS_SIGNED(extra->size);
if (result)
*addr = operand->raw;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -1530,15 +1127,15 @@ bool g_imm_operand_to_virt_t(const GImmOperand *operand, virt_t *addr)
void g_imm_operand_as_leb128(const GImmOperand *operand, leb128_t *val)
{
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
*val = operand->raw;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
}
@@ -1558,119 +1155,76 @@ void g_imm_operand_as_leb128(const GImmOperand *operand, leb128_t *val)
void g_imm_operand_as_uleb128(const GImmOperand *operand, uleb128_t *val)
{
- immop_obj_extra *extra; /* Données insérées à consulter*/
+ immop_extra_data_t *extra; /* Données insérées à consulter*/
extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
*val = operand->raw;
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ UNLOCK_GOBJECT_EXTRA(extra);
}
-/******************************************************************************
-* *
-* Paramètres : operand = opérande d'assemblage à constituer. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* format = format binaire chargé associé à l'architecture. *
-* pbuf = zone tampon à remplir. *
-* *
-* Description : Charge un opérande depuis une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- immop_obj_extra *extra; /* Données insérées à modifier */
-
- parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
-
- result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
-
- if (result)
- result = extract_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true);
-
- if (result)
- {
- extra = GET_IMM_OP_EXTRA(operand);
-
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
-
- result = extract_packed_buffer(pbuf, &extra->size, sizeof(MemoryDataSize), true);
-
- if (result)
- result = extract_packed_buffer(pbuf, &extra->def_display, sizeof(ImmOperandDisplay), true);
- if (result)
- result = extract_packed_buffer(pbuf, &extra->display, sizeof(ImmOperandDisplay), true);
-
- if (result)
- result = extract_packed_buffer(pbuf, &extra->flags, sizeof(uint8_t), false);
-
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
-
- }
-
- return result;
-
-}
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* lock = précise le besoin en verrouillage. *
* *
-* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* Description : Compare un opérande avec un autre. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : Bilan de la comparaison. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static int g_imm_operand_compare(const GImmOperand *a, const GImmOperand *b, bool lock)
{
- bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- immop_obj_extra *extra; /* Données insérées à modifier */
-
- parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
-
- result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+ int result; /* Bilan à retourner */
+ immop_extra_data_t *ea; /* Données insérées à modifier */
+ immop_extra_data_t *eb; /* Données insérées à modifier */
+ GArchOperandClass *class; /* Classe parente normalisée */
- if (result)
- result = extend_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true);
+ ea = GET_IMM_OP_EXTRA(a);
+ eb = GET_IMM_OP_EXTRA(b);
- if (result)
+ if (lock)
{
- extra = GET_IMM_OP_EXTRA(operand);
-
- g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(ea);
+ LOCK_GOBJECT_EXTRA(eb);
+ }
- result = extend_packed_buffer(pbuf, &extra->size, sizeof(MemoryDataSize), true);
+ result = sort_unsigned_long(ea->size, eb->size);
- if (result)
- result = extend_packed_buffer(pbuf, &extra->def_display, sizeof(ImmOperandDisplay), true);
+ if (result == 0)
+ sort_uint64_t(a->raw, b->raw);
- if (result)
- result = extend_packed_buffer(pbuf, &extra->display, sizeof(ImmOperandDisplay), true);
+ if (result == 0)
+ result = sort_unsigned_long(ea->def_display, eb->def_display);
- if (result)
- result = extend_packed_buffer(pbuf, &extra->flags, sizeof(ImmOpFlag), true);
+ if (result == 0)
+ result = sort_unsigned_long(ea->display, eb->display);
- g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+ if (result == 0)
+ {
+ class = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
+ result = class->compare(G_ARCH_OPERAND(a), G_ARCH_OPERAND(b), false);
+ }
+ if (lock)
+ {
+ UNLOCK_GOBJECT_EXTRA(eb);
+ UNLOCK_GOBJECT_EXTRA(ea);
}
return result;
@@ -1678,246 +1232,199 @@ static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *sto
}
-/******************************************************************************
-* *
-* Paramètres : operand = operande à consulter. *
-* src = localisation de l'instruction mère. *
-* format = format reconnu pour le binaire chargé. *
-* proc = architecture associée à ce même binaire. *
-* addr = localisation de la cible. [OUT] *
-* *
-* Description : Obtient l'adresse de la cible visée par un opérande. *
-* *
-* Retour : true si la cible est valide, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_imm_operand_get_addr(const GImmOperand *operand, const vmpa2t *src, GBinFormat *format, GArchProcessor *proc, vmpa2t *addr)
-{
- bool result; /* Bilan à retourner */
- virt_t virt; /* Adresse virtuelle */
-
- result = g_imm_operand_to_virt_t(operand, &virt);
-
- if (result)
- result = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), virt, addr);
-
- return result;
-
-}
+#ifdef INCLUDE_GTK_SUPPORT
/******************************************************************************
* *
-* Paramètres : operand = operande à consulter. *
-* text = texte alternatif de représentation. *
+* Paramètres : operand = opérande à consulter. *
+* binary = informations relatives au binaire chargé. *
* *
-* Description : Construit un opérande de représentation alternative. *
+* Description : Construit un petit résumé concis de l'opérande. *
* *
-* Retour : Nouvel opérande, en version renommée. *
+* Retour : Chaîne de caractères à libérer après usage ou NULL. *
* *
* Remarques : - *
* *
******************************************************************************/
-static GRenamedOperand *g_imm_operand_build(const GImmOperand *operand, const char *text)
+static char *g_imm_operand_build_tooltip(const GImmOperand *operand, const GLoadedBinary *binary)
{
- GRenamedOperand *result; /* Instance à retourner */
+ char *result; /* Description à retourner */
+ char value[IMM_MAX_SIZE]; /* Conversion artificielle */
+ char *conv; /* Affichage de la Conversion */
- result = G_RENAMED_OPERAND(g_known_imm_operand_new(operand, text));
+ if (operand->raw <= UCHAR_MAX && isprint(operand->raw))
+ switch (operand->raw)
+ {
+ case '&':
+ asprintf(&result, _("Character: '&amp;'"));
+ break;
+ case '<':
+ asprintf(&result, _("Character: '&lt;'"));
+ break;
+ case '>':
+ asprintf(&result, _("Character: '&gt;'"));
+ break;
+ default:
+ asprintf(&result, _("Character: '%c'"), (char)operand->raw);
+ break;
+ }
- return result;
+ else
+ asprintf(&result, _("Character: &lt;not printable&gt;"));
-}
+ /* Binaire */
+ _g_imm_operand_to_string(operand, IOD_BIN, value);
+ asprintf(&conv, _("Binary: %s"), value);
-/* ---------------------------------------------------------------------------------- */
-/* REMPLACEMENT DE VALEURS IMMEDIATES */
-/* ---------------------------------------------------------------------------------- */
+ result = stradd(result, "\n");
+ result = stradd(result, conv);
+ free(conv);
-/* Indique le type défini pour un remplacemet d'opérande de valeur numérique. */
-G_DEFINE_TYPE_WITH_CODE(GKnownImmOperand, g_known_imm_operand, G_TYPE_IMM_OPERAND,
- G_IMPLEMENT_INTERFACE(G_TYPE_RENAMED_OPERAND, g_known_imm_operand_renamed_interface_init));
+ /* Octal */
+ _g_imm_operand_to_string(operand, IOD_OCT, value);
-/******************************************************************************
-* *
-* Paramètres : klass = classe à initialiser. *
-* *
-* Description : Initialise la classe des remplacements d'opérandes. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ asprintf(&conv, _("Octal: %s"), value);
-static void g_known_imm_operand_class_init(GKnownImmOperandClass *klass)
-{
- GObjectClass *object; /* Autre version de la classe */
- GArchOperandClass *operand; /* Version de classe parente */
+ result = stradd(result, "\n");
+ result = stradd(result, conv);
- object = G_OBJECT_CLASS(klass);
- operand = G_ARCH_OPERAND_CLASS(klass);
+ free(conv);
- object->dispose = (GObjectFinalizeFunc/* ! */)g_known_imm_operand_dispose;
- object->finalize = (GObjectFinalizeFunc)g_known_imm_operand_finalize;
+ /* Décimal */
- operand->compare = (operand_compare_fc)g_known_imm_operand_compare;
- operand->print = (operand_print_fc)g_known_imm_operand_print;
+ _g_imm_operand_to_string(operand, IOD_DEC, value);
- operand->unserialize = (unserialize_operand_fc)g_known_imm_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_known_imm_operand_serialize;
+ asprintf(&conv, _("Decimal: %s"), value);
-}
+ result = stradd(result, "\n");
+ result = stradd(result, conv);
+ free(conv);
-/******************************************************************************
-* *
-* Paramètres : operand = instance à initialiser. *
-* *
-* Description : Initialise un remplacement d'opérande de valeur immédiate. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ /* Hexadécimal */
-static void g_known_imm_operand_init(GKnownImmOperand *operand)
-{
- operand->alt_text = NULL;
+ _g_imm_operand_to_string(operand, IOD_HEX, value);
-}
+ asprintf(&conv, _("Hexadecimal: %s"), value);
+ result = stradd(result, "\n");
+ result = stradd(result, conv);
-/******************************************************************************
-* *
-* Paramètres : iface = interface GLib à initialiser. *
-* *
-* Description : Procède à l'initialisation de l'interface de renommage. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ free(conv);
-static void g_known_imm_operand_renamed_interface_init(GRenamedOperandInterface *iface)
-{
- iface->get_text = (get_renamed_text_fc)g_known_imm_operand_get_text;
+ return result;
}
+#endif
+
+
/******************************************************************************
* *
-* Paramètres : operand = instance d'objet GLib à traiter. *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* lock = précise le besoin en verrouillage. *
* *
-* Description : Supprime toutes les références externes. *
+* Description : Fournit l'empreinte d'un candidat à une centralisation. *
* *
-* Retour : - *
+* Retour : Empreinte de l'élément représenté. *
* *
* Remarques : - *
* *
******************************************************************************/
-static void g_known_imm_operand_dispose(GKnownImmOperand *operand)
+static guint g_imm_operand_hash(const GImmOperand *operand, bool lock)
{
- if (operand->alt_text != NULL)
- free(operand->alt_text);
+ guint result; /* Valeur à retourner */
+ immop_extra_data_t *extra; /* Données insérées à modifier */
+ GArchOperandClass *class; /* Classe parente normalisée */
- G_OBJECT_CLASS(g_known_imm_operand_parent_class)->dispose(G_OBJECT(operand));
+ extra = GET_IMM_OP_EXTRA(operand);
-}
+ if (lock)
+ LOCK_GOBJECT_EXTRA(extra);
+ class = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
+ result = class->hash(G_ARCH_OPERAND(operand), false);
-/******************************************************************************
-* *
-* Paramètres : operand = instance d'objet GLib à traiter. *
-* *
-* Description : Procède à la libération totale de la mémoire. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ result ^= (operand->raw & 0xffffffff);
+ result ^= (operand->raw >> 32);
-static void g_known_imm_operand_finalize(GKnownImmOperand *operand)
-{
- G_OBJECT_CLASS(g_known_imm_operand_parent_class)->finalize(G_OBJECT(operand));
+ if (lock)
+ UNLOCK_GOBJECT_EXTRA(extra);
+
+ return result;
}
/******************************************************************************
* *
-* Paramètres : old = opérande à venir copier avant son remplacement. *
-* alt = texte alternatif à présenter pour l'impression. *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Crée un opérande remplaçant visuellement une valeur. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
-* Retour : Instruction mise en place. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GArchOperand *g_known_imm_operand_new(const GImmOperand *old, const char *alt)
+static bool g_imm_operand_load(GImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
- GKnownImmOperand *result; /* Remplacement à retourner */
- immop_obj_extra *src; /* Données insérées à consulter*/
- immop_obj_extra *dest; /* Données insérées à modifier */
+ bool result; /* Bilan à retourner */
+ GArchOperandClass *parent; /* Classe parente à consulter */
+ immop_extra_data_t *extra; /* Données insérées à modifier */
+ uleb128_t value; /* Valeur ULEB128 à charger */
+ uint8_t val; /* Champ de bits manipulé */
- result = g_object_new(G_TYPE_KNOWN_IMM_OPERAND, NULL);
+ parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
- result->parent.raw = old->raw;
+ result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
- src = GET_IMM_OP_EXTRA(old);
- dest = GET_IMM_OP_EXTRA(&result->parent);
+ if (result)
+ {
+ extra = GET_IMM_OP_EXTRA(operand);
- g_bit_lock(&src->lock, HOLE_LOCK_BIT);
+ LOCK_GOBJECT_EXTRA(extra);
- *dest = *src;
+ result = unpack_uleb128(&value, pbuf);
- g_bit_unlock(&src->lock, HOLE_LOCK_BIT);
+ if (result)
+ extra->size = value;
- result->alt_text = strdup(alt);
+ if (result)
+ {
+ result = extract_packed_buffer(pbuf, &val, sizeof(uint8_t), false);
- return G_ARCH_OPERAND(result);
+ if (result)
+ extra->def_display = val;
-}
+ }
+ if (result)
+ {
+ result = extract_packed_buffer(pbuf, &val, sizeof(uint8_t), false);
-/******************************************************************************
-* *
-* Paramètres : a = premier opérande à consulter. *
-* b = second opérande à consulter. *
-* *
-* Description : Compare un opérande avec un autre. *
-* *
-* Retour : Bilan de la comparaison. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ if (result)
+ extra->display = val;
-static int g_known_imm_operand_compare(const GKnownImmOperand *a, const GKnownImmOperand *b)
-{
- int result; /* Bilan à retourner */
- GArchOperandClass *class; /* Classe parente à consulter */
+ }
- class = G_ARCH_OPERAND_CLASS(g_known_imm_operand_parent_class);
+ UNLOCK_GOBJECT_EXTRA(extra);
- result = class->compare(G_ARCH_OPERAND(a), G_ARCH_OPERAND(b));
+ }
- if (result == 0)
- result = strcmp(a->alt_text, b->alt_text);
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true);
return result;
@@ -1926,36 +1433,11 @@ static int g_known_imm_operand_compare(const GKnownImmOperand *a, const GKnownIm
/******************************************************************************
* *
-* Paramètres : operand = opérande à traiter. *
-* line = ligne tampon où imprimer l'opérande donné. *
-* *
-* Description : Traduit un opérande en version humainement lisible. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_known_imm_operand_print(const GKnownImmOperand *operand, GBufferLine *line)
-{
- size_t len; /* Taille de l'élément inséré */
-
- len = strlen(operand->alt_text);
-
- g_buffer_line_append_text(line, DLC_ASSEMBLY, operand->alt_text, len, RTT_IMMEDIATE, G_OBJECT(operand));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = opérande d'assemblage à constituer. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* format = format binaire chargé associé à l'architecture. *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Charge un opérande depuis une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -1963,101 +1445,103 @@ static void g_known_imm_operand_print(const GKnownImmOperand *operand, GBufferLi
* *
******************************************************************************/
-static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_imm_operand_store(GImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
- unsigned short len; /* Taille du contenu alternatif*/
+ immop_extra_data_t *extra; /* Données insérées à modifier */
- parent = G_ARCH_OPERAND_CLASS(g_known_imm_operand_parent_class);
+ parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
- result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
+ result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
if (result)
- result = extract_packed_buffer(pbuf, &len, sizeof(unsigned short), true);
+ {
+ extra = GET_IMM_OP_EXTRA(operand);
- if (result)
- result = (len > 0);
+ LOCK_GOBJECT_EXTRA(extra);
- if (result)
- {
- operand->alt_text = malloc(len);
+ result = pack_uleb128((uleb128_t []){ extra->size }, pbuf);
- result = extract_packed_buffer(pbuf, operand->alt_text, len, false);
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint8_t []) { extra->def_display }, sizeof(uint8_t), false);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint8_t []) { extra->display }, sizeof(uint8_t), false);
+
+ UNLOCK_GOBJECT_EXTRA(extra);
}
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true);
+
return result;
}
+
+/* ---------------------------------------------------------------------------------- */
+/* COMMUNICATION D'UN CIBLAGE POTENTIEL */
+/* ---------------------------------------------------------------------------------- */
+
+
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : operand = operande à consulter. *
+* src = localisation de l'instruction mère. *
+* format = format reconnu pour le binaire chargé. *
+* proc = architecture associée à ce même binaire. *
+* addr = localisation de la cible. [OUT] *
* *
-* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* Description : Obtient l'adresse de la cible visée par un opérande. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : true si la cible est valide, false sinon. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_known_imm_operand_serialize(const GKnownImmOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_imm_operand_get_addr(const GImmOperand *operand, const vmpa2t *src, GBinFormat *format, GArchProcessor *proc, vmpa2t *addr)
{
bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
- size_t len; /* Taille du contenu alternatif*/
-
- parent = G_ARCH_OPERAND_CLASS(g_known_imm_operand_parent_class);
+ virt_t virt; /* Adresse virtuelle */
- result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+ result = g_imm_operand_to_virt_t(operand, &virt);
if (result)
- {
- len = strlen(operand->alt_text) + 1;
- assert(len > 1);
-
- if (len > (2 << (sizeof(unsigned short) * 8 - 1)))
- {
- log_variadic_message(LMT_ERROR, "Alternative text too long: '%s' (%zu bytes)",
- operand->alt_text, len);
- result = false;
- }
+ result = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), virt, addr);
- else
- result = extend_packed_buffer(pbuf, (unsigned short []) { len }, sizeof(unsigned short), true);
+ return result;
- if (result)
- result = extend_packed_buffer(pbuf, operand->alt_text, len, false);
+}
- }
- return result;
-}
+/* ---------------------------------------------------------------------------------- */
+/* CONSTRUCTION D'UN CONTENU ALTERNATIF */
+/* ---------------------------------------------------------------------------------- */
/******************************************************************************
* *
* Paramètres : operand = operande à consulter. *
+* text = texte alternatif de représentation. *
* *
-* Description : Fournit un texte comme représentation alternative d'opérande.*
+* Description : Construit un opérande de représentation alternative. *
* *
-* Retour : Chaîne de caractère de représentation alternative. *
+* Retour : Nouvel opérande, en version renommée. *
* *
* Remarques : - *
* *
******************************************************************************/
-static const char *g_known_imm_operand_get_text(const GKnownImmOperand *operand)
+static GRenamedOperand *g_imm_operand_build(const GImmOperand *operand, const char *text)
{
- const char *result; /* Texte à retourner */
+ GRenamedOperand *result; /* Instance à retourner */
- result = operand->alt_text;
+ result = G_RENAMED_OPERAND(g_known_imm_operand_new(operand, text));
return result;