summaryrefslogtreecommitdiff
path: root/src/analysis/disass
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/disass')
-rw-r--r--src/analysis/disass/area.c28
-rw-r--r--src/analysis/disass/output.c26
2 files changed, 38 insertions, 16 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index d2a03c6..c79b293 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -707,9 +707,11 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
const vmpa2t *border; /* Nouvelle bordure rencontrée */
mem_area_v2 *area; /* Zone avec valeurs à éditer */
vmpa2t tmp; /* Stockage temporaire */
+ GPortionLayer *layer; /* Couche première de portions */
GBinPortion **portions; /* Morceaux d'encadrement */
size_t portions_count; /* Taille de cette liste */
const vmpa2t *portion_start; /* Point de départ de portion */
+ const vmpa2t *portion_next; /* Départ de portion suivante */
size_t j; /* Boucle de parcours #2 */
SymbolType type; /* Nature d'un symbole */
const mrange_t *range; /* Couverture d'un symbole */
@@ -813,7 +815,9 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
/* Seconde étape : on s'assure du découpage autour des portions pour respecter l'alignement */
- portions = g_exe_format_get_portions_at_level(format, -1, &portions_count);
+ layer = g_exe_format_get_main_layer(format);
+
+ portions = g_portion_layer_collect_all_portions(layer, &portions_count);
for (i = 1; i < portions_count; i++)
{
@@ -824,6 +828,20 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
(unsigned int)get_phy_addr(portion_start),
(unsigned int)get_virt_addr(portion_start));
+
+ /**
+ * Si plusieurs portions débutent au même endroit, il ne sert
+ * à rien de découper plusieurs fois.
+ */
+ if ((i + 1) < portions_count)
+ {
+ portion_next = get_mrange_addr(g_binary_portion_get_range(portions[i + 1]));
+
+ if (cmp_vmpa(portion_start, portion_next) == 0)
+ continue;
+
+ }
+
for (j = 0; j < *count; j++)
{
area = &result[j];
@@ -871,7 +889,10 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
}
+ if (portions != NULL)
+ free(portions);
+ g_object_unref(G_OBJECT(layer));
@@ -928,9 +949,6 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
/* Nettoyage final */
- if (portions != NULL)
- free(portions);
-
if (exe_ranges != NULL)
free(exe_ranges);
@@ -2193,7 +2211,7 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
printf("--------------------\n");
- portions = g_exe_format_get_portions_at_level(format, -1, &portions_count);
+ portions = NULL;//g_exe_format_get_portions_at_level(format, -1, &portions_count);
for (i = 1; i < portions_count; i++)
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 727c34f..67a3ce8 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -56,6 +56,14 @@
void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, GArchProcessor *proc, const GArchInstruction *instrs, GBinRoutine * const *routines, size_t count, GtkExtStatusBar *statusbar, bstatus_id_t id)
{
GLangOutput *output; /* Modèle de sortie adéquat */
+ GPortionLayer *layer; /* Couche première de portions */
+ GBinPortion **portions; /* Morceaux d'encadrement */
+ size_t portions_count; /* Taille de cette liste */
+ size_t portion_index; /* Prochaine portion à traiter */
+ GBinSymbol **symbols; /* Symboles à représenter */
+ size_t sym_count; /* Qté de symboles présents */
+ size_t sym_index; /* Prochain symbole non traité */
+
//GArchProcessor *proc; /* Architecture du binaire */
MemoryDataSize msize; /* Taille du bus d'adresses */
const GBinContent *content; /* Contenu binaire global */
@@ -74,13 +82,6 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
GBufferLine *line;
- GBinPortion **portions; /* Morceaux d'encadrement */
- size_t portions_count; /* Taille de cette liste */
- size_t portion_index; /* Prochaine portion à traiter */
-
- GBinSymbol **symbols; /* Symboles à représenter */
- size_t sym_count; /* Qté de symboles présents */
- size_t sym_index; /* Prochain symbole non traité */
const vmpa2t *paddr; /* Adresse de portion */
@@ -100,12 +101,12 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
output = g_asm_output_new();
+ layer = g_exe_format_get_main_layer(format);
-
- portions = g_exe_format_get_portions_at_level(format, -1, &portions_count);
+ portions = g_portion_layer_collect_all_portions(layer, &portions_count);
portion_index = 0;
- symbols = g_binary_format_get_symbols(format, &sym_count);
+ symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &sym_count);
sym_index = 0;
#if 0
@@ -294,7 +295,10 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
g_object_unref(G_OBJECT(content));
- /* free portions... */
+ if (portions != NULL)
+ free(portions);
+
+ g_object_unref(G_OBJECT(layer));
g_object_unref(G_OBJECT(output));