diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-05-28 17:37:46 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-05-28 17:37:46 (GMT) |
commit | 9f5ed46de568d3db882c939c8ca9d0117bff3369 (patch) | |
tree | 9d2090cd640e54379dc1b982e03dc284b2d23ae7 /plugins/arm/v7/cregister.c | |
parent | 2fd186a84cba4f39f6f1bb8bd34d52b4e1d4f814 (diff) |
Relied on register objects as often as possible.
Diffstat (limited to 'plugins/arm/v7/cregister.c')
-rw-r--r-- | plugins/arm/v7/cregister.c | 340 |
1 files changed, 0 insertions, 340 deletions
diff --git a/plugins/arm/v7/cregister.c b/plugins/arm/v7/cregister.c deleted file mode 100644 index 7b39e02..0000000 --- a/plugins/arm/v7/cregister.c +++ /dev/null @@ -1,340 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * cregisters.c - aides auxiliaires relatives aux registres de co-processeur ARMv7 - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "cregister.h" - - -#include <stdio.h> - - -#include "../register-int.h" - - - -/* ------------------------- GESTION UNITAIRE DES REGISTRES ------------------------- */ - - -/* Représentation d'un registre de co-processeur ARMv7 (instance) */ -struct _GArmV7CRegister -{ - GArmRegister parent; /* Instance parente */ - -}; - - -/* Représentation d'un registre de co-processeur ARMv7 (classe) */ -struct _GArmV7CRegisterClass -{ - GArmRegisterClass parent; /* Classe parente */ - -}; - - - -/* Initialise la classe des registres de co-processeur ARMv7. */ -static void g_armv7_cregister_class_init(GArmV7CRegisterClass *); - -/* Initialise une instance de registre de co-processeur ARMv7. */ -static void g_armv7_cregister_init(GArmV7CRegister *); - -/* Supprime toutes les références externes. */ -static void g_armv7_cregister_dispose(GArmV7CRegister *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_cregister_finalize(GArmV7CRegister *); - -/* Traduit un registre en version humainement lisible. */ -static void g_armv7_cregister_print(const GArmV7CRegister *, GBufferLine *, AsmSyntax); - -/* Crée une réprésentation de registre de co-processeur ARMv7. */ -static GArmV7CRegister *_g_armv7_cregister_new(uint8_t); - - - -/* ------------------------ GESTION SOUS FORME DE SINGLETONS ------------------------ */ - - -/* Conservation des registres utilisés */ -static GArmV7CRegister **_armv7_cregisters = NULL; -static size_t _av7creg_count = 0; -G_LOCK_DEFINE_STATIC(_av7creg_mutex); - - -/* Fournit le singleton associé à un registre de co-proc. ARMv7. */ -static GArmV7CRegister *get_armv7_cregister(uint8_t); - - - -/* Indique le type défini pour une représentation d'un registre de co-processeur ARMv7. */ -G_DEFINE_TYPE(GArmV7CRegister, g_armv7_cregister, G_TYPE_ARM_REGISTER); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des registres de co-processeur ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_class_init(GArmV7CRegisterClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchRegisterClass *reg_class; /* Classe de haut niveau */ - - object_class = G_OBJECT_CLASS(klass); - reg_class = G_ARCH_REGISTER_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_cregister_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_armv7_cregister_finalize; - - reg_class->print = (reg_print_fc)g_armv7_cregister_print; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance à initialiser. * -* * -* Description : Initialise une instance de registre de co-processeur ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_init(GArmV7CRegister *reg) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_dispose(GArmV7CRegister *reg) -{ - G_OBJECT_CLASS(g_armv7_cregister_parent_class)->dispose(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_finalize(GArmV7CRegister *reg) -{ - G_OBJECT_CLASS(g_armv7_cregister_parent_class)->finalize(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = registre à transcrire. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un registre en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_print(const GArmV7CRegister *reg, GBufferLine *line, AsmSyntax syntax) -{ - char key[MAX_REGNAME_LEN]; /* Mot clef principal */ - size_t klen; /* Taille de ce mot clef */ - - switch (G_ARM_REGISTER(reg)->index) - { - case 0 ... 15: - klen = snprintf(key, MAX_REGNAME_LEN, "c%hhu", G_ARM_REGISTER(reg)->index); - break; - default: - klen = snprintf(key, MAX_REGNAME_LEN, "c??"); - break; - } - - g_buffer_line_append_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : index = indice du registre correspondant. * -* * -* Description : Crée une réprésentation de registre de co-processeur ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArmV7CRegister *_g_armv7_cregister_new(uint8_t index) -{ - GArmV7CRegister *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_CREGISTER, NULL); - - G_ARM_REGISTER(result)->index = index; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : index = indice du registre correspondant. * -* * -* Description : Crée une réprésentation de registre de co-processeur ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmV7CRegister *g_armv7_cregister_new(uint8_t index) -{ - GArmV7CRegister *result; /* Structure à retourner */ - - result = get_armv7_cregister(index); - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* GESTION SOUS FORME DE SINGLETONS */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : index = indice du registre correspondant. * -* * -* Description : Fournit le singleton associé à un registre de co-proc. ARMv7.* -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArmV7CRegister *get_armv7_cregister(uint8_t index) -{ - GArmV7CRegister *result; /* Structure à retourner */ - size_t new_count; /* Nouvelle taille à considérer*/ - size_t i; /* Boucle de parcours */ - - G_LOCK(_av7creg_mutex); - - if (index >= _av7creg_count) - { - new_count = index + 1; - - _armv7_cregisters = realloc(_armv7_cregisters, new_count * sizeof(GArmV7CRegister *)); - - for (i = _av7creg_count; i < new_count; i++) - _armv7_cregisters[i] = NULL; - - _av7creg_count = new_count; - - } - - if (_armv7_cregisters[index] == NULL) - _armv7_cregisters[index] = _g_armv7_cregister_new(index); - - result = _armv7_cregisters[index]; - - G_UNLOCK(_av7creg_mutex); - - g_object_ref(G_OBJECT(result)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Vide totalement le cache des registres ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void clean_armv7_cregister_cache(void) -{ - size_t i; /* Boucle de parcours */ - - G_LOCK(_av7creg_mutex); - - for (i = 0; i < _av7creg_count; i++) - g_object_unref(G_OBJECT(_armv7_cregisters[i])); - - if (_armv7_cregisters != NULL) - free(_armv7_cregisters); - - _armv7_cregisters = NULL; - _av7creg_count = 0; - - G_UNLOCK(_av7creg_mutex); - -} |