summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
Diffstat (limited to 'src/format')
-rw-r--r--src/format/executable.c4
-rw-r--r--src/format/flat.c8
-rw-r--r--src/format/format-int.h12
-rw-r--r--src/format/format.c54
-rw-r--r--src/format/format.h2
5 files changed, 35 insertions, 45 deletions
diff --git a/src/format/executable.c b/src/format/executable.c
index b081f64..553b157 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -286,8 +286,8 @@ bool g_exe_format_get_main_address(GExeFormat *format, vmpa2t *addr)
g_rw_lock_reader_lock(&base->pt_lock);
- if (base->ep_count > 0)
- result = g_exe_format_translate_address_into_vmpa(format, base->entry_points[0], addr);
+ if (base->pt_count[DPL_ENTRY_POINT] > 0)
+ result = g_exe_format_translate_address_into_vmpa(format, base->start_points[DPL_ENTRY_POINT][0], addr);
g_rw_lock_reader_unlock(&base->pt_lock);
diff --git a/src/format/flat.c b/src/format/flat.c
index 1ae813a..a9081d8 100644
--- a/src/format/flat.c
+++ b/src/format/flat.c
@@ -377,10 +377,14 @@ static bool g_flat_format_get_main_address(GFlatFormat *format, vmpa2t *addr)
base = G_BIN_FORMAT(format);
- result = (base->ep_count > 0);
+ g_rw_lock_reader_lock(&base->pt_lock);
+
+ result = (base->pt_count[DPL_ENTRY_POINT] > 0);
if (result)
- init_vmpa(addr, 0, base->entry_points[0]);
+ init_vmpa(addr, 0, base->start_points[DPL_ENTRY_POINT][0]);
+
+ g_rw_lock_reader_unlock(&base->pt_lock);
return result;
diff --git a/src/format/format-int.h b/src/format/format-int.h
index d5ee2b4..c8f2b1a 100644
--- a/src/format/format-int.h
+++ b/src/format/format-int.h
@@ -54,7 +54,7 @@ typedef void (* format_complete_analysis_fc) (GBinFormat *, wgroup_id_t, GtkStat
/* Rythme des allocations pour les entrées de code */
-#define EXTRA_POINT_BLOCK 100
+#define EXTRA_POINT_BLOCK 20
/* Description d'une erreur */
@@ -75,13 +75,9 @@ struct _GBinFormat
GBinContent *content; /* Contenu binaire à étudier */
- virt_t *entry_points; /* Points d'entrée du code */
- size_t ep_count; /* Nombre de ces points */
-
- virt_t *extra_points; /* Autres débuts de code */
- size_t xp_allocated; /* Taille d'inscription allouée*/
- size_t xp_count; /* Nombre de points enregistrés*/
-
+ virt_t *start_points[DPL_COUNT]; /* Départ de désassemblage */
+ size_t pt_allocated[DPL_COUNT]; /* Taille d'inscription allouée*/
+ size_t pt_count[DPL_COUNT]; /* Nombre de points enregistrés*/
GRWLock pt_lock; /* Accès à la liste des points */
GPreloadInfo *info; /* Préchargements du format */
diff --git a/src/format/format.c b/src/format/format.c
index e782996..533d641 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -192,22 +192,21 @@ static void g_binary_format_dispose(GBinFormat *format)
static void g_binary_format_finalize(GBinFormat *format)
{
- size_t i; /* Boucle de parcours */
-
- if (format->entry_points != NULL)
- free(format->entry_points);
+ DisassPriorityLevel i; /* Boucle de parcours #1 */
+ size_t k; /* Boucle de parcours #2 */
- if (format->extra_points != NULL)
- free(format->extra_points);
+ for (i = 0; i < DPL_COUNT; i++)
+ if (format->start_points[i] != NULL)
+ free(format->start_points[i]);
if (format->symbols != NULL)
free(format->symbols);
if (format->errors != NULL)
{
- for (i = 0; i < format->error_count; i++)
- if (format->errors[i].desc != NULL)
- free(format->errors[i].desc);
+ for (k = 0; k < format->error_count; k++)
+ if (format->errors[k].desc != NULL)
+ free(format->errors[k].desc);
free(format->errors);
@@ -388,7 +387,7 @@ SourceEndian g_binary_format_get_endianness(const GBinFormat *format)
* *
* Paramètres : format = description de l'exécutable à compléter. *
* pt = point de l'espace mémoire à considérer. *
-* entry = nature du point fourni. *
+* level = indication de priorité et d'origine de l'adresse. *
* *
* Description : Enregistre une adresse comme début d'une zone de code. *
* *
@@ -398,30 +397,22 @@ SourceEndian g_binary_format_get_endianness(const GBinFormat *format)
* *
******************************************************************************/
-void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, bool entry)
+void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, DisassPriorityLevel level)
{
+ assert(level < DPL_COUNT);
+
g_rw_lock_writer_lock(&format->pt_lock);
- if (entry)
+ if (format->pt_count[level] == format->pt_allocated[level])
{
- format->entry_points = realloc(format->entry_points, ++format->ep_count * sizeof(virt_t));
+ format->pt_allocated[level] += EXTRA_POINT_BLOCK;
- format->entry_points[format->ep_count - 1] = pt;
+ format->start_points[level] = realloc(format->start_points[level],
+ format->pt_allocated[level] * sizeof(virt_t));
}
- else
- {
- if (format->xp_count == format->xp_allocated)
- {
- format->xp_allocated += EXTRA_POINT_BLOCK;
- format->extra_points = realloc(format->extra_points, format->xp_allocated * sizeof(virt_t));
-
- }
-
- format->extra_points[format->xp_count++] = pt;
-
- }
+ format->start_points[level][format->pt_count[level]++] = pt;
g_rw_lock_writer_unlock(&format->pt_lock);
@@ -465,15 +456,14 @@ void g_binary_format_preload_disassembling_context(GBinFormat *format, GProcCont
void g_binary_format_activate_disassembling_context(GBinFormat *format, GProcContext *ctx, GtkStatusStack *status)
{
- size_t i; /* Boucle de parcours */
+ DisassPriorityLevel i; /* Boucle de parcours #1 */
+ size_t k; /* Boucle de parcours #2 */
g_rw_lock_reader_lock(&format->pt_lock);
- for (i = 0; i < format->ep_count; i++)
- g_proc_context_push_drop_point(ctx, DPL_ENTRY_POINT, format->entry_points[i]);
-
- for (i = 0; i < format->xp_count; i++)
- g_proc_context_push_drop_point(ctx, DPL_SYMBOL, format->extra_points[i]);
+ for (i = 0; i < DPL_COUNT; i++)
+ for (k = 0; k < format->pt_count[i]; k++)
+ g_proc_context_push_drop_point(ctx, i, format->start_points[i][k]);
g_rw_lock_reader_unlock(&format->pt_lock);
diff --git a/src/format/format.h b/src/format/format.h
index 450ebdc..626bb8a 100644
--- a/src/format/format.h
+++ b/src/format/format.h
@@ -76,7 +76,7 @@ bool g_binary_format_analyze(GBinFormat *, wgroup_id_t, GtkStatusStack *);
SourceEndian g_binary_format_get_endianness(const GBinFormat *);
/* Enregistre une adresse comme début d'une zone de code. */
-void g_binary_format_register_code_point(GBinFormat *, virt_t, bool);
+void g_binary_format_register_code_point(GBinFormat *, virt_t, DisassPriorityLevel);
/* Intègre dans un contexte les informations tirées d'un format. */
void g_binary_format_preload_disassembling_context(GBinFormat *, GProcContext *, GtkStatusStack *);