summaryrefslogtreecommitdiff
path: root/src/arch/instruction.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-03-08 19:30:52 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-03-08 19:30:52 (GMT)
commit68bb7efaf61e4f5ca2f2cffce84995ffd667c4cc (patch)
tree9b6a6f63ee20b08d8c2ac35849ee051d61787447 /src/arch/instruction.c
parentdc9e68505c4cc7ad208e63dbc7d0e0e8f582d0d9 (diff)
Handle cross references as well as entry points.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@482 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r--src/arch/instruction.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index c9811cf..aced77e 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -1011,6 +1011,35 @@ GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *list,
/******************************************************************************
* *
+* Paramètres : list = liste de lignes à parcourir. *
+* range = emplacement mémoire à comparer. *
+* *
+* Description : Recherche une instruction d'après son emplacement mémoire. *
+* *
+* Retour : Instruction trouvée à l'adresse donnée, NULL si aucune. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchInstruction *g_arch_instruction_find_by_range(GArchInstruction *list, const mrange_t *range)
+{
+ GArchInstruction *result; /* Trouvaille à retourner */
+
+ ainstr_list_for_each(result, list)
+ {
+ if (cmp_mrange(&result->range, range) == 0)
+ break;
+
+ }
+
+ 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. *
@@ -1023,16 +1052,19 @@ GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *list,
* *
******************************************************************************/
-GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *list, vmpa_t addr, bool strict)
+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 && result->offset == addr) break;
+ if (strict)
+ found = (cmp_vmpa(get_mrange_addr(&result->range), addr) == 0);
+ else
+ found = mrange_contains_addr(&result->range, addr);
- else if (!strict && result->offset < addr
- && addr < (result->offset + result->length)) break;
+ if (found) break;
}