summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-10-14 19:33:06 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-10-14 19:33:06 (GMT)
commitc9449c389834c580196527c4e1cb010a701e7a32 (patch)
tree224396e26a8fc11a6106c754b3870f854b7796f2 /src/analysis
parent48726043e2f07874e7a09a866c4cc537a65a683c (diff)
Discarded code symbols as symbols already containing instructions when disassembling.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@595 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/disass/area.c56
-rw-r--r--src/analysis/project.c4
2 files changed, 33 insertions, 27 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index 3338b03..b45e7fc 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -994,6 +994,7 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
const vmpa2t *portion_start; /* Point de départ de portion */
size_t j; /* Boucle de parcours #2 */
+ SymbolType type; /* Nature d'un symbole */
const mrange_t *range; /* Couverture d'un symbole */
const vmpa2t *start; /* Point de départ du symbole */
phys_t length; /* Taille de ce même symbole */
@@ -1175,32 +1176,45 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
}
- //exit(0);
-
/* Troisième étape : on insère les symboles existants */
j = 0;
-#define SKIP_EMPTY_SYMBOLS \
- for (; j < sym_count; j++) \
- { \
- range = g_binary_symbol_get_range(symbols[j]); \
- \
- length = get_mrange_length(range); \
- if (length > 0) break; \
- \
- } \
+ for (i = 0; i < *count; i++)
+ {
+ /* Sélection et écartement des symboles */
- SKIP_EMPTY_SYMBOLS
+ for (; j < sym_count; j++)
+ {
+ type = g_binary_symbol_get_target_type(symbols[j]);
- for (i = 0; i < *count && j < sym_count; i++)
- {
- range = g_binary_symbol_get_range(symbols[j]);
+ /**
+ * On ne garde que les symboles renvoyant directement une ou
+ * plusieurs instructions, c'est à dire les symboles valides
+ * pour un appel à g_binary_symbol_get_instruction().
+ *
+ * Les instructions des autres symboles sont obtenues et mises
+ * en place durant la procédure de désassemblage.
+ */
+
+ if (type == STP_ROUTINE || type == STP_ENTRY_POINT || type == STP_CODE_LABEL)
+ continue;
+
+ range = g_binary_symbol_get_range(symbols[j]);
+
+ length = get_mrange_length(range);
+
+ if (length > 0)
+ break;
+
+ }
+
+ if (j == sym_count)
+ break;
start = get_mrange_addr(range);
- length = get_mrange_length(range);
/* Si un découpage s'impose... */
@@ -1286,25 +1300,15 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
}
-
-
-
-
j++;
- SKIP_EMPTY_SYMBOLS
-
}
}
-
-
if (exe_ranges != NULL)
free(exe_ranges);
- //exit(0);
-
return result;
}
diff --git a/src/analysis/project.c b/src/analysis/project.c
index 902b5a8..8fef602 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -566,7 +566,9 @@ void g_study_project_add_loaded_binary(GLoadedBinary *binary, GStudyProject *pro
format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
- if (g_binary_format_find_symbol_by_label(format, "entry_point", &symbol))
+ if (g_binary_format_find_symbol_by_label(format, "main", &symbol)
+ || g_binary_format_find_symbol_by_label(format, "_start", &symbol)
+ || g_binary_format_find_symbol_by_label(format, "entry_point", &symbol))
{
range = g_binary_symbol_get_range(symbol);