diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-08-24 21:53:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-08-24 21:53:52 (GMT) |
commit | ce46ff64c00a90d03e2481dcaf1e713f22b71492 (patch) | |
tree | 5419bb07b142e34f882478c3f515644f45eaf3ae /plugins | |
parent | ebc0f829af60263fd5329f1a44f6c1e1162f97af (diff) |
Serialize registers when needed.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/arm/register.c | 97 | ||||
-rw-r--r-- | plugins/arm/v7/operands/reglist.c | 4 | ||||
-rw-r--r-- | plugins/arm/v7/registers/banked.c | 66 | ||||
-rw-r--r-- | plugins/arm/v7/registers/basic.c | 66 | ||||
-rw-r--r-- | plugins/arm/v7/registers/coproc.c | 66 | ||||
-rw-r--r-- | plugins/arm/v7/registers/simd.c | 179 | ||||
-rw-r--r-- | plugins/arm/v7/registers/special.c | 66 | ||||
-rw-r--r-- | plugins/dalvik/register.c | 195 | ||||
-rw-r--r-- | plugins/dalvik/register.h | 3 |
9 files changed, 213 insertions, 529 deletions
diff --git a/plugins/arm/register.c b/plugins/arm/register.c index 5d24806..6a58d59 100644 --- a/plugins/arm/register.c +++ b/plugins/arm/register.c @@ -46,22 +46,22 @@ static void g_arm_register_dispose(GArmRegister *); /* Procède à la libération totale de la mémoire. */ static void g_arm_register_finalize(GArmRegister *); -/* Produit une empreinte à partir d'un registre. */ -static guint g_arm_register_hash(const GArmRegister *); -/* Compare un registre avec un autre. */ -static int g_arm_register_compare(const GArmRegister *, const GArmRegister *); +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ +/* Produit une empreinte à partir d'un registre. */ +static guint g_arm_register_hash(const GArmRegister *); +/* Compare un registre avec un autre. */ +static int g_arm_register_compare(const GArmRegister *, const GArmRegister *); -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_arm_register_unserialize(GArmRegister *, GAsmStorage *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_arm_register_load(GArmRegister *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un registre dans une mémoire tampon. */ -static bool g_arm_register_serialize(const GArmRegister *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_arm_register_store(GArmRegister *, GObjectStorage *, packed_buffer_t *); @@ -88,20 +88,21 @@ G_DEFINE_TYPE(GArmRegister, g_arm_register, G_TYPE_ARCH_REGISTER); static void g_arm_register_class_init(GArmRegisterClass *klass) { - GObjectClass *object_class; /* Autre version de la classe */ - GArchRegisterClass *reg_class; /* Classe de haut niveau */ + GObjectClass *object; /* Autre version de la classe */ + GArchRegisterClass *reg; /* Classe de haut niveau */ - object_class = G_OBJECT_CLASS(klass); + object = G_OBJECT_CLASS(klass); - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_register_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_arm_register_finalize; + object->dispose = (GObjectFinalizeFunc/* ! */)g_arm_register_dispose; + object->finalize = (GObjectFinalizeFunc)g_arm_register_finalize; - reg_class = G_ARCH_REGISTER_CLASS(klass); + reg = G_ARCH_REGISTER_CLASS(klass); - reg_class->hash = (reg_hash_fc)g_arm_register_hash; - reg_class->compare = (reg_compare_fc)g_arm_register_compare; - reg_class->unserialize = (reg_unserialize_fc)g_arm_register_unserialize; - reg_class->serialize = (reg_serialize_fc)g_arm_register_serialize; + reg->hash = (reg_hash_fc)g_arm_register_hash; + reg->compare = (reg_compare_fc)g_arm_register_compare; + + reg->load = (load_register_fc)g_arm_register_load; + reg->store = (store_register_fc)g_arm_register_store; } @@ -181,6 +182,12 @@ uint8_t g_arm_register_get_index(const GArmRegister *reg) } + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + /****************************************************************************** * * * Paramètres : reg = opérande à consulter pour le calcul. * @@ -224,19 +231,13 @@ static int g_arm_register_compare(const GArmRegister *a, const GArmRegister *b) } - -/* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - /****************************************************************************** * * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * +* Paramètres : reg = élément GLib à constuire. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à lire. * * * -* Description : Charge un registre depuis une mémoire tampon. * +* Description : Charge un contenu depuis une mémoire tampon. * * * * Retour : Bilan de l'opération. * * * @@ -244,24 +245,17 @@ static int g_arm_register_compare(const GArmRegister *a, const GArmRegister *b) * * ******************************************************************************/ -static GArchRegister *g_arm_register_unserialize(GArmRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_arm_register_load(GArmRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf) { - GArchRegister *result; /* Instance à retourner */ + bool result; /* Bilan à retourner */ GArchRegisterClass *parent; /* Classe parente à consulter */ - /** - * L'indice de registre est utilisé par les sous-classes pour la regénération - * à partir du cache. - * - * Il est donc lu depuis le tempon avant l'appel à cette fonction, et est - * ainsi déjà pris en compte. - */ - - result = G_ARCH_REGISTER(reg); - parent = G_ARCH_REGISTER_CLASS(g_arm_register_parent_class); - result = parent->unserialize(result, storage, pbuf); + result = parent->load(G_ARCH_REGISTER(reg), storage, pbuf); + + if (result) + result = extract_packed_buffer(pbuf, ®->index, sizeof(uint8_t), true); return result; @@ -270,11 +264,11 @@ static GArchRegister *g_arm_register_unserialize(GArmRegister *reg, GAsmStorage /****************************************************************************** * * -* Paramètres : reg = registre d'architecture à consulter. * -* storage = mécanisme de sauvegarde à manipuler. * +* Paramètres : reg = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * * pbuf = zone tampon à remplir. * * * -* Description : Sauvegarde un registre dans une mémoire tampon. * +* Description : Sauvegarde un contenu dans une mémoire tampon. * * * * Retour : Bilan de l'opération. * * * @@ -282,20 +276,17 @@ static GArchRegister *g_arm_register_unserialize(GArmRegister *reg, GAsmStorage * * ******************************************************************************/ -static bool g_arm_register_serialize(const GArmRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_arm_register_store(GArmRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchRegisterClass *parent; /* Classe parente à consulter */ - result = extend_packed_buffer(pbuf, ®->index, sizeof(uint8_t), false); - - if (result) - { - parent = G_ARCH_REGISTER_CLASS(g_arm_register_parent_class); + parent = G_ARCH_REGISTER_CLASS(g_arm_register_parent_class); - result = parent->serialize(G_ARCH_REGISTER(reg), storage, pbuf); + result = parent->store(G_ARCH_REGISTER(reg), storage, pbuf); - } + if (result) + result = extend_packed_buffer(pbuf, ®->index, sizeof(uint8_t), false); return result; diff --git a/plugins/arm/v7/operands/reglist.c b/plugins/arm/v7/operands/reglist.c index 9b9a817..2b2ee10 100644 --- a/plugins/arm/v7/operands/reglist.c +++ b/plugins/arm/v7/operands/reglist.c @@ -457,7 +457,7 @@ static bool g_armv7_reglist_operand_unserialize(GArmV7RegListOperand *operand, G if (result) { - reg = g_arch_register_load(storage, ®_pbuf); + reg = NULL;//g_arch_register_load(storage, ®_pbuf); result = (reg != NULL); } @@ -510,7 +510,7 @@ static bool g_armv7_reglist_operand_serialize(const GArmV7RegListOperand *operan for (i = 0; i < operand->count && result; i++) { - result = g_arch_register_store(G_ARCH_REGISTER(operand->registers[i]), storage, ®_pbuf); + result = false;//g_arch_register_store(G_ARCH_REGISTER(operand->registers[i]), storage, ®_pbuf); if (result) result = g_asm_storage_store_register_data(storage, ®_pbuf, &pos); diff --git a/plugins/arm/v7/registers/banked.c b/plugins/arm/v7/registers/banked.c index daeae71..d565f95 100644 --- a/plugins/arm/v7/registers/banked.c +++ b/plugins/arm/v7/registers/banked.c @@ -78,14 +78,6 @@ static GArchRegister *_g_armv7_banked_register_new(BankedRegisterTarget); -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ - - -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_armv7_banked_register_unserialize(GArmV7BankedRegister *, GAsmStorage *, packed_buffer_t *); - - - /* ------------------------ GESTION SOUS FORME DE SINGLETONS ------------------------ */ @@ -133,7 +125,6 @@ static void g_armv7_banked_register_class_init(GArmV7BankedRegisterClass *klass) object_class->finalize = (GObjectFinalizeFunc)g_armv7_banked_register_finalize; reg_class->print = (reg_print_fc)g_armv7_banked_register_print; - reg_class->unserialize = (reg_unserialize_fc)g_armv7_banked_register_unserialize; } @@ -567,63 +558,6 @@ BankedRegisterTarget g_armv7_banked_register_get_target(const GArmV7BankedRegist /* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * -* * -* Description : Charge un registre depuis une mémoire tampon. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchRegister *g_armv7_banked_register_unserialize(GArmV7BankedRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) -{ - GArchRegister *result; /* Instance à retourner */ - uint8_t index; /* Indice du registre */ - bool status; /* Bilan d'une extraction */ - GArchRegisterClass *parent; /* Classe parente à consulter */ - - status = extract_packed_buffer(pbuf, &index, sizeof(uint8_t), false); - - if (status) - { - result = get_armv7_banked_register(index); - - if (result == NULL) - g_object_unref(G_OBJECT(reg)); - - } - - else - { - g_object_unref(G_OBJECT(reg)); - result = NULL; - } - - if (result != NULL) - { - parent = G_ARCH_REGISTER_CLASS(g_armv7_banked_register_parent_class); - - result = parent->unserialize(result, storage, pbuf); - - } - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ /* GESTION SOUS FORME DE SINGLETONS */ /* ---------------------------------------------------------------------------------- */ diff --git a/plugins/arm/v7/registers/basic.c b/plugins/arm/v7/registers/basic.c index d92f74e..60ef821 100644 --- a/plugins/arm/v7/registers/basic.c +++ b/plugins/arm/v7/registers/basic.c @@ -75,14 +75,6 @@ static GArchRegister *_g_armv7_basic_register_new(uint8_t); -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ - - -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_armv7_basic_register_unserialize(GArmV7BasicRegister *, GAsmStorage *, packed_buffer_t *); - - - /* ------------------------ GESTION SOUS FORME DE SINGLETONS ------------------------ */ @@ -130,7 +122,6 @@ static void g_armv7_basic_register_class_init(GArmV7BasicRegisterClass *klass) object_class->finalize = (GObjectFinalizeFunc)g_armv7_basic_register_finalize; reg_class->print = (reg_print_fc)g_armv7_basic_register_print; - reg_class->unserialize = (reg_unserialize_fc)g_armv7_basic_register_unserialize; } @@ -302,63 +293,6 @@ GArchRegister *g_armv7_basic_register_new(uint8_t index) /* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * -* * -* Description : Charge un registre depuis une mémoire tampon. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchRegister *g_armv7_basic_register_unserialize(GArmV7BasicRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) -{ - GArchRegister *result; /* Instance à retourner */ - uint8_t index; /* Indice du registre */ - bool status; /* Bilan d'une extraction */ - GArchRegisterClass *parent; /* Classe parente à consulter */ - - status = extract_packed_buffer(pbuf, &index, sizeof(uint8_t), false); - - if (status) - { - result = get_armv7_basic_register(index); - - if (result == NULL) - g_object_unref(G_OBJECT(reg)); - - } - - else - { - g_object_unref(G_OBJECT(reg)); - result = NULL; - } - - if (result != NULL) - { - parent = G_ARCH_REGISTER_CLASS(g_armv7_basic_register_parent_class); - - result = parent->unserialize(result, storage, pbuf); - - } - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ /* GESTION SOUS FORME DE SINGLETONS */ /* ---------------------------------------------------------------------------------- */ diff --git a/plugins/arm/v7/registers/coproc.c b/plugins/arm/v7/registers/coproc.c index acfbb81..3d4ee8e 100644 --- a/plugins/arm/v7/registers/coproc.c +++ b/plugins/arm/v7/registers/coproc.c @@ -76,14 +76,6 @@ static GArchRegister *_g_armv7_cp_register_new(uint8_t); -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ - - -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_armv7_cp_register_unserialize(GArmV7CpRegister *, GAsmStorage *, packed_buffer_t *); - - - /* ------------------------ GESTION SOUS FORME DE SINGLETONS ------------------------ */ @@ -131,7 +123,6 @@ static void g_armv7_cp_register_class_init(GArmV7CpRegisterClass *klass) object_class->finalize = (GObjectFinalizeFunc)g_armv7_cp_register_finalize; reg_class->print = (reg_print_fc)g_armv7_cp_register_print; - reg_class->unserialize = (reg_unserialize_fc)g_armv7_cp_register_unserialize; } @@ -282,63 +273,6 @@ GArchRegister *g_armv7_cp_register_new(uint8_t index) /* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * -* * -* Description : Charge un registre depuis une mémoire tampon. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchRegister *g_armv7_cp_register_unserialize(GArmV7CpRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) -{ - GArchRegister *result; /* Instance à retourner */ - uint8_t index; /* Indice du registre */ - bool status; /* Bilan d'une extraction */ - GArchRegisterClass *parent; /* Classe parente à consulter */ - - status = extract_packed_buffer(pbuf, &index, sizeof(uint8_t), false); - - if (status) - { - result = get_armv7_cp_register(index); - - if (result == NULL) - g_object_unref(G_OBJECT(reg)); - - } - - else - { - g_object_unref(G_OBJECT(reg)); - result = NULL; - } - - if (result != NULL) - { - parent = G_ARCH_REGISTER_CLASS(g_armv7_cp_register_parent_class); - - result = parent->unserialize(result, storage, pbuf); - - } - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ /* GESTION SOUS FORME DE SINGLETONS */ /* ---------------------------------------------------------------------------------- */ diff --git a/plugins/arm/v7/registers/simd.c b/plugins/arm/v7/registers/simd.c index eedd7c8..e38de0c 100644 --- a/plugins/arm/v7/registers/simd.c +++ b/plugins/arm/v7/registers/simd.c @@ -70,22 +70,21 @@ static void g_armv7_simd_register_dispose(GArmV7SIMDRegister *); /* Procède à la libération totale de la mémoire. */ static void g_armv7_simd_register_finalize(GArmV7SIMDRegister *); -/* Traduit un registre en version humainement lisible. */ -static void g_armv7_simd_register_print(const GArmV7SIMDRegister *, GBufferLine *); - /* Crée une réprésentation de registre SIMD ARMv7. */ static GArchRegister *_g_armv7_simd_register_new(SIMDRegisterMapping, uint8_t); -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ +/* Traduit un registre en version humainement lisible. */ +static void g_armv7_simd_register_print(const GArmV7SIMDRegister *, GBufferLine *); -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_armv7_simd_register_unserialize(GArmV7SIMDRegister *, GAsmStorage *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_armv7_simd_register_load(GArmV7SIMDRegister *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un registre dans une mémoire tampon. */ -static bool g_armv7_simd_register_serialize(const GArmV7SIMDRegister *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_armv7_simd_register_store(GArmV7SIMDRegister *, GObjectStorage *, packed_buffer_t *); @@ -126,20 +125,20 @@ G_DEFINE_TYPE(GArmV7SIMDRegister, g_armv7_simd_register, G_TYPE_ARMV7_REGISTER); static void g_armv7_simd_register_class_init(GArmV7SIMDRegisterClass *klass) { - GObjectClass *object_class; /* Autre version de la classe */ - GArchRegisterClass *reg_class; /* Classe de haut niveau */ + GObjectClass *object; /* Autre version de la classe */ + GArchRegisterClass *reg; /* Classe de haut niveau */ - object_class = G_OBJECT_CLASS(klass); + object = G_OBJECT_CLASS(klass); - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_simd_register_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_armv7_simd_register_finalize; + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_simd_register_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_simd_register_finalize; - reg_class = G_ARCH_REGISTER_CLASS(klass); + reg = G_ARCH_REGISTER_CLASS(klass); - reg_class->print = (reg_print_fc)g_armv7_simd_register_print; - reg_class->unserialize = (reg_unserialize_fc)g_armv7_simd_register_unserialize; - reg_class->serialize = (reg_serialize_fc)g_armv7_simd_register_serialize; + reg->print = (reg_print_fc)g_armv7_simd_register_print; + reg->load = (load_register_fc)g_armv7_simd_register_load; + reg->store = (store_register_fc)g_armv7_simd_register_store; } @@ -202,50 +201,6 @@ static void g_armv7_simd_register_finalize(GArmV7SIMDRegister *reg) /****************************************************************************** * * -* Paramètres : reg = registre à transcrire. * -* line = ligne tampon où imprimer l'opérande donné. * -* * -* Description : Traduit un registre en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_simd_register_print(const GArmV7SIMDRegister *reg, GBufferLine *line) -{ - char key[MAX_REGNAME_LEN]; /* Mot clef principal */ - size_t klen; /* Taille de ce mot clef */ - - switch (reg->mapping) - { - case SRM_SINGLE_WORD: - klen = snprintf(key, MAX_REGNAME_LEN, "s%hhu", G_ARM_REGISTER(reg)->index); - break; - - case SRM_DOUBLE_WORD: - klen = snprintf(key, MAX_REGNAME_LEN, "d%hhu", G_ARM_REGISTER(reg)->index); - break; - - case SRM_QUAD_WORD: - klen = snprintf(key, MAX_REGNAME_LEN, "q%hhu", G_ARM_REGISTER(reg)->index); - break; - - default: - assert(false); - klen = snprintf(key, MAX_REGNAME_LEN, "x??"); - break; - - } - - g_buffer_line_append_text(line, DLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - -} - - -/****************************************************************************** -* * * Paramètres : mapping = type de registre demandé. * * index = indice du registre correspondant. * * * @@ -328,57 +283,84 @@ GArchRegister *g_armv7_simd_register_new(SIMDRegisterMapping mapping, uint8_t in /* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ /* ---------------------------------------------------------------------------------- */ /****************************************************************************** * * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * +* Paramètres : reg = registre à transcrire. * +* line = ligne tampon où imprimer l'opérande donné. * * * -* Description : Charge un registre depuis une mémoire tampon. * +* Description : Traduit un registre en version humainement lisible. * * * -* Retour : Bilan de l'opération. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -static GArchRegister *g_armv7_simd_register_unserialize(GArmV7SIMDRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) +static void g_armv7_simd_register_print(const GArmV7SIMDRegister *reg, GBufferLine *line) { - GArchRegister *result; /* Instance à retourner */ - SIMDRegisterMapping mapping; /* Type de registre */ - bool status; /* Bilan d'une extraction */ - uint8_t index; /* Indice du registre */ - GArchRegisterClass *parent; /* Classe parente à consulter */ + char key[MAX_REGNAME_LEN]; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ - status = extract_packed_buffer(pbuf, &mapping, sizeof(SIMDRegisterMapping), true); + switch (reg->mapping) + { + case SRM_SINGLE_WORD: + klen = snprintf(key, MAX_REGNAME_LEN, "s%hhu", G_ARM_REGISTER(reg)->index); + break; - if (status) - status = extract_packed_buffer(pbuf, &index, sizeof(uint8_t), false); + case SRM_DOUBLE_WORD: + klen = snprintf(key, MAX_REGNAME_LEN, "d%hhu", G_ARM_REGISTER(reg)->index); + break; - if (status) - { - result = get_armv7_simd_register(mapping, index); + case SRM_QUAD_WORD: + klen = snprintf(key, MAX_REGNAME_LEN, "q%hhu", G_ARM_REGISTER(reg)->index); + break; - if (result == NULL) - g_object_unref(G_OBJECT(reg)); + default: + assert(false); + klen = snprintf(key, MAX_REGNAME_LEN, "x??"); + break; } - else - { - g_object_unref(G_OBJECT(reg)); - result = NULL; - } + g_buffer_line_append_text(line, DLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - if (result != NULL) +} + + +/****************************************************************************** +* * +* Paramètres : reg = é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_simd_register_load(GArmV7SIMDRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchRegisterClass *parent; /* Classe parente à consulter */ + uleb128_t value; /* Valeur à charger */ + + parent = G_ARCH_REGISTER_CLASS(g_armv7_simd_register_parent_class); + + result = parent->load(G_ARCH_REGISTER(reg), storage, pbuf); + + if (result) { - parent = G_ARCH_REGISTER_CLASS(g_armv7_simd_register_parent_class); + result = unpack_uleb128(&value, pbuf); - result = parent->unserialize(G_ARCH_REGISTER(reg), storage, pbuf); + if (result) + reg->mapping = value; } @@ -389,11 +371,11 @@ static GArchRegister *g_armv7_simd_register_unserialize(GArmV7SIMDRegister *reg, /****************************************************************************** * * -* Paramètres : reg = registre d'architecture à consulter. * -* storage = mécanisme de sauvegarde à manipuler. * +* Paramètres : reg = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * * pbuf = zone tampon à remplir. * * * -* Description : Sauvegarde un registre dans une mémoire tampon. * +* Description : Sauvegarde un contenu dans une mémoire tampon. * * * * Retour : Bilan de l'opération. * * * @@ -401,20 +383,17 @@ static GArchRegister *g_armv7_simd_register_unserialize(GArmV7SIMDRegister *reg, * * ******************************************************************************/ -static bool g_armv7_simd_register_serialize(const GArmV7SIMDRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_armv7_simd_register_store(GArmV7SIMDRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchRegisterClass *parent; /* Classe parente à consulter */ - result = extend_packed_buffer(pbuf, ®->mapping, sizeof(SIMDRegisterMapping), true); - - if (result) - { - parent = G_ARCH_REGISTER_CLASS(g_armv7_simd_register_parent_class); + parent = G_ARCH_REGISTER_CLASS(g_armv7_simd_register_parent_class); - result = parent->serialize(G_ARCH_REGISTER(reg), storage, pbuf); + result = parent->store(G_ARCH_REGISTER(reg), storage, pbuf); - } + if (result) + result = pack_uleb128((uleb128_t []){ reg->mapping }, pbuf); return result; diff --git a/plugins/arm/v7/registers/special.c b/plugins/arm/v7/registers/special.c index ff46a1e..d0bfb67 100644 --- a/plugins/arm/v7/registers/special.c +++ b/plugins/arm/v7/registers/special.c @@ -75,14 +75,6 @@ static GArchRegister *_g_armv7_special_register_new(SpecRegTarget); -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ - - -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_armv7_special_register_unserialize(GArmV7SpecialRegister *, GAsmStorage *, packed_buffer_t *); - - - /* ------------------------ GESTION SOUS FORME DE SINGLETONS ------------------------ */ @@ -130,7 +122,6 @@ static void g_armv7_special_register_class_init(GArmV7SpecialRegisterClass *klas object_class->finalize = (GObjectFinalizeFunc)g_armv7_special_register_finalize; reg_class->print = (reg_print_fc)g_armv7_special_register_print; - reg_class->unserialize = (reg_unserialize_fc)g_armv7_special_register_unserialize; } @@ -326,63 +317,6 @@ GArchRegister *g_armv7_special_register_new(SpecRegTarget target) /* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * -* * -* Description : Charge un registre depuis une mémoire tampon. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchRegister *g_armv7_special_register_unserialize(GArmV7SpecialRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) -{ - GArchRegister *result; /* Instance à retourner */ - uint8_t index; /* Indice du registre */ - bool status; /* Bilan d'une extraction */ - GArchRegisterClass *parent; /* Classe parente à consulter */ - - status = extract_packed_buffer(pbuf, &index, sizeof(uint8_t), false); - - if (status) - { - result = get_armv7_special_register(index); - - if (result == NULL) - g_object_unref(G_OBJECT(reg)); - - } - - else - { - g_object_unref(G_OBJECT(reg)); - result = NULL; - } - - if (result != NULL) - { - parent = G_ARCH_REGISTER_CLASS(g_armv7_special_register_parent_class); - - result = parent->unserialize(result, storage, pbuf); - - } - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ /* GESTION SOUS FORME DE SINGLETONS */ /* ---------------------------------------------------------------------------------- */ diff --git a/plugins/dalvik/register.c b/plugins/dalvik/register.c index 87babfb..b350b04 100644 --- a/plugins/dalvik/register.c +++ b/plugins/dalvik/register.c @@ -70,25 +70,28 @@ static void g_dalvik_register_dispose(GDalvikRegister *); /* Procède à la libération totale de la mémoire. */ static void g_dalvik_register_finalize(GDalvikRegister *); -/* Produit une empreinte à partir d'un registre. */ -static guint g_dalvik_register_hash(const GDalvikRegister *); - -/* Traduit un registre en version humainement lisible. */ -static void g_dalvik_register_print(const GDalvikRegister *, GBufferLine *); - /* Crée une réprésentation de registre Dalvik. */ static GArchRegister *_g_dalvik_register_new(uint16_t); -/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */ +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Produit une empreinte à partir d'un registre. */ +static guint g_dalvik_register_hash(const GDalvikRegister *); +/* Compare un registre avec un autre. */ +static int g_dalvik_register_compare(const GDalvikRegister *, const GDalvikRegister *); + +/* Traduit un registre en version humainement lisible. */ +static void g_dalvik_register_print(const GDalvikRegister *, GBufferLine *); -/* Charge un registre depuis une mémoire tampon. */ -static GArchRegister *g_dalvik_register_unserialize(GDalvikRegister *, GAsmStorage *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_dalvik_register_load(GDalvikRegister *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un registre dans une mémoire tampon. */ -static bool g_dalvik_register_serialize(const GDalvikRegister *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_dalvik_register_store(GDalvikRegister *, GObjectStorage *, packed_buffer_t *); @@ -130,20 +133,21 @@ G_DEFINE_TYPE(GDalvikRegister, g_dalvik_register, G_TYPE_ARCH_REGISTER); static void g_dalvik_register_class_init(GDalvikRegisterClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GArchRegisterClass *reg_class; /* Classe de haut niveau */ + GArchRegisterClass *reg; /* Classe de haut niveau */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_register_dispose; object->finalize = (GObjectFinalizeFunc)g_dalvik_register_finalize; - reg_class = G_ARCH_REGISTER_CLASS(klass); + reg = G_ARCH_REGISTER_CLASS(klass); + + reg->hash = (reg_hash_fc)g_dalvik_register_hash; + reg->compare = (reg_compare_fc)g_dalvik_register_compare; + reg->print = (reg_print_fc)g_dalvik_register_print; - reg_class->hash = (reg_hash_fc)g_dalvik_register_hash; - reg_class->compare = (reg_compare_fc)g_dalvik_register_compare; - reg_class->print = (reg_print_fc)g_dalvik_register_print; - reg_class->unserialize = (reg_unserialize_fc)g_dalvik_register_unserialize; - reg_class->serialize = (reg_serialize_fc)g_dalvik_register_serialize; + reg->load = (load_register_fc)g_dalvik_register_load; + reg->store = (store_register_fc)g_dalvik_register_store; } @@ -206,50 +210,6 @@ static void g_dalvik_register_finalize(GDalvikRegister *reg) /****************************************************************************** * * -* Paramètres : reg = opérande à consulter pour le calcul. * -* * -* Description : Produit une empreinte à partir d'un registre. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static guint g_dalvik_register_hash(const GDalvikRegister *reg) -{ - return reg->index; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = registre à transcrire. * -* line = ligne tampon où imprimer l'opérande donné. * -* * -* Description : Traduit un registre en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_register_print(const GDalvikRegister *reg, GBufferLine *line) -{ - char key[MAX_REGNAME_LEN]; /* Mot clef principal */ - size_t klen; /* Taille de ce mot clef */ - - klen = snprintf(key, MAX_REGNAME_LEN, "v%hu", reg->index); - - g_buffer_line_append_text(line, DLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - -} - - -/****************************************************************************** -* * * Paramètres : index = indice du registre correspondant. * * * * Description : Crée une réprésentation de registre Dalvik. * @@ -315,6 +275,31 @@ uint16_t g_dalvik_register_get_index(const GDalvikRegister *reg) } + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : reg = opérande à consulter pour le calcul. * +* * +* Description : Produit une empreinte à partir d'un registre. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static guint g_dalvik_register_hash(const GDalvikRegister *reg) +{ + return reg->index; + +} + + /****************************************************************************** * * * Paramètres : a = premier opérande à consulter. * @@ -328,7 +313,7 @@ uint16_t g_dalvik_register_get_index(const GDalvikRegister *reg) * * ******************************************************************************/ -int g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b) +static int g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b) { int result; /* Bilan à retourner */ @@ -339,57 +324,56 @@ int g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b } - -/* ---------------------------------------------------------------------------------- */ -/* TRANSPOSITIONS VIA CACHE DES OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - /****************************************************************************** * * -* Paramètres : reg = registre d'architecture à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* pbuf = zone tampon à remplir. * +* Paramètres : reg = registre à transcrire. * +* line = ligne tampon où imprimer l'opérande donné. * * * -* Description : Charge un registre depuis une mémoire tampon. * +* Description : Traduit un registre en version humainement lisible. * * * -* Retour : Bilan de l'opération. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -static GArchRegister *g_dalvik_register_unserialize(GDalvikRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) +static void g_dalvik_register_print(const GDalvikRegister *reg, GBufferLine *line) { - GArchRegister *result; /* Instance à retourner */ - uint16_t index; /* Indice du registre */ - bool status; /* Bilan d'une extraction */ - GArchRegisterClass *parent; /* Classe parente à consulter */ + char key[MAX_REGNAME_LEN]; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ - status = extract_packed_buffer(pbuf, &index, sizeof(uint16_t), true); + klen = snprintf(key, MAX_REGNAME_LEN, "v%hu", reg->index); - if (status) - { - result = get_dalvik_register(index); + g_buffer_line_append_text(line, DLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - if (result == NULL) - g_object_unref(G_OBJECT(reg)); +} - } - else - { - g_object_unref(G_OBJECT(reg)); - result = NULL; - } +/****************************************************************************** +* * +* Paramètres : reg = é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 : - * +* * +******************************************************************************/ - if (result != NULL) - { - parent = G_ARCH_REGISTER_CLASS(g_dalvik_register_parent_class); +static bool g_dalvik_register_load(GDalvikRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchRegisterClass *parent; /* Classe parente à consulter */ - result = parent->unserialize(result, storage, pbuf); + parent = G_ARCH_REGISTER_CLASS(g_dalvik_register_parent_class); - } + result = parent->load(G_ARCH_REGISTER(reg), storage, pbuf); + + if (result) + result = extract_packed_buffer(pbuf, ®->index, sizeof(uint16_t), true); return result; @@ -398,11 +382,11 @@ static GArchRegister *g_dalvik_register_unserialize(GDalvikRegister *reg, GAsmSt /****************************************************************************** * * -* Paramètres : reg = registre d'architecture à consulter. * -* storage = mécanisme de sauvegarde à manipuler. * +* Paramètres : reg = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * * pbuf = zone tampon à remplir. * * * -* Description : Sauvegarde un registre dans une mémoire tampon. * +* Description : Sauvegarde un contenu dans une mémoire tampon. * * * * Retour : Bilan de l'opération. * * * @@ -410,20 +394,17 @@ static GArchRegister *g_dalvik_register_unserialize(GDalvikRegister *reg, GAsmSt * * ******************************************************************************/ -static bool g_dalvik_register_serialize(const GDalvikRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_dalvik_register_store(GDalvikRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchRegisterClass *parent; /* Classe parente à consulter */ - result = extend_packed_buffer(pbuf, ®->index, sizeof(uint16_t), true); + parent = G_ARCH_REGISTER_CLASS(g_dalvik_register_parent_class); - if (result) - { - parent = G_ARCH_REGISTER_CLASS(g_dalvik_register_parent_class); + result = parent->store(G_ARCH_REGISTER(reg), storage, pbuf); - result = parent->serialize(G_ARCH_REGISTER(reg), storage, pbuf); - - } + if (result) + result = extend_packed_buffer(pbuf, ®->index, sizeof(uint16_t), true); return result; diff --git a/plugins/dalvik/register.h b/plugins/dalvik/register.h index 586d242..8c664a5 100644 --- a/plugins/dalvik/register.h +++ b/plugins/dalvik/register.h @@ -60,9 +60,6 @@ GArchRegister *g_dalvik_register_new(uint16_t); /* Fournit l'indice d'un registre Dalvik. */ uint16_t g_dalvik_register_get_index(const GDalvikRegister *); -/* Compare un registre avec un autre. */ -int g_dalvik_register_compare(const GDalvikRegister *, const GDalvikRegister *); - /* ------------------------ GESTION SOUS FORME DE SINGLETONS ------------------------ */ |