summaryrefslogtreecommitdiff
path: root/src/analysis/disass/area.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-12-28 23:27:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-12-28 23:27:12 (GMT)
commitb57e8ef5522dcbe126157fc2c50fcf879aa7d743 (patch)
tree1ecfd9de39073fee3a2c1a4afa9ce5da574b26df /src/analysis/disass/area.c
parent276b75e6e9ff99a930bd36045e55b1117bb29579 (diff)
Defined layers to register all kinds of binary portions.
Diffstat (limited to 'src/analysis/disass/area.c')
-rw-r--r--src/analysis/disass/area.c28
1 files changed, 23 insertions, 5 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++)