summaryrefslogtreecommitdiff
path: root/src/arch/target.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/target.c')
-rw-r--r--src/arch/target.c142
1 files changed, 80 insertions, 62 deletions
diff --git a/src/arch/target.c b/src/arch/target.c
index 056ace3..3f6d9a5 100644
--- a/src/arch/target.c
+++ b/src/arch/target.c
@@ -78,13 +78,13 @@ static void g_target_operand_dispose(GTargetOperand *);
static void g_target_operand_finalize(GTargetOperand *);
/* Initialise un nouvel objet partagé avec des informations. */
-static bool g_target_operand_do_init(GTargetOperand *, const GTargetOperand *);
+static bool g_target_operand_apply_template(GTargetOperand *, const GTargetOperand *);
/* Réalise une copie minimale d'un contenu partagé. */
-static void g_target_operand_quickly_copy(const GTargetOperand *, GTargetOperand *);
+static void g_target_operand_define_template(const GTargetOperand *, GTargetOperand *);
/* Compare un opérande avec un autre. */
-static int g_target_operand_compare(const GTargetOperand * const *, const GTargetOperand * const *);
+static int g_target_operand_compare(const GTargetOperand *, const GTargetOperand *);
/* Traduit un opérande en version humainement lisible. */
static void g_target_operand_print(const GTargetOperand *, GBufferLine *, AsmSyntax);
@@ -101,6 +101,10 @@ static char *g_target_operand_build_tooltip(const GTargetOperand *, const GLoade
static GShareManager *_target_operand_manager = NULL;
+/* Fournit le gestionnaire de partages attribué à un type. */
+static GShareManager *get_target_operand_share_manager(void);
+
+
/* ---------------------------------------------------------------------------------- */
/* GESTION DES OPERANDES DE CIBLAGE */
@@ -135,8 +139,10 @@ static void g_target_operand_class_init(GTargetOperandClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_target_operand_dispose;
object->finalize = (GObjectFinalizeFunc)g_target_operand_finalize;
- operand->init = (operand_do_init_fc)g_target_operand_do_init;
- operand->qck_copy = (operand_qck_copy_fc)g_target_operand_quickly_copy;
+ operand->get_manager = (get_operand_manager_fc)get_target_operand_share_manager;
+
+ operand->apply_template = (apply_operand_template_fc)g_target_operand_apply_template;
+ operand->define_template = (define_operand_template_fc)g_target_operand_define_template;
operand->compare = (operand_compare_fc)g_target_operand_compare;
operand->print = (operand_print_fc)g_target_operand_print;
@@ -182,8 +188,6 @@ static void g_target_operand_init(GTargetOperand *operand)
static void g_target_operand_dispose(GTargetOperand *operand)
{
- printf(" !! dispose %p\n", operand);
-
if (operand->symbol != NULL)
g_object_unref(G_OBJECT(operand->symbol));
@@ -213,36 +217,6 @@ static void g_target_operand_finalize(GTargetOperand *operand)
/******************************************************************************
* *
-* Paramètres : size = taille des adresse mémoire virtuelles. *
-* addr = localisation d'un élément à retrouver. *
-* *
-* Description : Crée un opérande réprésentant une valeur numérique. *
-* *
-* Retour : Instruction mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr)
-{
- GArchOperand *result; /* Opérande à retourner */
- GTargetOperand fake; /* Transport d'informations */
-
- g_target_operand_init(&fake);
-
- fake.size = size;
- copy_vmpa(&fake.addr, addr);
-
- result = G_ARCH_OPERAND(g_share_manager_get(_target_operand_manager, (GSharedInstance *)&fake));
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : operand = objet partagé à initialiser. *
* template = coquille vide contenant les infos à enregistrer. *
* *
@@ -254,9 +228,9 @@ GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr)
* *
******************************************************************************/
-static bool g_target_operand_do_init(GTargetOperand *operand, const GTargetOperand *template)
+static bool g_target_operand_apply_template(GTargetOperand *operand, const GTargetOperand *template)
{
- g_target_operand_quickly_copy(template, operand);
+ g_target_operand_define_template(template, operand);
if (operand->symbol != NULL)
g_object_ref(G_OBJECT(operand->symbol));
@@ -279,7 +253,7 @@ static bool g_target_operand_do_init(GTargetOperand *operand, const GTargetOpera
* *
******************************************************************************/
-static void g_target_operand_quickly_copy(const GTargetOperand *operand, GTargetOperand *template)
+static void g_target_operand_define_template(const GTargetOperand *operand, GTargetOperand *template)
{
template->size = operand->size;
copy_vmpa(&template->addr, &operand->addr);
@@ -303,52 +277,47 @@ static void g_target_operand_quickly_copy(const GTargetOperand *operand, GTarget
* *
******************************************************************************/
-static int g_target_operand_compare(const GTargetOperand * const *a, const GTargetOperand * const *b)
+static int g_target_operand_compare(const GTargetOperand *a, const GTargetOperand *b)
{
int result; /* Bilan à retourner */
- const GTargetOperand *target_a; /* Accès simplifié à A */
- const GTargetOperand *target_b; /* Accès simplifié à B */
- target_a = *a;
- target_b = *b;
-
- result = cmp_vmpa(&target_a->addr, &target_b->addr);
+ result = cmp_vmpa(&a->addr, &b->addr);
if (result != 0) goto gtoc_done;
- if (target_a->size < target_b->size)
+ if (a->size < b->size)
{
result = -1;
goto gtoc_done;
}
- else if (target_a->size > target_b->size)
+ else if (a->size > b->size)
{
result = 1;
goto gtoc_done;
}
- if (target_a->symbol == NULL && target_b->symbol != NULL)
+ if (a->symbol == NULL && b->symbol != NULL)
{
result = -1;
goto gtoc_done;
}
- else if (target_a->symbol != NULL && target_b->symbol == NULL)
+ else if (a->symbol != NULL && b->symbol == NULL)
{
result = 1;
goto gtoc_done;
}
- else if (target_a->symbol != NULL && target_b->symbol != NULL)
+ else if (a->symbol != NULL && b->symbol != NULL)
{
- result = g_binary_symbol_cmp((const GBinSymbol * []) { target_a->symbol },
- (const GBinSymbol * []) { target_b->symbol });
+ result = g_binary_symbol_cmp((const GBinSymbol * []) { a->symbol },
+ (const GBinSymbol * []) { b->symbol });
if (result != 0) goto gtoc_done;
}
- if (target_a->diff < target_b->diff)
+ if (a->diff < b->diff)
{
result = -1;
goto gtoc_done;
}
- else if (target_a->diff > target_b->diff)
+ else if (a->diff > b->diff)
{
result = 1;
goto gtoc_done;
@@ -419,6 +388,36 @@ static void g_target_operand_print(const GTargetOperand *operand, GBufferLine *l
/******************************************************************************
* *
+* Paramètres : size = taille des adresse mémoire virtuelles. *
+* addr = localisation d'un élément à retrouver. *
+* *
+* Description : Crée un opérande réprésentant une valeur numérique. *
+* *
+* Retour : Instruction mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr)
+{
+ GArchOperand *result; /* Opérande à retourner */
+ GTargetOperand fake; /* Transport d'informations */
+
+ g_target_operand_init(&fake);
+
+ fake.size = size;
+ copy_vmpa(&fake.addr, addr);
+
+ result = G_ARCH_OPERAND(g_share_manager_build(_target_operand_manager, (GSharedInstance *)&fake));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : operand = opérande à consulter. *
* binary = informations relatives au binaire chargé. *
* *
@@ -545,7 +544,7 @@ bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool
{
bool result; /* Bilan à retourner */
GSharedInstance *shared; /* Instace de travail partagée */
- GTargetOperand fake; /* Transport d'informations */
+ GTargetOperand template; /* Transport d'informations */
GBinSymbol *symbol; /* Facilités d'accès au symbole*/
SymbolType stype; /* Type de symbole trouvé */
const mrange_t *range; /* Couverture du symbole */
@@ -553,14 +552,14 @@ bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool
shared = G_SHARED_INSTANCE(*operand);
- g_shared_instance_quickly_copy(shared, (GSharedInstance *)&fake);
+ g_shared_instance_define_template(shared, (GSharedInstance *)&template);
- result = g_binary_format_resolve_symbol(format, &fake.addr, strict, &fake.symbol, &fake.diff);
+ result = g_binary_format_resolve_symbol(format, &template.addr, strict, &template.symbol, &template.diff);
- shared = g_share_manager_update(_target_operand_manager, shared, (GSharedInstance *)&fake, container);
+ shared = g_share_manager_update(_target_operand_manager, shared, (GSharedInstance *)&template, container);
- if (fake.symbol != NULL)
- g_object_unref(G_OBJECT(fake.symbol));
+ if (template.symbol != NULL)
+ g_object_unref(G_OBJECT(template.symbol));
*operand = G_TARGET_OPERAND(shared);
@@ -647,6 +646,25 @@ GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *operand, phys_t *d
* *
* Paramètres : - *
* *
+* Description : Fournit le gestionnaire de partages attribué à un type. *
+* *
+* Retour : Gestionnaire de partages en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GShareManager *get_target_operand_share_manager(void)
+{
+ return _target_operand_manager;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
* Description : Initialise les mécanismes de partage d'opérandes de ciblage. *
* *
* Retour : Bilan de l'opération. *