summaryrefslogtreecommitdiff
path: root/src/format/format.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-10-09 02:11:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-10-09 02:11:35 (GMT)
commit56549ed6632859db219d5434079ad94381293a0a (patch)
tree114f09993c3804b023837f555a610affe62cb8d3 /src/format/format.c
parentfe3ac685849b69d87ad536e80d6f31d08c593eac (diff)
Deleted duplicated symbols to avoid zero-length areas.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@589 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/format.c')
-rw-r--r--src/format/format.c59
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] *
* *