summaryrefslogtreecommitdiff
path: root/src/format/program.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/program.c')
-rw-r--r--src/format/program.c266
1 files changed, 153 insertions, 113 deletions
diff --git a/src/format/program.c b/src/format/program.c
index d126236..3624496 100644
--- a/src/format/program.c
+++ b/src/format/program.c
@@ -1,8 +1,8 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * format.c - support des différents formats binaires
+ * program.c - support des différents formats de programmes
*
- * Copyright (C) 2009-2020 Cyrille Bagard
+ * Copyright (C) 2009-2024 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -21,40 +21,45 @@
*/
-#include "format.h"
+#include "program.h"
-#include <assert.h>
-#include <malloc.h>
-#include <string.h>
+//#include <assert.h>
+//#include <malloc.h>
+//#include <string.h>
-#include "format-int.h"
+#include "program-int.h"
+
+/*
#include "preload.h"
#include "../arch/processor.h"
#include "../common/sort.h"
#include "../core/demanglers.h"
#include "../plugins/pglist.h"
+*/
/* Initialise la classe des formats binaires génériques. */
-static void g_binary_format_class_init(GBinFormatClass *);
+static void g_program_format_class_init(GProgramFormatClass *);
/* Initialise une instance de format binaire générique. */
-static void g_binary_format_init(GBinFormat *);
+static void g_program_format_init(GProgramFormat *);
/* Supprime toutes les références externes. */
-static void g_binary_format_dispose(GBinFormat *);
+static void g_program_format_dispose(GProgramFormat *);
/* Procède à la libération totale de la mémoire. */
-static void g_binary_format_finalize(GBinFormat *);
+static void g_program_format_finalize(GProgramFormat *);
+
+#if 0
/* Charge les plages de couvertures depuis une mémoire tampon. */
-static bool g_binary_format_load_start_points(GBinFormat *, packed_buffer_t *);
+static bool g_program_format_load_start_points(GProgramFormat *, packed_buffer_t *);
/* Sauvegarde les points de départ enregistrés pour un format. */
-static bool g_binary_format_store_start_points(GBinFormat *, packed_buffer_t *);
+static bool g_program_format_store_start_points(GProgramFormat *, packed_buffer_t *);
@@ -62,13 +67,13 @@ static bool g_binary_format_store_start_points(GBinFormat *, packed_buffer_t *);
/* Retire un symbole de la collection du format binaire. */
-static void _g_binary_format_remove_symbol(GBinFormat *, size_t);
+static void _g_program_format_remove_symbol(GProgramFormat *, size_t);
/* Recherche le symbole associé à une adresse. */
-static bool _g_binary_format_find_symbol(const GBinFormat *, const vmpa2t *, __compar_fn_t, size_t *, GBinSymbol **);
+static bool _g_program_format_find_symbol(const GProgramFormat *, const vmpa2t *, __compar_fn_t, size_t *, GBinSymbol **);
/* Recherche un symbole particulier. */
-static bool __g_binary_format_find_symbol(const GBinFormat *, const void *, __compar_fn_t, size_t *, GBinSymbol **);
+static bool __g_program_format_find_symbol(const GProgramFormat *, const void *, __compar_fn_t, size_t *, GBinSymbol **);
@@ -76,10 +81,10 @@ static bool __g_binary_format_find_symbol(const GBinFormat *, const void *, __co
/* Charge les erreurs de chargement depuis une mémoire tampon. */
-static bool g_binary_format_load_errors(GBinFormat *, packed_buffer_t *);
+static bool g_program_format_load_errors(GProgramFormat *, packed_buffer_t *);
/* Sauvegarde les erreurs de chargement dans une mémoire tampon. */
-static bool g_binary_format_store_errors(GBinFormat *, packed_buffer_t *);
+static bool g_program_format_store_errors(GProgramFormat *, packed_buffer_t *);
@@ -87,17 +92,18 @@ static bool g_binary_format_store_errors(GBinFormat *, packed_buffer_t *);
/* Charge un format depuis une mémoire tampon. */
-static bool g_binary_format_load(GBinFormat *, GObjectStorage *, packed_buffer_t *);
+static bool g_program_format_load(GProgramFormat *, GObjectStorage *, packed_buffer_t *);
/* Sauvegarde un format dans une mémoire tampon. */
-static bool g_binary_format_store(GBinFormat *, GObjectStorage *, packed_buffer_t *);
+static bool g_program_format_store(GProgramFormat *, GObjectStorage *, packed_buffer_t *);
+#endif
/* Indique le type défini pour un format binaire générique. */
-G_DEFINE_TYPE(GBinFormat, g_binary_format, G_TYPE_KNOWN_FORMAT);
+G_DEFINE_TYPE(GProgramFormat, g_program_format, G_TYPE_KNOWN_FORMAT);
/******************************************************************************
@@ -112,25 +118,27 @@ G_DEFINE_TYPE(GBinFormat, g_binary_format, G_TYPE_KNOWN_FORMAT);
* *
******************************************************************************/
-static void g_binary_format_class_init(GBinFormatClass *klass)
+static void g_program_format_class_init(GProgramFormatClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
- GKnownFormatClass *known; /* Version de classe parente */
+ //GKnownFormatClass *known; /* Version de classe parente */
object = G_OBJECT_CLASS(klass);
- object->dispose = (GObjectFinalizeFunc/* ! */)g_binary_format_dispose;
- object->finalize = (GObjectFinalizeFunc)g_binary_format_finalize;
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_program_format_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_program_format_finalize;
+
+#if 0
known = G_KNOWN_FORMAT_CLASS(klass);
- known->load = (load_known_fc)g_binary_format_load;
- known->store = (load_known_fc)g_binary_format_store;
+ known->load = (load_known_fc)g_program_format_load;
+ known->store = (load_known_fc)g_program_format_store;
g_signal_new("symbol-added",
G_TYPE_BIN_FORMAT,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GBinFormatClass, symbol_added),
+ G_STRUCT_OFFSET(GProgramFormatClass, symbol_added),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
@@ -138,11 +146,13 @@ static void g_binary_format_class_init(GBinFormatClass *klass)
g_signal_new("symbol-removed",
G_TYPE_BIN_FORMAT,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GBinFormatClass, symbol_removed),
+ G_STRUCT_OFFSET(GProgramFormatClass, symbol_removed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
+#endif
+
}
@@ -158,8 +168,10 @@ static void g_binary_format_class_init(GBinFormatClass *klass)
* *
******************************************************************************/
-static void g_binary_format_init(GBinFormat *format)
+static void g_program_format_init(GProgramFormat *format)
{
+
+#if 0
fmt_extra_data_t *extra; /* Données insérées à modifier */
extra = GET_BIN_FORMAT_EXTRA(format);
@@ -184,6 +196,8 @@ static void g_binary_format_init(GBinFormat *format)
g_atomic_int_set(&format->error_locked, 0);
#endif
+#endif
+
}
@@ -199,8 +213,10 @@ static void g_binary_format_init(GBinFormat *format)
* *
******************************************************************************/
-static void g_binary_format_dispose(GBinFormat *format)
+static void g_program_format_dispose(GProgramFormat *format)
{
+#if 0
+
size_t i; /* Boucle de parcours */
g_rw_lock_clear(&format->pt_lock);
@@ -216,7 +232,10 @@ static void g_binary_format_dispose(GBinFormat *format)
g_mutex_clear(&format->error_mutex);
- G_OBJECT_CLASS(g_binary_format_parent_class)->dispose(G_OBJECT(format));
+#endif
+
+
+ G_OBJECT_CLASS(g_program_format_parent_class)->dispose(G_OBJECT(format));
}
@@ -233,8 +252,10 @@ static void g_binary_format_dispose(GBinFormat *format)
* *
******************************************************************************/
-static void g_binary_format_finalize(GBinFormat *format)
+static void g_program_format_finalize(GProgramFormat *format)
{
+#if 0
+
DisassPriorityLevel i; /* Boucle de parcours #1 */
size_t k; /* Boucle de parcours #2 */
@@ -255,11 +276,21 @@ static void g_binary_format_finalize(GBinFormat *format)
}
- G_OBJECT_CLASS(g_binary_format_parent_class)->finalize(G_OBJECT(format));
+#endif
+
+
+
+ G_OBJECT_CLASS(g_program_format_parent_class)->finalize(G_OBJECT(format));
}
+
+
+
+
+#if 0
+
/******************************************************************************
* *
* Paramètres : format = format à venir modifier. *
@@ -273,7 +304,7 @@ static void g_binary_format_finalize(GBinFormat *format)
* *
******************************************************************************/
-bool g_binary_format_set_flag(GBinFormat *format, FormatFlag flag)
+bool g_program_format_set_flag(GProgramFormat *format, FormatFlag flag)
{
bool result; /* Bilan à retourner */
fmt_extra_data_t *extra; /* Données insérées à modifier */
@@ -306,7 +337,7 @@ bool g_binary_format_set_flag(GBinFormat *format, FormatFlag flag)
* *
******************************************************************************/
-bool g_binary_format_unset_flag(GBinFormat *format, FormatFlag flag)
+bool g_program_format_unset_flag(GProgramFormat *format, FormatFlag flag)
{
bool result; /* Bilan à retourner */
fmt_extra_data_t *extra; /* Données insérées à modifier */
@@ -339,7 +370,7 @@ bool g_binary_format_unset_flag(GBinFormat *format, FormatFlag flag)
* *
******************************************************************************/
-bool g_binary_format_has_flag(const GBinFormat *format, FormatFlag flag)
+bool g_program_format_has_flag(const GProgramFormat *format, FormatFlag flag)
{
bool result; /* Bilan à retourner */
fmt_extra_data_t *extra; /* Données insérées à modifier */
@@ -369,7 +400,7 @@ bool g_binary_format_has_flag(const GBinFormat *format, FormatFlag flag)
* *
******************************************************************************/
-FormatFlag g_binary_format_get_flags(const GBinFormat *format)
+FormatFlag g_program_format_get_flags(const GProgramFormat *format)
{
FormatFlag result; /* Fanions à retourner */
fmt_extra_data_t *extra; /* Données insérées à modifier */
@@ -386,6 +417,8 @@ FormatFlag g_binary_format_get_flags(const GBinFormat *format)
}
+#endif
+
/******************************************************************************
* *
@@ -399,17 +432,22 @@ FormatFlag g_binary_format_get_flags(const GBinFormat *format)
* *
******************************************************************************/
-SourceEndian g_binary_format_get_endianness(const GBinFormat *format)
+SourceEndian g_program_format_get_endianness(const GProgramFormat *format)
{
SourceEndian result; /* Boutisme à retourner */
+ GProgramFormatClass *class; /* Classe de l'instance */
+
+ class = G_PROGRAM_FORMAT_GET_CLASS(format);
- result = G_BIN_FORMAT_GET_CLASS(format)->get_endian(format);
+ result = class->get_endian(format);
return result;
}
+#if 0
+
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à compléter. *
@@ -424,7 +462,7 @@ SourceEndian g_binary_format_get_endianness(const GBinFormat *format)
* *
******************************************************************************/
-void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, DisassPriorityLevel level)
+void g_program_format_register_code_point(GProgramFormat *format, virt_t pt, DisassPriorityLevel level)
{
assert(level < DPL_COUNT);
@@ -459,7 +497,7 @@ void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, DisassPr
* *
******************************************************************************/
-static bool g_binary_format_load_start_points(GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_program_format_load_start_points(GProgramFormat *format, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
DisassPriorityLevel i; /* Boucle de parcours #1 */
@@ -512,7 +550,7 @@ static bool g_binary_format_load_start_points(GBinFormat *format, packed_buffer_
* *
******************************************************************************/
-static bool g_binary_format_store_start_points(GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_program_format_store_start_points(GProgramFormat *format, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
DisassPriorityLevel i; /* Boucle de parcours #1 */
@@ -555,7 +593,7 @@ static bool g_binary_format_store_start_points(GBinFormat *format, packed_buffer
* *
******************************************************************************/
-void g_binary_format_preload_disassembling_context(GBinFormat *format, GProcContext *ctx, GtkStatusStack *status)
+void g_program_format_preload_disassembling_context(GProgramFormat *format, GProcContext *ctx, GtkStatusStack *status)
{
g_preload_info_copy(format->info, G_PRELOAD_INFO(ctx));
@@ -576,7 +614,7 @@ void g_binary_format_preload_disassembling_context(GBinFormat *format, GProcCont
* *
******************************************************************************/
-void g_binary_format_activate_disassembling_context(GBinFormat *format, GProcContext *ctx, GtkStatusStack *status)
+void g_program_format_activate_disassembling_context(GProgramFormat *format, GProcContext *ctx, GtkStatusStack *status)
{
DisassPriorityLevel i; /* Boucle de parcours #1 */
size_t k; /* Boucle de parcours #2 */
@@ -610,7 +648,7 @@ void g_binary_format_activate_disassembling_context(GBinFormat *format, GProcCon
* *
******************************************************************************/
-GCompDemangler *g_binary_format_get_demangler(const GBinFormat *format)
+GCompDemangler *g_program_format_get_demangler(const GProgramFormat *format)
{
GCompDemangler *result; /* Décodeur à retourner */
@@ -637,7 +675,7 @@ GCompDemangler *g_binary_format_get_demangler(const GBinFormat *format)
* *
******************************************************************************/
-GDataType *g_binary_format_decode_type(const GBinFormat *format, const char *desc)
+GDataType *g_program_format_decode_type(const GProgramFormat *format, const char *desc)
{
GDataType *result; /* Construction à remonter */
GCompDemangler *demangler; /* Accès plus lisible */
@@ -667,7 +705,7 @@ GDataType *g_binary_format_decode_type(const GBinFormat *format, const char *des
* *
******************************************************************************/
-GBinRoutine *g_binary_format_decode_routine(const GBinFormat *format, const char *desc)
+GBinRoutine *g_program_format_decode_routine(const GProgramFormat *format, const char *desc)
{
GBinRoutine *result; /* Construction à remonter */
GCompDemangler *demangler; /* Accès plus lisible */
@@ -708,7 +746,7 @@ GBinRoutine *g_binary_format_decode_routine(const GBinFormat *format, const char
* *
******************************************************************************/
-void g_binary_format_lock_unlock_symbols_rd(GBinFormat *format, bool state)
+void g_program_format_lock_unlock_symbols_rd(GProgramFormat *format, bool state)
{
#ifndef NDEBUG
gint test; /* Test de valeur courante */
@@ -746,7 +784,7 @@ void g_binary_format_lock_unlock_symbols_rd(GBinFormat *format, bool state)
* *
******************************************************************************/
-void g_binary_format_lock_unlock_symbols_wr(GBinFormat *format, bool state)
+void g_program_format_lock_unlock_symbols_wr(GProgramFormat *format, bool state)
{
if (state)
{
@@ -778,7 +816,7 @@ void g_binary_format_lock_unlock_symbols_wr(GBinFormat *format, bool state)
* *
******************************************************************************/
#ifndef NDEBUG
-void g_binary_format_check_for_symbols_lock(const GBinFormat *format)
+void g_program_format_check_for_symbols_lock(const GProgramFormat *format)
{
assert(g_atomic_int_get(&format->sym_locked) > 0);
@@ -798,7 +836,7 @@ void g_binary_format_check_for_symbols_lock(const GBinFormat *format)
* *
******************************************************************************/
-unsigned int g_binary_format_get_symbols_stamp(const GBinFormat *format)
+unsigned int g_program_format_get_symbols_stamp(const GProgramFormat *format)
{
return format->sym_stamp;
@@ -817,7 +855,7 @@ unsigned int g_binary_format_get_symbols_stamp(const GBinFormat *format)
* *
******************************************************************************/
-size_t g_binary_format_count_symbols(const GBinFormat *format)
+size_t g_program_format_count_symbols(const GProgramFormat *format)
{
assert(g_atomic_int_get(&format->sym_locked) > 0);
@@ -839,7 +877,7 @@ size_t g_binary_format_count_symbols(const GBinFormat *format)
* *
******************************************************************************/
-GBinSymbol *g_binary_format_get_symbol(const GBinFormat *format, size_t index)
+GBinSymbol *g_program_format_get_symbol(const GProgramFormat *format, size_t index)
{
GBinSymbol *result; /* Symbole à retourner */
@@ -877,7 +915,7 @@ GBinSymbol *g_binary_format_get_symbol(const GBinFormat *format, size_t index)
* *
******************************************************************************/
-bool g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol)
+bool g_program_format_add_symbol(GProgramFormat *format, GBinSymbol *symbol)
{
bool result; /* Statut d'ajout à retourner */
#ifndef NDEBUG
@@ -887,7 +925,7 @@ bool g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol)
size_t index; /* Indice du point d'insertion */
/**
- * Pour que les fonctions de recherche basées sur _g_binary_format_find_symbol()
+ * Pour que les fonctions de recherche basées sur _g_program_format_find_symbol()
* fassent bien leur office, il faut que les symboles soient triés.
*
* Cependant, les localisations à satisfaire lors d'une recherche recontrent
@@ -912,7 +950,7 @@ bool g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol)
assert(has_phys_addr(addr) || g_binary_symbol_get_status(symbol) == SSS_DYNAMIC);
#endif
- g_binary_format_lock_unlock_symbols_wr(format, true);
+ g_program_format_lock_unlock_symbols_wr(format, true);
/**
* Avec tous les traitements parallèles, il est possible que plusieurs chemins d'exécution
@@ -939,7 +977,7 @@ bool g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol)
else
g_object_unref(G_OBJECT(symbol));
- g_binary_format_lock_unlock_symbols_wr(format, false);
+ g_program_format_lock_unlock_symbols_wr(format, false);
if (result)
g_signal_emit_by_name(format, "symbol-added", symbol);
@@ -963,7 +1001,7 @@ bool g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol)
* *
******************************************************************************/
-bool g_binary_format_add_symbols(GBinFormat *format, GBinSymbol **symbols, size_t count)
+bool g_program_format_add_symbols(GProgramFormat *format, GBinSymbol **symbols, size_t count)
{
bool result; /* Statut d'ajout à retourner */
#ifndef NDEBUG
@@ -977,7 +1015,7 @@ bool g_binary_format_add_symbols(GBinFormat *format, GBinSymbol **symbols, size_
size_t index; /* Indice du point d'insertion */
/**
- * Pour que les fonctions de recherche basées sur _g_binary_format_find_symbol()
+ * Pour que les fonctions de recherche basées sur _g_program_format_find_symbol()
* fassent bien leur office, il faut que les symboles soient triés.
*
* Cependant, les localisations à satisfaire lors d'une recherche recontrent
@@ -1014,7 +1052,7 @@ bool g_binary_format_add_symbols(GBinFormat *format, GBinSymbol **symbols, size_
}
#endif
- g_binary_format_lock_unlock_symbols_wr(format, true);
+ g_program_format_lock_unlock_symbols_wr(format, true);
/**
* Avec tous les traitements parallèles, il est possible que plusieurs chemins d'exécution
@@ -1042,7 +1080,7 @@ bool g_binary_format_add_symbols(GBinFormat *format, GBinSymbol **symbols, size_
}
- g_binary_format_lock_unlock_symbols_wr(format, false);
+ g_program_format_lock_unlock_symbols_wr(format, false);
if (result)
for (i = 0; i < count; i++)
@@ -1066,7 +1104,7 @@ bool g_binary_format_add_symbols(GBinFormat *format, GBinSymbol **symbols, size_
* *
******************************************************************************/
-static void _g_binary_format_remove_symbol(GBinFormat *format, size_t index)
+static void _g_program_format_remove_symbol(GProgramFormat *format, size_t index)
{
assert(g_atomic_int_get(&format->sym_locked) == 1);
@@ -1096,22 +1134,22 @@ static void _g_binary_format_remove_symbol(GBinFormat *format, size_t index)
* *
******************************************************************************/
-void g_binary_format_remove_symbol(GBinFormat *format, GBinSymbol *symbol)
+void g_program_format_remove_symbol(GProgramFormat *format, GBinSymbol *symbol)
{
bool found; /* Jeton de présence */
size_t index; /* Indice du point de retrait */
g_object_ref(G_OBJECT(symbol));
- g_binary_format_lock_unlock_symbols_wr(format, true);
+ g_program_format_lock_unlock_symbols_wr(format, true);
found = bsearch_index(&symbol, format->symbols, format->sym_count,
sizeof(GBinSymbol *), (__compar_fn_t)g_binary_symbol_cmp, &index);
if (found)
- _g_binary_format_remove_symbol(format, index);
+ _g_program_format_remove_symbol(format, index);
- g_binary_format_lock_unlock_symbols_wr(format, false);
+ g_program_format_lock_unlock_symbols_wr(format, false);
if (found)
g_signal_emit_by_name(format, "symbol-removed", symbol);
@@ -1135,7 +1173,7 @@ void g_binary_format_remove_symbol(GBinFormat *format, GBinSymbol *symbol)
* *
******************************************************************************/
-bool g_binary_format_find_symbol_by_label(GBinFormat *format, const char *label, GBinSymbol **symbol)
+bool g_program_format_find_symbol_by_label(GProgramFormat *format, const char *label, GBinSymbol **symbol)
{
bool result; /* Bilan à retourner */
size_t i; /* Boucle de parcours */
@@ -1143,7 +1181,7 @@ bool g_binary_format_find_symbol_by_label(GBinFormat *format, const char *label,
result = false;
- g_binary_format_lock_symbols_rd(format);
+ g_program_format_lock_symbols_rd(format);
for (i = 0; i < format->sym_count && !result; i++)
{
@@ -1163,7 +1201,7 @@ bool g_binary_format_find_symbol_by_label(GBinFormat *format, const char *label,
}
- g_binary_format_unlock_symbols_rd(format);
+ g_program_format_unlock_symbols_rd(format);
return result;
@@ -1186,16 +1224,16 @@ bool g_binary_format_find_symbol_by_label(GBinFormat *format, const char *label,
* *
******************************************************************************/
-static bool _g_binary_format_find_symbol(const GBinFormat *format, const vmpa2t *addr, __compar_fn_t fn, size_t *index, GBinSymbol **symbol)
+static bool _g_program_format_find_symbol(const GProgramFormat *format, const vmpa2t *addr, __compar_fn_t fn, size_t *index, GBinSymbol **symbol)
{
/**
* Pour ce qui est des justifications quant à la vérification suivante,
- * se référer aux commentaires placés dans g_binary_format_add_symbol().
+ * se référer aux commentaires placés dans g_program_format_add_symbol().
*/
assert(has_phys_addr(addr));
- return __g_binary_format_find_symbol(format, addr, fn, index, symbol);
+ return __g_program_format_find_symbol(format, addr, fn, index, symbol);
}
@@ -1216,7 +1254,7 @@ static bool _g_binary_format_find_symbol(const GBinFormat *format, const vmpa2t
* *
******************************************************************************/
-static bool __g_binary_format_find_symbol(const GBinFormat *format, const void *key, __compar_fn_t fn, size_t *index, GBinSymbol **symbol)
+static bool __g_program_format_find_symbol(const GProgramFormat *format, const void *key, __compar_fn_t fn, size_t *index, GBinSymbol **symbol)
{
bool result; /* Bilan à retourner */
void *found; /* Résultat de recherches */
@@ -1268,7 +1306,7 @@ static bool __g_binary_format_find_symbol(const GBinFormat *format, const void *
* *
******************************************************************************/
-bool g_binary_format_find_symbol_index_at(GBinFormat *format, const vmpa2t *addr, size_t *index)
+bool g_program_format_find_symbol_index_at(GProgramFormat *format, const vmpa2t *addr, size_t *index)
{
bool result; /* Bilan à retourner */
@@ -1282,11 +1320,11 @@ bool g_binary_format_find_symbol_index_at(GBinFormat *format, const vmpa2t *addr
}
- g_binary_format_lock_symbols_rd(format);
+ g_program_format_lock_symbols_rd(format);
- result = _g_binary_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, index, NULL);
+ result = _g_program_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, index, NULL);
- g_binary_format_unlock_symbols_rd(format);
+ g_program_format_unlock_symbols_rd(format);
return result;
@@ -1307,7 +1345,7 @@ bool g_binary_format_find_symbol_index_at(GBinFormat *format, const vmpa2t *addr
* *
******************************************************************************/
-bool g_binary_format_find_symbol_at(GBinFormat *format, const vmpa2t *addr, GBinSymbol **symbol)
+bool g_program_format_find_symbol_at(GProgramFormat *format, const vmpa2t *addr, GBinSymbol **symbol)
{
bool result; /* Bilan à retourner */
@@ -1321,11 +1359,11 @@ bool g_binary_format_find_symbol_at(GBinFormat *format, const vmpa2t *addr, GBin
}
- g_binary_format_lock_symbols_rd(format);
+ g_program_format_lock_symbols_rd(format);
- result = _g_binary_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, NULL, symbol);
+ result = _g_program_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, NULL, symbol);
- g_binary_format_unlock_symbols_rd(format);
+ g_program_format_unlock_symbols_rd(format);
return result;
@@ -1346,7 +1384,7 @@ bool g_binary_format_find_symbol_at(GBinFormat *format, const vmpa2t *addr, GBin
* *
******************************************************************************/
-bool g_binary_format_find_symbol_for(GBinFormat *format, const vmpa2t *addr, GBinSymbol **symbol)
+bool g_program_format_find_symbol_for(GProgramFormat *format, const vmpa2t *addr, GBinSymbol **symbol)
{
bool result; /* Bilan à retourner */
@@ -1360,11 +1398,11 @@ bool g_binary_format_find_symbol_for(GBinFormat *format, const vmpa2t *addr, GBi
}
- g_binary_format_lock_symbols_rd(format);
+ g_program_format_lock_symbols_rd(format);
- result = _g_binary_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, NULL, symbol);
+ result = _g_program_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, NULL, symbol);
- g_binary_format_unlock_symbols_rd(format);
+ g_program_format_unlock_symbols_rd(format);
return result;
@@ -1385,7 +1423,7 @@ bool g_binary_format_find_symbol_for(GBinFormat *format, const vmpa2t *addr, GBi
* *
******************************************************************************/
-bool g_binary_format_find_next_symbol_at(GBinFormat *format, const vmpa2t *addr, GBinSymbol **symbol)
+bool g_program_format_find_next_symbol_at(GProgramFormat *format, const vmpa2t *addr, GBinSymbol **symbol)
{
bool result; /* Bilan à retourner */
size_t index; /* Indice à considérer */
@@ -1400,9 +1438,9 @@ bool g_binary_format_find_next_symbol_at(GBinFormat *format, const vmpa2t *addr,
}
- g_binary_format_lock_symbols_rd(format);
+ g_program_format_lock_symbols_rd(format);
- result = _g_binary_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, &index, NULL);
+ result = _g_program_format_find_symbol(format, addr, (__compar_fn_t)find_symbol, &index, NULL);
if (result && (index + 1) < format->sym_count)
{
@@ -1417,7 +1455,7 @@ bool g_binary_format_find_next_symbol_at(GBinFormat *format, const vmpa2t *addr,
result = false;
}
- g_binary_format_unlock_symbols_rd(format);
+ g_program_format_unlock_symbols_rd(format);
return result;
@@ -1438,7 +1476,7 @@ bool g_binary_format_find_next_symbol_at(GBinFormat *format, const vmpa2t *addr,
* *
******************************************************************************/
-bool g_binary_format_find_first_symbol_inside(GBinFormat *format, const mrange_t *range, size_t *index)
+bool g_program_format_find_first_symbol_inside(GProgramFormat *format, const mrange_t *range, size_t *index)
{
bool result; /* Bilan à retourner */
const GBinSymbol *prev; /* Symbole précédent */
@@ -1463,7 +1501,7 @@ bool g_binary_format_find_first_symbol_inside(GBinFormat *format, const mrange_t
g_rw_lock_reader_lock(&format->syms_lock);
- result = __g_binary_format_find_symbol(format, range, (__compar_fn_t)find_symbol, index, NULL);
+ result = __g_program_format_find_symbol(format, range, (__compar_fn_t)find_symbol, index, NULL);
if (result)
while (*index > 0)
@@ -1502,15 +1540,15 @@ bool g_binary_format_find_first_symbol_inside(GBinFormat *format, const mrange_t
* *
******************************************************************************/
-bool g_binary_format_resolve_symbol(GBinFormat *format, const vmpa2t *addr, bool strict, GBinSymbol **symbol, phys_t *diff)
+bool g_program_format_resolve_symbol(GProgramFormat *format, const vmpa2t *addr, bool strict, GBinSymbol **symbol, phys_t *diff)
{
bool result; /* Bilan à retourner */
const mrange_t *range; /* Espace mémoire parcouru */
if (strict)
- result = g_binary_format_find_symbol_at(format, addr, symbol);
+ result = g_program_format_find_symbol_at(format, addr, symbol);
else
- result = g_binary_format_find_symbol_for(format, addr, symbol);
+ result = g_program_format_find_symbol_for(format, addr, symbol);
if (result)
{
@@ -1548,7 +1586,7 @@ bool g_binary_format_resolve_symbol(GBinFormat *format, const vmpa2t *addr, bool
* *
******************************************************************************/
-void g_binary_format_lock_unlock_errors(GBinFormat *format, bool state)
+void g_program_format_lock_unlock_errors(GProgramFormat *format, bool state)
{
if (state)
{
@@ -1584,11 +1622,11 @@ void g_binary_format_lock_unlock_errors(GBinFormat *format, bool state)
* *
******************************************************************************/
-void g_binary_format_add_error(GBinFormat *format, BinaryFormatError type, const vmpa2t *addr, const char *desc)
+void g_program_format_add_error(GProgramFormat *format, BinaryFormatError type, const vmpa2t *addr, const char *desc)
{
fmt_error *error; /* Raccourci de confort */
- g_binary_format_lock_errors(format);
+ g_program_format_lock_errors(format);
format->errors = realloc(format->errors, ++format->error_count * sizeof(fmt_error));
@@ -1603,7 +1641,7 @@ void g_binary_format_add_error(GBinFormat *format, BinaryFormatError type, const
else
error->desc = NULL;
- g_binary_format_unlock_errors(format);
+ g_program_format_unlock_errors(format);
}
@@ -1620,7 +1658,7 @@ void g_binary_format_add_error(GBinFormat *format, BinaryFormatError type, const
* *
******************************************************************************/
-size_t g_binary_format_count_errors(GBinFormat *format)
+size_t g_program_format_count_errors(GProgramFormat *format)
{
size_t result; /* Quantité à retourner */
@@ -1649,7 +1687,7 @@ size_t g_binary_format_count_errors(GBinFormat *format)
* *
******************************************************************************/
-bool g_binary_format_get_error(GBinFormat *format, size_t index, BinaryFormatError *type, vmpa2t *addr, char **desc)
+bool g_program_format_get_error(GProgramFormat *format, size_t index, BinaryFormatError *type, vmpa2t *addr, char **desc)
{
bool result; /* Bilan à retourner */
fmt_error *error; /* Raccourci de confort */
@@ -1693,7 +1731,7 @@ bool g_binary_format_get_error(GBinFormat *format, size_t index, BinaryFormatErr
* *
******************************************************************************/
-static bool g_binary_format_load_errors(GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_program_format_load_errors(GProgramFormat *format, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
uleb128_t value; /* Valeur ULEB128 à charger */
@@ -1701,7 +1739,7 @@ static bool g_binary_format_load_errors(GBinFormat *format, packed_buffer_t *pbu
fmt_error *error; /* Raccourci de confort */
rle_string str; /* Chaîne à charger */
- g_binary_format_lock_errors(format);
+ g_program_format_lock_errors(format);
result = unpack_uleb128(&value, pbuf);
if (!result) goto exit;
@@ -1736,7 +1774,7 @@ static bool g_binary_format_load_errors(GBinFormat *format, packed_buffer_t *pbu
exit:
- g_binary_format_unlock_errors(format);
+ g_program_format_unlock_errors(format);
return result;
@@ -1756,14 +1794,14 @@ static bool g_binary_format_load_errors(GBinFormat *format, packed_buffer_t *pbu
* *
******************************************************************************/
-static bool g_binary_format_store_errors(GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_program_format_store_errors(GProgramFormat *format, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
size_t i; /* Boucle de parcours */
fmt_error *error; /* Raccourci de confort */
rle_string str; /* Chaîne à conserver */
- g_binary_format_lock_errors(format);
+ g_program_format_lock_errors(format);
result = pack_uleb128((uleb128_t []){ format->error_count }, pbuf);
@@ -1785,7 +1823,7 @@ static bool g_binary_format_store_errors(GBinFormat *format, packed_buffer_t *pb
}
- g_binary_format_unlock_errors(format);
+ g_program_format_unlock_errors(format);
return result;
@@ -1812,7 +1850,7 @@ static bool g_binary_format_store_errors(GBinFormat *format, packed_buffer_t *pb
* *
******************************************************************************/
-static bool g_binary_format_load(GBinFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
+static bool g_program_format_load(GProgramFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
fmt_extra_data_t *extra; /* Données insérées à consulter*/
@@ -1831,7 +1869,7 @@ static bool g_binary_format_load(GBinFormat *format, GObjectStorage *storage, pa
UNLOCK_GOBJECT_EXTRA(extra);
if (result)
- result = g_binary_format_load_start_points(format, pbuf);
+ result = g_program_format_load_start_points(format, pbuf);
if (result)
{
@@ -1857,7 +1895,7 @@ static bool g_binary_format_load(GBinFormat *format, GObjectStorage *storage, pa
if (result)
- result = g_binary_format_load_errors(format, pbuf);
+ result = g_program_format_load_errors(format, pbuf);
return result;
@@ -1878,7 +1916,7 @@ static bool g_binary_format_load(GBinFormat *format, GObjectStorage *storage, pa
* *
******************************************************************************/
-static bool g_binary_format_store(GBinFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
+static bool g_program_format_store(GProgramFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
fmt_extra_data_t *extra; /* Données insérées à consulter*/
@@ -1894,7 +1932,7 @@ static bool g_binary_format_store(GBinFormat *format, GObjectStorage *storage, p
UNLOCK_GOBJECT_EXTRA(extra);
if (result)
- result = g_binary_format_store_start_points(format, pbuf);
+ result = g_program_format_store_start_points(format, pbuf);
if (result)
{
@@ -1913,8 +1951,10 @@ static bool g_binary_format_store(GBinFormat *format, GObjectStorage *storage, p
if (result)
- result = g_binary_format_store_errors(format, pbuf);
+ result = g_program_format_store_errors(format, pbuf);
return result;
}
+
+#endif