summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-01-02 22:09:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-01-02 22:09:09 (GMT)
commit2f0c162313fa7272bfec7eb674b71e5e15c4ec7c (patch)
treeee6b7b25ebd83b709cb7644edb660f94d38e0f1f /src
parent836e4ca6053594ceba7b78b8407d8a1f03491cd2 (diff)
Unlinked instructions to save memory.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/disass/area.c51
-rw-r--r--src/arch/instruction-int.h10
-rw-r--r--src/arch/instruction.c139
-rw-r--r--src/arch/instruction.h21
4 files changed, 23 insertions, 198 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index e57e2e0..a22f65a 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -861,8 +861,7 @@ mem_area *find_memory_area_by_addr(mem_area *list, size_t count, const vmpa2t *a
void insert_extra_symbol_into_mem_areas(mem_area *areas, size_t count, const GBinSymbol *symbol)
{
SymbolType type; /* Type de symbole */
- GArchInstruction *list; /* Ensemble à insérer */
- GArchInstruction *iter; /* Boucle de parcours */
+ GArchInstruction *instr; /* Instruction à insérer */
const mrange_t *range; /* Emplacement d'instruction */
const vmpa2t *addr; /* Départ de cet emplacement */
mem_area *area; /* Zone d'accueil désignée */
@@ -874,46 +873,42 @@ void insert_extra_symbol_into_mem_areas(mem_area *areas, size_t count, const GBi
if (!HAS_DATA_INSTR(type))
return;
- list = g_binary_symbol_get_instruction(symbol);
+ instr = g_binary_symbol_get_instruction(symbol);
- for (iter = list; iter != NULL; iter = g_arch_instruction_get_next_iter(list, iter, ~0))
- {
- range = g_arch_instruction_get_range(iter);
- addr = get_mrange_addr(range);
-
- /* Une aire d'accueil existe-t-elle ? */
+ range = g_arch_instruction_get_range(instr);
+ addr = get_mrange_addr(range);
- area = find_memory_area_by_addr(areas, count, addr);
+ /* Une aire d'accueil existe-t-elle ? */
- if (area == NULL)
- {
- vmpa2_virt_to_string(addr, MDS_UNDEFINED, loc, NULL);
+ area = find_memory_area_by_addr(areas, count, addr);
- log_variadic_message(LMT_WARNING, _("No place found for symbol located at %s."), loc);
- continue;
+ if (area == NULL)
+ {
+ vmpa2_virt_to_string(addr, MDS_UNDEFINED, loc, NULL);
- }
+ log_variadic_message(LMT_WARNING, _("No place found for symbol located at %s."), loc);
+ return;
- /* L'instruction est-elle accueillie dans son intégralité ? */
+ }
- start = compute_vmpa_diff(get_mrange_addr(&area->range), addr);
+ /* L'instruction est-elle accueillie dans son intégralité ? */
- if (start + get_mrange_length(range) > get_mrange_length(&area->range))
- {
- vmpa2_virt_to_string(addr, MDS_UNDEFINED, loc, NULL);
+ start = compute_vmpa_diff(get_mrange_addr(&area->range), addr);
- log_variadic_message(LMT_WARNING, _("The symbol located at %s is too big for one place only."), loc);
- continue;
+ if (start + get_mrange_length(range) > get_mrange_length(&area->range))
+ {
+ vmpa2_virt_to_string(addr, MDS_UNDEFINED, loc, NULL);
- }
+ log_variadic_message(LMT_WARNING, _("The symbol located at %s is too big for one place only."), loc);
+ return;
- /* Inscription d'une instruction de symbole (sans retour arrière possible :/ ) */
+ }
- mark_range_in_mem_area_as_processed(area, iter, true);
+ /* Inscription d'une instruction de symbole (sans retour arrière possible :/ ) */
- g_object_ref(G_OBJECT(iter));
+ mark_range_in_mem_area_as_processed(area, instr, true);
- }
+ g_object_ref(G_OBJECT(instr));
}
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index 8679589..2d829c0 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -52,8 +52,6 @@ struct _GArchInstruction
{
GObject parent; /* A laisser en premier */
- DL_LIST_ITEM(flow); /* Maillon de liste chaînée */
-
phys_t max_displayed_len; /* Quantité de code affichée */
const instr_hook_fc *hooks; /* Traitements complémentaires */
@@ -96,13 +94,5 @@ struct _GArchInstructionClass
};
-#define ainstr_list_last(head) dl_list_last(head, GArchInstruction, flow)
-#define ainstr_list_prev_iter(iter, head) dl_list_prev_iter(iter, head, GArchInstruction, flow)
-#define ainstr_list_next_iter(iter, head) dl_list_next_iter(iter, head, GArchInstruction, flow)
-#define ainstr_list_add_tail(new, head) dl_list_add_tail(new, head, GArchInstruction, flow)
-#define ainstr_list_merge(head1, head2) dl_list_merge(head1, head2, GArchInstruction, flow)
-#define ainstr_list_for_each(pos, head) dl_list_for_each(pos, head, GArchInstruction, flow)
-
-
#endif /* _ARCH_INSTRUCTION_INT_H */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 70b2819..db37bf7 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -122,8 +122,6 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass)
static void g_arch_instruction_init(GArchInstruction *instr)
{
- DL_LIST_ITEM_INIT(&instr->flow);
-
instr->max_displayed_len = VMPA_NO_PHYSICAL;
g_rw_lock_init(&instr->link_access);
@@ -942,143 +940,6 @@ void g_arch_instruction_set_displayed_max_length(GArchInstruction *instr, phys_t
/* ---------------------------------------------------------------------------------- */
-/* TRAITEMENT DES INSTRUCTIONS PAR ENSEMBLE */
-/* ---------------------------------------------------------------------------------- */
-
-
-/******************************************************************************
-* *
-* Paramètres : list = liste d'instructions à compléter, ou NULL. *
-* instr = nouvelle instruction à intégrer à l'ensemble. *
-* *
-* Description : Ajoute une instruction à un ensemble existant. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_arch_instruction_add_to_list(GArchInstruction **list, GArchInstruction *instr)
-{
- ainstr_list_add_tail(instr, list);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : list1 = première liste à traiter. *
-* list2 = seconde liste à traiter. *
-* *
-* Description : Fusionne deux listes d'instructions. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_arch_instruction_merge_lists(GArchInstruction **list1, GArchInstruction **list2)
-{
- ainstr_list_merge(list1, list2);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : list = liste d'instructions à consulter. *
-* : iter = position actuelle dans la liste. *
-* *
-* Description : Fournit l'élement suivant un autre pour un parcours. *
-* *
-* Retour : Elément suivant ou NULL si aucun. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GArchInstruction *g_arch_instruction_get_prev_iter(const GArchInstruction *list, const GArchInstruction *iter)
-{
- GArchInstruction *result; /* Elément suivant à renvoyer */
-
- result = ainstr_list_prev_iter(iter, list);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : list = liste d'instructions à consulter. *
-* : iter = position actuelle dans la liste. *
-* max = adresse marquant la limite (exclue) du parcours. *
-* *
-* Description : Fournit l'élement suivant un autre pour un parcours. *
-* *
-* Retour : Elément suivant ou NULL si aucun. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *list, const GArchInstruction *iter, vmpa_t max)
-{
- GArchInstruction *result; /* Elément suivant à renvoyer */
-
- result = ainstr_list_next_iter(iter, list);
-
- /* FIXME : utiliser les nouvelles adresses !
-
- if (result != NULL && result->address >= max)
- result = NULL;
-
- */
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : list = liste de lignes à parcourir. *
-* addr = position en mémoire ou physique à chercher. *
-* strict = définit la considération à porter à l'adresse. *
-* *
-* Description : Recherche une instruction d'après son adresse. *
-* *
-* Retour : Instruction trouvée à l'adresse donnée, NULL si aucune. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *list, const vmpa2t *addr, bool strict)
-{
- GArchInstruction *result; /* Trouvaille à retourner */
- bool found; /* Bilan de comparaisons */
-
- ainstr_list_for_each(result, list)
- {
- if (strict)
- found = (cmp_vmpa(get_mrange_addr(&result->range), addr) == 0);
- else
- found = mrange_contains_addr(&result->range, addr);
-
- if (found) break;
-
- }
-
- return result;
-
-}
-
-
-
-/* ---------------------------------------------------------------------------------- */
/* OFFRE DE CAPACITES DE GENERATION */
/* ---------------------------------------------------------------------------------- */
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 6c88e66..ffebaf3 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -223,25 +223,4 @@ void g_arch_instruction_set_displayed_max_length(GArchInstruction *, phys_t);
-/* -------------------- TRAITEMENT DES INSTRUCTIONS PAR ENSEMBLE -------------------- */
-
-
-/* Ajoute une instruction à un ensemble existant. */
-void g_arch_instruction_add_to_list(GArchInstruction **, GArchInstruction *);
-
-/* Fusionne deux listes d'instructions. */
-void g_arch_instruction_merge_lists(GArchInstruction **, GArchInstruction **);
-
-/* Fournit l'élement suivant un autre pour un parcours. */
-GArchInstruction *g_arch_instruction_get_prev_iter(const GArchInstruction *, const GArchInstruction *);
-
-/* Fournit l'élement suivant un autre pour un parcours. */
-GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *, const GArchInstruction *, vmpa_t);
-
-/* Recherche une instruction d'après son adresse. */
-GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *, const vmpa2t *, bool) __attribute__ ((deprecated));
-/* -> g_arch_processor_find_instr_by_address */
-
-
-
#endif /* _ARCH_INSTRUCTION_H */