summaryrefslogtreecommitdiff
path: root/plugins/mobicore/symbols.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-02-16 07:07:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-02-16 07:07:15 (GMT)
commit635640a32fecbb9b8a5ddf239b819c022c4b9977 (patch)
treef8fc69a2c2db411000996146536ca5cc4f54d417 /plugins/mobicore/symbols.c
parentbf879f2562545ab7de23f9d38364b7bd4b43fb2c (diff)
Added a basic support for Mobicore truslets.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@472 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/mobicore/symbols.c')
-rw-r--r--plugins/mobicore/symbols.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/plugins/mobicore/symbols.c b/plugins/mobicore/symbols.c
new file mode 100644
index 0000000..c718cfa
--- /dev/null
+++ b/plugins/mobicore/symbols.c
@@ -0,0 +1,145 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * symbols.c - gestion des symboles d'un MCLF
+ *
+ * Copyright (C) 2015 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 "symbols.h"
+
+
+#include <malloc.h>
+
+
+#include <format/mangling/demangler.h>
+
+
+#include "mclf-int.h"
+
+
+
+/* Enregistre un point d'entrée au sein d'un binaire MCLF. */
+static void register_mclf_entry_point(GMCLFFormat *, virt_t, phys_t, GBinRoutine *);
+
+/* Enumère les points d'entrée principaux d'un binaire MCLF. */
+static bool load_all_mclf_basic_entry_points(GMCLFFormat *format);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* vaddr = adresse virtuelle du symbole à insérer. *
+* len = taille de la routine à ajouter. *
+* routine = représentation de la fonction repérée. *
+* *
+* Description : Enregistre un point d'entrée au sein d'un binaire MCLF. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void register_mclf_entry_point(GMCLFFormat *format, virt_t vaddr, phys_t len, GBinRoutine *routine)
+{
+ GBinFormat *base; /* Version basique de l'instance */
+ vmpa2t addr; /* Localisation d'une routine */
+ mrange_t range; /* Couverture mémoire associée */
+ GBinSymbol *symbol; /* Nouveau symbole construit */
+
+ base = G_BIN_FORMAT(format);
+
+ /* Comptabilisation pour le désassemblage brut */
+
+ base->entry_points = (virt_t *)realloc(base->entry_points, ++base->ep_count * sizeof(virt_t));
+
+ base->entry_points[base->ep_count - 1] = vaddr;
+
+ /* Comptabilisation en tant que symbole */
+
+ vaddr &= ~0x1;
+
+ init_vmpa(&addr, vaddr - format->header.v1.text.start, vaddr);
+ init_vmpa(&addr, VMPA_NO_PHYSICAL, vaddr);
+
+ init_mrange(&range, &addr, len);
+
+ g_binary_routine_set_range(routine, &range);
+
+ symbol = g_binary_symbol_new(STP_ENTRY_POINT, "XXX", ~0);
+ g_binary_symbol_attach_routine(symbol, routine);
+ g_binary_format_add_symbol(base, symbol);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* *
+* Description : Enumère les points d'entrée principaux d'un binaire MCLF. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool load_all_mclf_basic_entry_points(GMCLFFormat *format)
+{
+ virt_t ep; /* Point d'entrée détecté */
+ GBinRoutine *routine; /* Routine à associer à un pt. */
+
+ /* Point d'entrée principal éventuel */
+
+ ep = format->header.v1.entry;
+
+ if (ep != 0x0)
+ {
+ routine = try_to_demangle_routine("entry_point");
+ register_mclf_entry_point(format, ep, 0, routine);
+ }
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à compléter. *
+* *
+* Description : Charge en mémoire la liste humaine des symboles. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool load_mclf_symbols(GMCLFFormat *format)
+{
+ bool result; /* Bilan à retourner */
+
+ result = load_all_mclf_basic_entry_points(format);
+
+ return result;
+
+}