From 9e3c072316b1183c256595f394f3ca22f2d2b66e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 8 Dec 2018 15:03:41 +0100 Subject: Compared symbols using their location only to prevent duplicated symbols. --- src/format/format.c | 62 ----------------------------------------------------- src/format/symbol.c | 7 +++++- 2 files changed, 6 insertions(+), 63 deletions(-) diff --git a/src/format/format.c b/src/format/format.c index b43f78f..261f152 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -57,9 +57,6 @@ static void g_binary_format_finalize(GBinFormat *); /* Retire un symbole de la collection du format binaire. */ static void _g_binary_format_remove_symbol(GBinFormat *, size_t); -/* Supprime les éventuels doublons au sein des symboles. */ -static void g_binary_format_delete_duplicated_symbols(GBinFormat *); - /* Recherche le symbole associé à une adresse. */ static bool _g_binary_format_find_symbol(const GBinFormat *, const vmpa2t *, __compar_fn_t, size_t *, GBinSymbol **); @@ -219,8 +216,6 @@ static void g_binary_format_finalize(GBinFormat *format) bool g_binary_format_complete_loading(GBinFormat *format, GtkStatusStack *status) { - g_binary_format_delete_duplicated_symbols(format); - return true; } @@ -929,63 +924,6 @@ void g_binary_format_remove_symbol(GBinFormat *format, GBinSymbol *symbol) /****************************************************************************** * * -* Paramètres : format = informations chargées à corriger si besoin est. * -* * -* Description : Supprime les éventuels doublons au sein des symboles. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_format_delete_duplicated_symbols(GBinFormat *format) -{ - size_t i; /* Boucle de parcours */ - const mrange_t *range; /* Emplacement à consulter */ - mrange_t last; /* Dernière localisation vue */ - size_t index; /* Indice de suppression */ - - g_binary_format_lock_unlock_symbols_wr(format, true); - - if (format->sym_count > 1) - { - range = g_binary_symbol_get_range(format->symbols[0]); - copy_mrange(&last, range); - } - - for (i = 1; i < format->sym_count; i++) - { - range = g_binary_symbol_get_range(format->symbols[i]); - - if (cmp_vmpa(get_mrange_addr(&last), get_mrange_addr(range)) == 0) - { - /* TODO : établir une meilleur comparaison pour trouver le bon candidat */ - /* TODO : (éviter de) traiter selon le type aussi */ - index = (get_mrange_length(&last) == 0 ? i - 1 : i); - /* - printf("DELETE @ %zu / 0x%08x '%s'\n", index, - (unsigned int)last.addr.virtual, - g_binary_symbol_get_label(format->symbols[index])); - */ - - _g_binary_format_remove_symbol(format, index); - - i--; - - } - - copy_mrange(&last, range); - - } - - g_binary_format_lock_unlock_symbols_wr(format, false); - -} - - -/****************************************************************************** -* * * Paramètres : format = informations chargées à consulter. * * label = étiquette à retrouver lors des recherches. * * symbol = éventuel symbole trouvé à déréfenrencer. [OUT] * diff --git a/src/format/symbol.c b/src/format/symbol.c index 899740a..22403c5 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -237,8 +237,13 @@ GBinSymbol *g_binary_symbol_new(const mrange_t *range, SymbolType type) int g_binary_symbol_cmp(const GBinSymbol * const *a, const GBinSymbol * const *b) { int result; /* Bilan à retourner */ + const mrange_t *range_a; /* Emplacement du symbole A */ + const mrange_t *range_b; /* Emplacement du symbole B */ - result = cmp_mrange(&(*a)->range, &(*b)->range); + range_a = &(*a)->range; + range_b = &(*b)->range; + + result = cmp_vmpa(get_mrange_addr(range_a), get_mrange_addr(range_b)); return result; -- cgit v0.11.2-87-g4458