summaryrefslogtreecommitdiff
path: root/src/mangling/itanium/component.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mangling/itanium/component.h')
-rw-r--r--src/mangling/itanium/component.h213
1 files changed, 213 insertions, 0 deletions
diff --git a/src/mangling/itanium/component.h b/src/mangling/itanium/component.h
new file mode 100644
index 0000000..7ab2521
--- /dev/null
+++ b/src/mangling/itanium/component.h
@@ -0,0 +1,213 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * component.h - prototypes pour la représentation des composants extraits de l'ABI C++ Itanium
+ *
+ * Copyright (C) 2013-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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_MANGLING_ITANIUM_COMPONENT_H
+#define _FORMAT_MANGLING_ITANIUM_COMPONENT_H
+
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <malloc.h>
+#include <sys/types.h>
+
+
+#include "context.h"
+#include "../../analysis/type.h"
+#include "../../common/fnv1a.h"
+
+
+
+/* Type de composants */
+typedef enum _ItaniumComponentType
+{
+ /**
+ * Représentation d'une règle vide.
+ */
+ ICT_EMPTY,
+
+ /**
+ * Chaîne de caractère, terminée par un octet nul.
+ */
+ ICT_NAME,
+ ICT_STD_SUBST,
+
+ /**
+ * Noms imbriqués, en deux parties : 'binary'.
+ */
+ ICT_NESTED_NAME,
+ ICT_TEMPLATE_NAME_ARGS,
+
+ /**
+ * Deux types de préfixes : un ou deux éléments.
+ * -> 'unary' ou 'binary'
+ */
+ ICT_PREFIX_UNARY,
+ ICT_PREFIX_BINARY,
+ ICT_TPREFIX_UNARY,
+ ICT_TPREFIX_BINARY,
+
+ /**
+ * Encodage d'un nom d'opérateur, consigné dans 'operator'.
+ */
+ ICT_OPERATOR_NAME,
+
+
+ /**
+ * Fonctions virtuelles.
+ * -> décalage : 'offset'.
+ * -> fonctions simples : 'binary'.
+ * -> fonctions complexes : 'ternary'.
+ */
+ ICT_NON_VIRTUAL_OFFSET,
+ ICT_VIRTUAL_OFFSET,
+ ICT_FUNCTION_THUNK,
+ ICT_FUNCTION_COVARIANT_THUNK,
+
+ /**
+ * Constructeur ou destructeur, sans plus de détail.
+ */
+ ICT_CONSTRUCTOR,
+ ICT_DESSTRUCTOR,
+
+ /**
+ * Type instanciable dans le programme.
+ */
+ ICT_TYPE,
+
+ /**
+ * Différentes références vers un sous-type.
+ * Le champ impacté est 'unary'.
+ */
+ ICT_POINTER_TO,
+ ICT_REFERENCE_TO,
+ ICT_RVALUE_REFERENCE_TO,
+ ICT_COMPLEX_PAIR,
+ ICT_IMAGINARY,
+
+ /**
+ * Fonction (nom + retour/paramètres), sous forme binaire :
+ * -> left = function name
+ * -> right = bare-function-type
+ */
+ ICT_FUNCTION_ENCODING,
+
+ /**
+ * Liste d'arguments pour templates, à encadrer par des chevrons.
+ * 'unary' pointe vers la liste des éléments.
+ */
+ ICT_TEMPLATE_ARGS,
+
+ /**
+ * Liste de types, sous forme binaire :
+ * -> left = élément de la liste de types.
+ * -> right = reste de la liste de types.
+ */
+ ICT_TYPES_LIST,
+
+ ICT_COUNT
+
+} ItaniumComponentType;
+
+
+/* Catégories d'opérateurs */
+typedef enum _ItaniumOperatorType
+{
+ IOT_SIMPLE, /* Présent dans la liste */
+ IOT_CAST, /* Conversion forcée */
+ IOT_VENDOR /* Défini par un vendeur */
+
+} ItaniumOperatorType;
+
+
+/* Enregistrement des opérateurs */
+typedef struct _itanium_operator_info
+{
+ const char *code; /* Nom encodé */
+ const char *name; /* Désignation humaine */
+ size_t name_len; /* Taille du nom humain */
+ int args; /* Nombre d'arguments */
+
+} itanium_operator_info;
+
+
+/* Composant extrait de l'encodage */
+typedef struct _itanium_component itanium_component;
+
+
+
+/* Incrémente le nombre d'utilisation du composant. */
+void itd_ref_comp(itanium_component *);
+
+/* Décrémente le nombre d'utilisation du composant. */
+void itd_unref_comp(itanium_component *);
+
+/* Détermine ou fournit l'empreinte d'un composant. */
+fnv64_t itd_hash_comp(itanium_component *);
+
+
+
+/* Marque un composant comme étant disponible pour un usage. */
+void itd_free_comp(GItaniumDContext *, itanium_component *);
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_empty(GItaniumDContext *);
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_name(GItaniumDContext *, const char *, size_t);
+
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_operator(GItaniumDContext *, const itanium_operator_info *);
+
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_offset(GItaniumDContext *, ItaniumComponentType, ssize_t);
+
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_type(GItaniumDContext *, GDataType *);
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_binary(GItaniumDContext *, ItaniumComponentType, itanium_component *, itanium_component *);
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_append_right_to_binary(GItaniumDContext *, ItaniumComponentType, itanium_component *, itanium_component *);
+
+/* Construit un composant dans un contexte Itanium. */
+itanium_component *itd_make_unary(GItaniumDContext *, ItaniumComponentType, itanium_component *);
+
+
+
+/* Modifie légèrement le type d'un composant donné. */
+void itd_set_type(itanium_component *, ItaniumComponentType);
+
+/* Fournit le type d'un composant issu d'un contexte Itanium. */
+ItaniumComponentType itd_get_component_type(const itanium_component *);
+
+/* Traduit les composants de contexte Itanium. */
+char *itd_translate_component(GItaniumDContext *, const itanium_component *, char *);
+
+
+
+#endif /* _FORMAT_MANGLING_ITANIUM_COMPONENT_H */