summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/arm/v7/post.c12
-rw-r--r--src/arch/instruction.h3
-rw-r--r--src/arch/processor.c52
-rw-r--r--src/arch/processor.h6
4 files changed, 72 insertions, 1 deletions
diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c
index e066bb0..0692cea 100644
--- a/src/arch/arm/v7/post.c
+++ b/src/arch/arm/v7/post.c
@@ -57,6 +57,10 @@ void post_process_branch_instructions(GArchInstruction *instr, GArchProcessor *p
op = g_arch_instruction_get_operand(instr, 0);
+
+ if (!G_IS_IMM_OPERAND(op)) return;
+
+
if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr)
&& g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target))
{
@@ -121,6 +125,10 @@ void post_process_branch_and_link_instructions(GArchInstruction *instr, GArchPro
op = g_arch_instruction_get_operand(instr, 0);
+
+ if (!G_IS_IMM_OPERAND(op)) return;
+
+
if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr)
&& g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target))
{
@@ -195,6 +203,10 @@ void post_process_comp_and_branch_instructions(GArchInstruction *instr, GArchPro
op = g_arch_instruction_get_operand(instr, 1);
+
+ if (!G_IS_IMM_OPERAND(op)) return;
+
+
if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr)
&& g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target))
{
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 0db68c7..d75cf54 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -248,7 +248,8 @@ GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *, con
GArchInstruction *g_arch_instruction_find_by_range(GArchInstruction *, const mrange_t *);
/* Recherche une instruction d'après son adresse. */
-GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *, const vmpa2t *, bool);
+GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *, const vmpa2t *, bool) __attribute__ ((deprecated));
+/* -> g_arch_processor_find_instr_by_address */
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 21db869..da5ddce 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -520,6 +520,58 @@ GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProc
/******************************************************************************
* *
+* Paramètres : proc = architecture visée par la procédure. *
+* index = indice de l'instruction visée. *
+* *
+* Description : Fournit une instruction désassemblée pour une architecture. *
+* *
+* Retour : Instructions désassemblée trouvée ou NULL si aucune. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchInstruction *g_arch_processor_get_disassembled_instruction(const GArchProcessor *proc, size_t index)
+{
+ GArchInstruction *result; /* Instruction à retourner */
+
+ if (proc->instr_count == 0)
+ result = NULL;
+
+ else
+ {
+ assert(index < proc->instr_count);
+
+ result = proc->instructions[index];
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : proc = architecture visée par la procédure. *
+* *
+* Description : Compte le nombre d'instructions représentées. *
+* *
+* Retour : Nombre d'instructions présentes. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+size_t g_arch_processor_count_disassembled_instructions(const GArchProcessor *proc)
+{
+ return proc->instr_count;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : proc = processeur recensant diverses instructions. *
* addr = position en mémoire ou physique à chercher. *
* nearby = la recherche s'effectue-t-elle de façon stricte ? *
diff --git a/src/arch/processor.h b/src/arch/processor.h
index 82c4f18..9dee9f6 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -91,6 +91,12 @@ void g_arch_processor_set_disassembled_instructions(GArchProcessor *, GArchInstr
/* Fournit les instructions désassemblées pour une architecture. */
GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProcessor *);
+/* Fournit une instruction désassemblée pour une architecture. */
+GArchInstruction *g_arch_processor_get_disassembled_instruction(const GArchProcessor *, size_t);
+
+/* Compte le nombre d'instructions représentées. */
+size_t g_arch_processor_count_disassembled_instructions(const GArchProcessor *);
+
/* Recherche un groupe d'instruction d'après son adresse. */
const instr_coverage *g_arch_processor_find_coverage_by_address(const GArchProcessor *, const vmpa2t *);