diff options
Diffstat (limited to 'src/format/format.c')
-rw-r--r-- | src/format/format.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/format/format.c b/src/format/format.c index 74549bc..6128c9a 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -350,6 +350,65 @@ void g_binary_format_sort_symbols(GBinFormat *format) /****************************************************************************** * * +* Paramètres : format = informations chargées à corriger si besoin est. * +* * +* Description : Supprime les éventuels doublons au sein des symboles. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +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_sort_symbols(G_BIN_FORMAT(format)); + + g_rw_lock_writer_lock(&format->syms_lock); + + if (format->symbols_count > 1) + { + range = g_binary_symbol_get_range(format->symbols[0]); + copy_mrange(&last, range); + } + + for (i = 1; i < format->symbols_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_rw_lock_writer_unlock(&format->syms_lock); + +} + + +/****************************************************************************** +* * * Paramètres : format = informations chargées à consulter. * * count = taille du tableau créé. [OUT] * * * |