diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-05-22 15:43:43 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-05-22 15:43:43 (GMT) |
commit | 7577eadd4e871d467f747c4927a1b1984d6a7606 (patch) | |
tree | e72a2fd5c1619e60402a678b0559079ed267eab0 /src/arch/arm/v7/cregister.c | |
parent | 33aa90b022e7d711a733ca7eb62c0b285f974317 (diff) |
Extended the compiler to transform all the new ARMv7 encoding definitions.
Diffstat (limited to 'src/arch/arm/v7/cregister.c')
-rw-r--r-- | src/arch/arm/v7/cregister.c | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/src/arch/arm/v7/cregister.c b/src/arch/arm/v7/cregister.c new file mode 100644 index 0000000..62f3833 --- /dev/null +++ b/src/arch/arm/v7/cregister.c @@ -0,0 +1,212 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * cregisters.c - aides auxiliaires relatives aux registres de co-processeur ARMv7 + * + * Copyright (C) 2016 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "cregister.h" + + +#include <stdio.h> + + +#include "../register-int.h" + + + +/* 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); + + + +/* 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 : 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 = g_object_new(G_TYPE_ARMV7_CREGISTER, NULL); + + G_ARM_REGISTER(result)->index = index; + + return result; + +} + + +/****************************************************************************** +* * +* 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_insert_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER); + +} |