diff options
Diffstat (limited to 'src/format')
-rw-r--r-- | src/format/format.c | 19 | ||||
-rw-r--r-- | src/format/symbol.c | 32 | ||||
-rw-r--r-- | src/format/symbol.h | 4 |
3 files changed, 53 insertions, 2 deletions
diff --git a/src/format/format.c b/src/format/format.c index 2808b67..2093469 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -192,11 +192,28 @@ void g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol) format->symbols[format->symbols_count - 1] = symbol; - qsort(format->symbols, format->symbols_count, sizeof(GBinSymbol *), (__compar_fn_t)g_binary_symbol_cmp); + switch (g_binary_symbol_get_target_type(symbol)) + { + case STP_ROUTINE: + case STP_ENTRY_POINT: + + format->routines = (GBinRoutine **)realloc(format->routines, + ++format->routines_count * sizeof(GBinRoutine *)); + + format->routines[format->routines_count - 1] = g_binary_symbol_get_routine(symbol); + + qsort(format->routines, format->routines_count, + sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare); + break; + + default: + break; + + } } diff --git a/src/format/symbol.c b/src/format/symbol.c index d360591..c867b68 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -228,6 +228,7 @@ const char *g_binary_symbol_to_string(const GBinSymbol *symbol) { case STP_ROUTINE: case STP_ENTRY_POINT: + case STP_CODE_LABEL: result = g_binary_routine_get_name(symbol->extra.routine); break; @@ -292,6 +293,7 @@ const char *g_binary_symbol_get_label(const GBinSymbol *symbol) { case STP_ROUTINE: case STP_ENTRY_POINT: + case STP_CODE_LABEL: result = g_binary_routine_get_name(symbol->extra.routine); break; @@ -344,6 +346,7 @@ void g_binary_symbol_fix_range(GBinSymbol *symbol, const vmpa2t *full) case STP_ROUTINE: case STP_ENTRY_POINT: + case STP_CODE_LABEL: routine = g_binary_symbol_get_routine(symbol); @@ -392,6 +395,7 @@ const mrange_t *g_binary_symbol_get_range(const GBinSymbol *symbol) case STP_ROUTINE: case STP_ENTRY_POINT: + case STP_CODE_LABEL: result = g_binary_routine_get_range(symbol->extra.routine); break; @@ -431,6 +435,7 @@ void g_binary_symbol_set_alt_name(GBinSymbol *symbol, char *alt) * * * Paramètres : symbol = symbole à venir consulter. * * routine = prototype de la fonction représentée. * +* type = (nouveau) type du symbole attaché. * * * * Description : Attache la routine associée au symbole. * * * @@ -440,8 +445,13 @@ void g_binary_symbol_set_alt_name(GBinSymbol *symbol, char *alt) * * ******************************************************************************/ -void g_binary_symbol_attach_routine(GBinSymbol *symbol, GBinRoutine *routine) +void _g_binary_symbol_attach_routine(GBinSymbol *symbol, GBinRoutine *routine, SymbolType type) { + if (symbol->extra.routine != NULL) + g_object_unref(G_OBJECT(symbol->extra.routine)); + + symbol->type = type; + symbol->extra.routine = routine; } @@ -449,6 +459,26 @@ void g_binary_symbol_attach_routine(GBinSymbol *symbol, GBinRoutine *routine) /****************************************************************************** * * +* Paramètres : symbol = symbole à venir consulter. * +* routine = prototype de la fonction représentée. * +* * +* Description : Attache la routine associée au symbole. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_binary_symbol_attach_routine(GBinSymbol *symbol, GBinRoutine *routine) +{ + _g_binary_symbol_attach_routine(symbol, routine, symbol->type); + +} + + +/****************************************************************************** +* * * Paramètres : symbol = symbole à venir manipuler. * * instr = représentation du symbole associé. * * * diff --git a/src/format/symbol.h b/src/format/symbol.h index fafc55f..49cde56 100644 --- a/src/format/symbol.h +++ b/src/format/symbol.h @@ -39,6 +39,7 @@ typedef enum _SymbolType { STP_DATA, /* Données brutes */ STP_ROUTINE, /* Simple morceau de code */ + STP_CODE_LABEL, /* Renvoi au sein de code */ STP_OBJECT, /* Objet quelconque */ STP_FUNCTION, /* Simple morceau de code */ STP_ENTRY_POINT, /* Morceau de code en entrée */ @@ -99,6 +100,9 @@ const mrange_t *g_binary_symbol_get_range(const GBinSymbol *); void g_binary_symbol_set_alt_name(GBinSymbol *, char *); /* Attache la routine associée au symbole. */ +void _g_binary_symbol_attach_routine(GBinSymbol *, GBinRoutine *, SymbolType); + +/* Attache la routine associée au symbole. */ void g_binary_symbol_attach_routine(GBinSymbol *, GBinRoutine *); /* Attache l'instruction associée au symbole. */ |