summaryrefslogtreecommitdiff
path: root/src/analysis/disass/area.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/disass/area.c')
-rw-r--r--src/analysis/disass/area.c116
1 files changed, 97 insertions, 19 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index 8c46eb0..7e3a9a8 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -28,8 +28,6 @@
-
-
/* Zone mémoire bien bornée */
typedef struct _mem_area
{
@@ -49,10 +47,6 @@ typedef struct _mem_area
} mem_area;
-
-
-
-
/* Initialise une aire de données à partir d'une adresse donnée. */
static void init_mem_area_from_addr(mem_area *, const vmpa2t *, phys_t);
@@ -381,6 +375,14 @@ void load_code_from_mem_area(mem_area *area, mem_area *list, size_t count, const
//printf(" [%p] CODE start @ %u (len=%u)\n", area, (unsigned int)diff, (unsigned int)alen);
+
+
+ printf(" START @ 0x%08x\n", (unsigned int)get_virt_addr(&pos));
+
+
+ bin_length = (get_phy_addr(get_mrange_addr(&area->range)) + alen);
+
+
for (i = diff; i < alen; i += diff)
{
//il y a eu un point d'entrée... -> STOP
@@ -418,6 +420,26 @@ void load_code_from_mem_area(mem_area *area, mem_area *list, size_t count, const
assert(!is_range_blank_in_mem_areas(list, count, &range));
+
+
+
+ printf(" --disass-- '%s' @ 0x%08x (break=%d)\n",
+ g_arch_instruction_get_keyword(instr, 0),
+ (unsigned int)get_virt_addr(&prev),
+ g_arch_instruction_is_return(instr));
+
+
+
+
+ if (g_arch_instruction_is_return(instr))
+ printf("BREAK @ 0x%08x\n", (unsigned int)get_virt_addr(&prev));
+
+ //continue;
+
+ /* Rupture du flot d'exécution ? */
+ if (g_arch_instruction_is_return(instr))
+ break;
+
}
@@ -485,8 +507,9 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
advance_vmpa(&pos, diff);
/*
- printf(" [%p] DATA start @ 0x%08x -> %u (len=%u)\n",
- area, (unsigned int)get_phy_addr(&pos), (unsigned int)diff, (unsigned int)alen);
+ printf(" [%p] DATA start @ 0x%08x -> %u (len=%u) => 0x%08x <-> 0x%08x\n",
+ area, (unsigned int)get_phy_addr(&pos), (unsigned int)diff, (unsigned int)alen,
+ (unsigned int)get_virt_addr(&pos), (unsigned int)(get_virt_addr(&pos) + alen));
*/
for (i = diff; i < alen; i += diff)
@@ -496,7 +519,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
copy_vmpa(&prev, &pos);
instr = NULL;
-
+ /*
if (instr == NULL && (i + 4) <= alen)
{
init_mrange(&range, &pos, 4);
@@ -505,7 +528,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
instr = g_raw_instruction_new_array(bin_data, MDS_32_BITS, 1, &pos, bin_length, endianness);
}
-
+ */
if (instr == NULL && (i + 2) <= alen)
{
copy_vmpa(&pos, &prev);
@@ -525,10 +548,29 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
instr = g_raw_instruction_new_array(bin_data, MDS_8_BITS, 1, &pos, bin_length, endianness);
else
{
- printf(" break !! 0x%08x\n",
- (unsigned int)get_phy_addr(&pos));
- assert(0);
- break;
+ /**
+ * On rencontre ici un morceau déjà traité.
+ * On recherche donc la fin de cette partie à sauter, si elle existe.
+ */
+
+ //////////////
+ return;
+
+
+
+ for (i++; i < alen; i++)
+ {
+ advance_vmpa(&pos, 1);
+ init_mrange(&range, &pos, 1);
+
+ if (is_range_blank_in_mem_areas(list, count, &range))
+ break;
+
+ }
+
+ diff = 0;
+ continue;
+
}
}
@@ -551,6 +593,12 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
assert(!is_range_blank_in_mem_areas(list, count, &range));
+
+
+ if (area->exec) break;
+
+
+
}
}
@@ -579,11 +627,14 @@ static void fill_mem_area(mem_area *area, mem_area *list, size_t count, const GL
phys_t i; /* Boucle de parcours */
vmpa2t start; /* Adresse de départ de combles*/
- /*
- printf(" === FILLING | 0x%08x (%u)...\n",
+ bool on = true;
+
+
+ printf(" === FILLING | 0x%08x // 0x%08x <-> 0x%08x...\n",
(unsigned int)get_phy_addr(get_mrange_addr(&area->range)),
- (unsigned int)get_phy_addr(get_mrange_addr(&area->range)));
- */
+ (unsigned int)get_virt_addr(get_mrange_addr(&area->range)),
+ (unsigned int)(get_virt_addr(get_mrange_addr(&area->range)) + get_mrange_length(&area->range)));
+
/* Les symboles se doivent d'être indépendants ! */
if (area->has_sym) return;
@@ -597,14 +648,29 @@ static void fill_mem_area(mem_area *area, mem_area *list, size_t count, const GL
copy_vmpa(&start, get_mrange_addr(&area->range));
advance_vmpa(&start, i);
- if (area->exec)
+ if (area->exec && get_virt_addr(&start) % 4 == 0)
+ {
load_code_from_mem_area(area, list, count, binary, ctx, &start, info);
+ if (!is_range_blank_in_mem_area(area, i, 1, NULL))
+ {
+ printf(" --filled-- @ 0x%08x\n", (unsigned int)get_virt_addr(&start));
+ on = false;
+ }
+ else
+ printf(" --fill failed-- @ 0x%08x\n", (unsigned int)get_virt_addr(&start));
+
+
+ }
+
if (is_range_blank_in_mem_area(area, i, 1, NULL))
load_data_from_mem_area(area, list, count, binary, ctx, &start, info);
}
+
+ else on = true;
+
if (is_range_blank_in_mem_area(area, i, 1, NULL))
printf(" [%p] error with %u\n", area, (unsigned int)i);
@@ -1134,6 +1200,18 @@ static bool handle_bytes_map_in_mem_area(mem_area *list, size_t count, const mra
else
{
+
+ printf("BUG_ON | off=%u remaining=%u length=%u\n",
+ (unsigned int)offset,
+ (unsigned int)remaining,
+ (unsigned int)get_mrange_length(&area->range));
+
+ printf("BUG_ON @ 0x%08x + %d\n",
+ (unsigned int)get_virt_addr(get_mrange_addr(range)),
+ (int)get_mrange_length(range)
+ );
+
+
assert(0);
/* Traitement de la fin de la première aire */