diff options
Diffstat (limited to 'src/arch/arm')
-rw-r--r-- | src/arch/arm/v7/link.c | 43 | ||||
-rw-r--r-- | src/arch/arm/v7/link.h | 3 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/pop_A88131.d | 20 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/pop_A88132.d | 14 |
4 files changed, 78 insertions, 2 deletions
diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c index 4443fdb..9eb625f 100644 --- a/src/arch/arm/v7/link.c +++ b/src/arch/arm/v7/link.c @@ -27,6 +27,7 @@ #include <assert.h> +#include "operands/reglist.h" #include "../register.h" @@ -63,3 +64,45 @@ void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArc g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); /* FIXME : jump inconnu ! */ } + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARM à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* * +* Description : Détecte les fins de procédures à base d'instructions 'pop'. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +{ + GArchOperand *op; /* Opérande numérique en place */ + GArmV7RegListOperand *reglist; /* Autre version de l'instance */ + size_t count; /* Nombre de registres présents*/ + size_t i; /* Boucle de parcours */ + GArmRegister *reg; /* Registre matériel manipulé */ + + op = g_arch_instruction_get_operand(instr, 0); + assert(G_IS_ARMV7_REGLIST_OPERAND(op)); + + reglist = G_ARMV7_REGLIST_OPERAND(op); + + count = g_armv7_reglist_count_registers(reglist); + + for (i = 0; i < count; i++) + { + reg = G_ARM_REGISTER(g_armv7_reglist_operand_get_register(reglist, i)); + + if (g_arm_register_get_index(reg) == 15 /* pc */) + g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); + + } + +} diff --git a/src/arch/arm/v7/link.h b/src/arch/arm/v7/link.h index 3251647..e5cc483 100644 --- a/src/arch/arm/v7/link.h +++ b/src/arch/arm/v7/link.h @@ -34,6 +34,9 @@ /* Encadre les sauts à partir de registres ARMv7. */ void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +/* Détecte les fins de procédures à base d'instructions 'pop'. */ +void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); + #endif /* _ARCH_ARM_V7_LINK_H */ diff --git a/src/arch/arm/v7/opdefs/pop_A88131.d b/src/arch/arm/v7/opdefs/pop_A88131.d index 7de7ee4..2dee09a 100644 --- a/src/arch/arm/v7/opdefs/pop_A88131.d +++ b/src/arch/arm/v7/opdefs/pop_A88131.d @@ -37,6 +37,12 @@ } + @hooks { + + link = handle_armv7_return_from_pop + + } + } @encoding (T2) { @@ -51,6 +57,12 @@ } + @hooks { + + link = handle_armv7_return_from_pop + + } + } @encoding (T3) { @@ -61,7 +73,13 @@ @conv { - registers = Zeros(16) + registers = RegistersList(1 << Rt) + + } + + @hooks { + + link = handle_armv7_return_from_pop } diff --git a/src/arch/arm/v7/opdefs/pop_A88132.d b/src/arch/arm/v7/opdefs/pop_A88132.d index 692aecb..27bbf3b 100644 --- a/src/arch/arm/v7/opdefs/pop_A88132.d +++ b/src/arch/arm/v7/opdefs/pop_A88132.d @@ -43,6 +43,12 @@ } + @hooks { + + link = handle_armv7_return_from_pop + + } + } @encoding (A2) { @@ -53,7 +59,7 @@ @conv { - registers = Zeros(16) + registers = RegistersList(1 << Rt) } @@ -63,5 +69,11 @@ } + @hooks { + + link = handle_armv7_return_from_pop + + } + } |