diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-05-16 21:56:55 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-05-16 21:56:55 (GMT) |
commit | 4691a434a34a19317156a761967f719e408b73bb (patch) | |
tree | 1daaf5be5d4a9f52d492380c2862580129d2ad12 /src/analysis | |
parent | 1996274a43883aa58e8c565f7698bc7c338a9ce0 (diff) |
Merged routines into symbols.
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/disass/area.c | 21 | ||||
-rw-r--r-- | src/analysis/disass/limit.c | 8 | ||||
-rw-r--r-- | src/analysis/disass/limit.h | 4 | ||||
-rw-r--r-- | src/analysis/disass/routines.c | 20 | ||||
-rw-r--r-- | src/analysis/disass/routines.h | 1 | ||||
-rw-r--r-- | src/analysis/routine.c | 120 | ||||
-rw-r--r-- | src/analysis/routine.h | 6 |
7 files changed, 68 insertions, 112 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index 352069c..e19a4c0 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -32,7 +32,8 @@ #include <i18n.h> -#include "../../analysis/contents/restricted.h" +#include "../routine.h" +#include "../contents/restricted.h" #include "../../arch/raw.h" #include "../../common/bits.h" #include "../../common/sort.h" @@ -654,27 +655,25 @@ static void update_address_as_routine(GBinFormat *format, const vmpa2t *addr) if (!found || (found && wrong_type)) { + if (found) + g_binary_format_remove_symbol(format, symbol); + init_mrange(&range, addr, 0); vmpa2_virt_to_string(addr, MDS_UNDEFINED, loc, NULL); snprintf(name, sizeof(name), "sub_%s", loc + 2); routine = g_binary_routine_new(); - g_binary_routine_set_name(routine, strdup(name)); + symbol = G_BIN_SYMBOL(routine); - g_binary_routine_set_range(routine, &range); + g_binary_routine_set_name(routine, strdup(name)); + g_binary_symbol_set_range(symbol, &range); - if (!found) - { - symbol = g_binary_symbol_new(STP_ROUTINE); - g_binary_symbol_attach_routine(symbol, routine); - g_binary_format_add_symbol(format, symbol); - } - else _g_binary_symbol_attach_routine(symbol, routine, STP_ROUTINE); + g_binary_format_add_symbol(format, symbol); } - if (found) + else g_object_unref(G_OBJECT(symbol)); } diff --git a/src/analysis/disass/limit.c b/src/analysis/disass/limit.c index df9f23c..bcc594f 100644 --- a/src/analysis/disass/limit.c +++ b/src/analysis/disass/limit.c @@ -27,7 +27,7 @@ /****************************************************************************** * * -* Paramètres : routine = routine dont les frontières sont à fixer. * +* Paramètres : symbol = routine dont les frontières sont à fixer. * * next = adresse du prochain symbole présent. * * proc = ensemble d'instructions désassemblées. * * portions = ensemble de couches binaires bornées. * @@ -40,7 +40,7 @@ * * ******************************************************************************/ -void compute_routine_limit(GBinRoutine *routine, const vmpa2t *next, GArchProcessor *proc, GBinPortion *portions) +void compute_routine_limit(GBinSymbol *symbol, const vmpa2t *next, GArchProcessor *proc, GBinPortion *portions) { const mrange_t *range; /* Emplacement courant */ vmpa2t addr; /* Adresse à conserver */ @@ -49,7 +49,7 @@ void compute_routine_limit(GBinRoutine *routine, const vmpa2t *next, GArchProces GBinPortion *portion; /* Conteneur avec limites */ mrange_t new; /* Nouvel emplacement taillé */ - range = g_binary_routine_get_range(routine); + range = g_binary_symbol_get_range(symbol); if (get_mrange_length(range) > 0) goto crl_skip; copy_vmpa(&addr, get_mrange_addr(range)); @@ -91,7 +91,7 @@ void compute_routine_limit(GBinRoutine *routine, const vmpa2t *next, GArchProces init_mrange(&new, &addr, diff); - g_binary_routine_set_range(routine, &new); + g_binary_symbol_set_range(symbol, &new); crl_skip: diff --git a/src/analysis/disass/limit.h b/src/analysis/disass/limit.h index c26b450..ce76a43 100644 --- a/src/analysis/disass/limit.h +++ b/src/analysis/disass/limit.h @@ -25,14 +25,14 @@ #define _ANALYSIS_DISASS_LIMIT_H -#include "../routine.h" #include "../../arch/processor.h" #include "../../format/executable.h" +#include "../../format/symbol.h" /* S'assure qu'une routine est bien bornée. */ -void compute_routine_limit(GBinRoutine *, const vmpa2t *, GArchProcessor *, GBinPortion *); +void compute_routine_limit(GBinSymbol *, const vmpa2t *, GArchProcessor *, GBinPortion *); diff --git a/src/analysis/disass/routines.c b/src/analysis/disass/routines.c index 1150f08..5d6dc42 100644 --- a/src/analysis/disass/routines.c +++ b/src/analysis/disass/routines.c @@ -231,14 +231,16 @@ GRoutinesStudy *g_routines_study_new(GArchProcessor *proc, GBinPortion *portions static void g_routines_study_process(GRoutinesStudy *study, GtkStatusStack *status) { size_t i; /* Boucle de parcours */ - GBinRoutine *routine; /* Routine à traiter */ + GBinSymbol *symbol; /* Commodité d'accès */ + SymbolType type; /* Type de symbole rencontré */ for (i = study->begin; i < study->end; i++) { - routine = g_binary_symbol_get_routine(study->symbols[i]); + symbol = study->symbols[i]; + type = g_binary_symbol_get_target_type(symbol); - if (routine != NULL) - study->fallback(study, routine, i); + if (type == STP_ROUTINE || type == STP_ENTRY_POINT) + study->fallback(study, G_BIN_ROUTINE(symbol), i); gtk_status_stack_update_activity_value(status, study->id, 1); @@ -263,9 +265,12 @@ static void g_routines_study_process(GRoutinesStudy *study, GtkStatusStack *stat void g_routines_study_compute_limits(GRoutinesStudy *study, GBinRoutine *routine, size_t index) { + GBinSymbol *symbol; /* Version alternative */ const mrange_t *range; /* Zone du symbole suivant */ const vmpa2t *next; /* Début de la zone suivante */ + symbol = G_BIN_SYMBOL(routine); + if ((index + 1) < study->count) { range = g_binary_symbol_get_range(study->symbols[index + 1]); @@ -275,7 +280,7 @@ void g_routines_study_compute_limits(GRoutinesStudy *study, GBinRoutine *routine else next = NULL; - compute_routine_limit(routine, next, study->proc, study->portions); + compute_routine_limit(symbol, next, study->proc, study->portions); } @@ -296,6 +301,7 @@ void g_routines_study_compute_limits(GRoutinesStudy *study, GBinRoutine *routine void g_routines_study_handle_blocks(GRoutinesStudy *study, GBinRoutine *routine, size_t index) { + GBinSymbol *symbol; /* Version alternative */ const mrange_t *range; /* Couverture d'une routine */ const vmpa2t *start; /* Adresse de départ */ const instr_coverage *coverage; /* Instructions couvertes */ @@ -304,7 +310,9 @@ void g_routines_study_handle_blocks(GRoutinesStudy *study, GBinRoutine *routine, /* Préparatifs communs */ - range = g_binary_routine_get_range(routine); + symbol = G_BIN_SYMBOL(routine); + + range = g_binary_symbol_get_range(symbol); start = get_mrange_addr(range); coverage = g_arch_processor_find_coverage_by_address(study->proc, start); diff --git a/src/analysis/disass/routines.h b/src/analysis/disass/routines.h index dc81bb1..4b3efa9 100644 --- a/src/analysis/disass/routines.h +++ b/src/analysis/disass/routines.h @@ -25,6 +25,7 @@ #define _ANALYSIS_DISASS_ROUTINES_H +#include "../routine.h" #include "../../arch/processor.h" #include "../../format/executable.h" #include "../../format/symbol.h" diff --git a/src/analysis/routine.c b/src/analysis/routine.c index c916c66..b882428 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -45,8 +45,6 @@ struct _GBinRoutine { GBinSymbol parent; /* A laisser en premier */ - mrange_t range; /* Couverture mémoire */ - RoutineType type; /* Type de routine */ GDataType *ret_type; /* Type retourné */ @@ -88,6 +86,9 @@ static void g_bin_routine_init(GBinRoutine *); /* Vide le cache des descriptions humaines. */ static void g_binary_routine_reset_declarator(GBinRoutine *, bool); +/* Fournit une étiquette pour viser une routine. */ +static const char *g_binary_routine_get_label(GBinRoutine *); + /* Indique le type définit pour une représentation de routine. */ @@ -108,6 +109,11 @@ G_DEFINE_TYPE(GBinRoutine, g_bin_routine, G_TYPE_BIN_SYMBOL); static void g_bin_routine_class_init(GBinRoutineClass *klass) { + GBinSymbolClass *symbol; /* Autre version de la classe */ + + symbol = G_BIN_SYMBOL_CLASS(klass); + + symbol->get_label = (get_symbol_label_fc)g_binary_routine_get_label; } @@ -126,6 +132,11 @@ static void g_bin_routine_class_init(GBinRoutineClass *klass) static void g_bin_routine_init(GBinRoutine *routine) { + GBinSymbol *symbol; /* Autre version de l'instance */ + + symbol = G_BIN_SYMBOL(routine); + + g_binary_symbol_set_target_type(symbol, STP_ROUTINE); } @@ -212,85 +223,6 @@ void g_binary_routine_finalize(GBinRoutine *routine) /****************************************************************************** * * -* Paramètres : a = premières informations à consulter. * -* b = secondes informations à consulter. * -* * -* Description : Etablit la comparaison ascendante entre deux routines. * -* * -* Retour : Bilan : -1 (a < b), 0 (a == b) ou 1 (a > b). * -* * -* Remarques : - * -* * -******************************************************************************/ - -int g_binary_routine_compare(const GBinRoutine **a, const GBinRoutine **b) -{ - return cmp_mrange(&(*a)->range, &(*b)->range); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premières informations à consulter. * -* b = secondes informations à consulter. * -* * -* Description : Etablit la comparaison descendante entre deux routines. * -* * -* Retour : Bilan : 1 (a < b), 0 (a == b) ou -1 (a > b). * -* * -* Remarques : - * -* * -******************************************************************************/ - -int g_binary_routine_rcompare(const GBinRoutine **a, const GBinRoutine **b) -{ - return (-1) * cmp_mrange(&(*a)->range, &(*b)->range); - -} - - -/****************************************************************************** -* * -* Paramètres : routine = routine à mettre à jour. * -* range = plage mémoire ou physique déclarée. * -* * -* Description : Définit la couverture physique / en mémoire d'une routine. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_binary_routine_set_range(GBinRoutine *routine, const mrange_t *range) -{ - copy_mrange(&routine->range, range); - -} - - -/****************************************************************************** -* * -* Paramètres : routine = routine à consulter. * -* * -* Description : Fournit la couverture physique / en mémoire d'une routine. * -* * -* Retour : Plage mémoire ou physique déclarée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -const mrange_t *g_binary_routine_get_range(const GBinRoutine *routine) -{ - return &routine->range; - -} - - -/****************************************************************************** -* * * Paramètres : routine = routine à mettre à jour. * * type = type de routine spécifié. * * * @@ -699,6 +631,25 @@ const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) /****************************************************************************** * * +* Paramètres : routine = routine à manipuler. * +* * +* Description : Fournit une étiquette pour viser une routine. * +* * +* Retour : Désignation humainement lisible ou NULL si non définie. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_binary_routine_get_label(GBinRoutine *routine) +{ + return g_binary_routine_get_declarator(routine, false); + +} + + +/****************************************************************************** +* * * Paramètres : routine = routine à mettre à jour. * * offset = position abstraite à retrouver. * * local = indique le type de variable à manipuler. * @@ -1125,6 +1076,7 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi char *string_info; /* Détails des chaînes */ GArchProcessor *proc; /* Architecture utilisée */ GBufferCache *cache; /* Tampon de désassemblage */ + const mrange_t *srange; /* Couverture de la routine */ instr_iter_t *iter; /* Parcours local d'adresses */ GArchInstruction *instr; /* Instruction correspondante */ size_t dcount; /* Nombre de liens de dest. */ @@ -1163,10 +1115,12 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi /* Parcours des instructions */ - iter = g_arch_processor_get_iter_from_address(proc, get_mrange_addr(&routine->range)); + srange = g_binary_symbol_get_range(G_BIN_SYMBOL(routine)); + + iter = g_arch_processor_get_iter_from_address(proc, get_mrange_addr(srange)); if (iter == NULL) goto gbrbt_no_iter; - restrict_instruction_iterator(iter, &routine->range); + restrict_instruction_iterator(iter, srange); for (instr = get_instruction_iterator_current(iter); instr != NULL; diff --git a/src/analysis/routine.h b/src/analysis/routine.h index b040c6c..48cec13 100644 --- a/src/analysis/routine.h +++ b/src/analysis/routine.h @@ -83,12 +83,6 @@ GBinRoutine *g_binary_routine_new(void); /* Crée une représentation de routine construisant une instance. */ GBinRoutine *g_binary_routine_new_constructor(GDataType *); -/* Etablit la comparaison ascendante entre deux routines. */ -int g_binary_routine_compare(const GBinRoutine **, const GBinRoutine **); - -/* Etablit la comparaison descendante entre deux routines. */ -int g_binary_routine_rcompare(const GBinRoutine **, const GBinRoutine **); - /* Définit la couverture physique / en mémoire d'une routine. */ void g_binary_routine_set_range(GBinRoutine *, const mrange_t *); |