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.c210
1 files changed, 15 insertions, 195 deletions
diff --git a/src/arch/target.c b/src/arch/target.c
index 3f6d9a5..2cd8518 100644
--- a/src/arch/target.c
+++ b/src/arch/target.c
@@ -33,16 +33,12 @@
#include "operand-int.h"
-#include "sharing/manager.h"
#include "../analysis/routine.h"
#include "../common/extstr.h"
#include "../format/format.h"
-/* ------------------------ GESTION DES OPERANDES DE CIBLAGE ------------------------ */
-
-
/* Définition d'un opérande ciblant idéalement un symbole connu (instance) */
struct _GTargetOperand
{
@@ -77,12 +73,6 @@ static void g_target_operand_dispose(GTargetOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_target_operand_finalize(GTargetOperand *);
-/* Initialise un nouvel objet partagé avec des informations. */
-static bool g_target_operand_apply_template(GTargetOperand *, const GTargetOperand *);
-
-/* Réalise une copie minimale d'un contenu partagé. */
-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 GTargetOperand *);
@@ -94,23 +84,6 @@ static char *g_target_operand_build_tooltip(const GTargetOperand *, const GLoade
-/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */
-
-
-/* Gestionnaire des partages d'instances */
-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 */
-/* ---------------------------------------------------------------------------------- */
-
-
/* Indique le type défini pour un opérande de valeur numérique. */
G_DEFINE_TYPE(GTargetOperand, g_target_operand, G_TYPE_ARCH_OPERAND);
@@ -139,11 +112,6 @@ static void g_target_operand_class_init(GTargetOperandClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_target_operand_dispose;
object->finalize = (GObjectFinalizeFunc)g_target_operand_finalize;
- 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;
operand->build_tooltip = (operand_build_tooltip_fc)g_target_operand_build_tooltip;
@@ -217,55 +185,6 @@ static void g_target_operand_finalize(GTargetOperand *operand)
/******************************************************************************
* *
-* Paramètres : operand = objet partagé à initialiser. *
-* template = coquille vide contenant les infos à enregistrer. *
-* *
-* Description : Initialise un nouvel objet partagé avec des informations. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_target_operand_apply_template(GTargetOperand *operand, const GTargetOperand *template)
-{
- g_target_operand_define_template(template, operand);
-
- if (operand->symbol != NULL)
- g_object_ref(G_OBJECT(operand->symbol));
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = objet partagé à consulter. *
-* template = informations à retrouver intégralement. *
-* *
-* Description : Réalise une copie minimale d'un contenu partagé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_target_operand_define_template(const GTargetOperand *operand, GTargetOperand *template)
-{
- template->size = operand->size;
- copy_vmpa(&template->addr, &operand->addr);
-
- template->symbol = operand->symbol;
- template->diff = operand->diff;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : a = premier opérande à consulter. *
* b = second opérande à consulter. *
* *
@@ -401,17 +320,14 @@ static void g_target_operand_print(const GTargetOperand *operand, GBufferLine *l
GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr)
{
- GArchOperand *result; /* Opérande à retourner */
- GTargetOperand fake; /* Transport d'informations */
+ GTargetOperand *result; /* Opérande à retourner */
- g_target_operand_init(&fake);
+ result = g_object_new(G_TYPE_TARGET_OPERAND, NULL);
- fake.size = size;
- copy_vmpa(&fake.addr, addr);
+ result->size = size;
+ copy_vmpa(&result->addr, addr);
- result = G_ARCH_OPERAND(g_share_manager_build(_target_operand_manager, (GSharedInstance *)&fake));
-
- return result;
+ return G_ARCH_OPERAND(result);
}
@@ -527,10 +443,9 @@ void g_target_operand_get_addr(const GTargetOperand *operand, vmpa2t *addr)
/******************************************************************************
* *
-* Paramètres : operand = opérande dont le contenu est à raffiner. [OUT] *
-* format = format du binaire d'origine à consulter. *
-* strict = indique la perfection attendue de la résolution. *
-* container = propriétaire d'origine à tenir au courant. *
+* Paramètres : operand = opérande dont le contenu est à raffiner. [OUT] *
+* format = format du binaire d'origine à consulter. *
+* strict = indique la perfection attendue de la résolution. *
* *
* Description : Tente une résolution de symbole. *
* *
@@ -540,28 +455,18 @@ void g_target_operand_get_addr(const GTargetOperand *operand, vmpa2t *addr)
* *
******************************************************************************/
-bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool strict, GShareContainer *container)
+bool g_target_operand_resolve(GTargetOperand *operand, GBinFormat *format, bool strict)
{
bool result; /* Bilan à retourner */
- GSharedInstance *shared; /* Instace de travail partagée */
- 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 */
char *label; /* Désignation de la chaîne */
- shared = G_SHARED_INSTANCE(*operand);
-
- g_shared_instance_define_template(shared, (GSharedInstance *)&template);
-
- result = g_binary_format_resolve_symbol(format, &template.addr, strict, &template.symbol, &template.diff);
-
- shared = g_share_manager_update(_target_operand_manager, shared, (GSharedInstance *)&template, container);
-
- if (template.symbol != NULL)
- g_object_unref(G_OBJECT(template.symbol));
+ if (operand->symbol != NULL)
+ g_object_unref(G_OBJECT(operand->symbol));
- *operand = G_TARGET_OPERAND(shared);
+ result = g_binary_format_resolve_symbol(format, &operand->addr, strict, &operand->symbol, &operand->diff);
/**
* Si plusieurs chaînes se suivent, la seconde et les suivantes bénéficient
@@ -575,9 +480,9 @@ bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool
* attribue à cette ligne une étiquette propre.
*/
- if (result && (*operand)->diff == 0)
+ if (result && operand->diff == 0)
{
- symbol = (*operand)->symbol;
+ symbol = operand->symbol;
stype = g_binary_symbol_get_target_type(symbol);
@@ -587,7 +492,7 @@ bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool
{
range = g_binary_symbol_get_range(symbol);
- assert(cmp_vmpa(&(*operand)->addr, get_mrange_addr(range)) == 0);
+ assert(cmp_vmpa(&operand->addr, get_mrange_addr(range)) == 0);
label = create_string_label(format, get_mrange_addr(range), get_mrange_length(range));
@@ -634,88 +539,3 @@ GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *operand, phys_t *d
return result;
}
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* PARTAGES DE CONTENUS UNIQUES */
-/* ---------------------------------------------------------------------------------- */
-
-
-/******************************************************************************
-* *
-* 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. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool init_target_operand_sharing(void)
-{
- _target_operand_manager = g_share_manager_new(G_TYPE_TARGET_OPERAND);
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Imprime des statistiques quant aux partages dans l'archi. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-#ifdef DEBUG_DUMP_STATS
-void dump_target_operand_share_stats(void)
-{
- g_share_manager_dump_stats(_target_operand_manager);
-
-}
-#endif
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Supprime les mécanismes de partage des opérandes de ciblage. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void exit_target_operand_sharing(void)
-{
- g_object_unref(G_OBJECT(_target_operand_manager));
-
-}