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/arm/v7 | |
parent | ebc0f829af60263fd5329f1a44f6c1e1162f97af (diff) |
Serialize registers when needed.
Diffstat (limited to 'plugins/arm/v7')
-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 |
6 files changed, 81 insertions, 366 deletions
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 */ /* ---------------------------------------------------------------------------------- */ |