diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/arm/v7/opdefs/bl_A8825.d | 4 | ||||
| -rw-r--r-- | src/arch/arm/v7/opdefs/cbnz_A8829.d | 2 | ||||
| -rw-r--r-- | src/arch/instruction.c | 2 | ||||
| -rw-r--r-- | src/arch/instruction.h | 2 | ||||
| -rw-r--r-- | src/arch/link.c | 9 | ||||
| -rw-r--r-- | src/arch/link.h | 14 | ||||
| -rw-r--r-- | src/arch/target.c | 23 | ||||
| -rw-r--r-- | src/arch/target.h | 3 | 
8 files changed, 52 insertions, 7 deletions
| diff --git a/src/arch/arm/v7/opdefs/bl_A8825.d b/src/arch/arm/v7/opdefs/bl_A8825.d index 62ac8f9..ce4870c 100644 --- a/src/arch/arm/v7/opdefs/bl_A8825.d +++ b/src/arch/arm/v7/opdefs/bl_A8825.d @@ -40,6 +40,7 @@      @hooks {          fetch = help_fetching_with_instruction_bl_from_thumb +        link = handle_call_as_link          post = post_process_branch_and_link_instructions      } @@ -69,6 +70,7 @@      @hooks {          fetch = help_fetching_with_instruction_blx_from_thumb +        link = handle_call_as_link          post = post_process_branch_and_link_instructions      } @@ -96,6 +98,7 @@      @hooks {          fetch = help_fetching_with_instruction_bl_from_arm +        link = handle_call_as_link          post = post_process_branch_and_link_instructions      } @@ -123,6 +126,7 @@      @hooks {          fetch = help_fetching_with_instruction_blx_from_arm +        link = handle_call_as_link          post = post_process_branch_and_link_instructions      } diff --git a/src/arch/arm/v7/opdefs/cbnz_A8829.d b/src/arch/arm/v7/opdefs/cbnz_A8829.d index d9815c1..f5f9602 100644 --- a/src/arch/arm/v7/opdefs/cbnz_A8829.d +++ b/src/arch/arm/v7/opdefs/cbnz_A8829.d @@ -39,6 +39,7 @@      @hooks {          fetch = help_fetching_with_instruction_cb_n_z +        link = handle_comp_and_branch_if_true_as_link          post = post_process_comp_and_branch_instructions      } @@ -61,6 +62,7 @@      @hooks {          fetch = help_fetching_with_instruction_cb_n_z +        link = handle_comp_and_branch_if_true_as_link          post = post_process_comp_and_branch_instructions      } diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 475c038..7391af1 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -636,7 +636,7 @@ void g_arch_instruction_link_with(GArchInstruction *instr, GArchInstruction *des  *                                                                             *  ******************************************************************************/ -void g_arch_instruction_change_link(GArchInstruction *instr, GArchInstruction *dest, InstructionLinkType old, InstructionLinkType new) +bool g_arch_instruction_change_link(GArchInstruction *instr, GArchInstruction *dest, InstructionLinkType old, InstructionLinkType new)  {      size_t count;                           /* Raccourci pour la lecture   */      size_t i;                               /* Boucle de parcours          */ diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 9123b6f..b570d92 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -189,7 +189,7 @@ bool g_arch_instruction_is_return(const GArchInstruction *instr);  void g_arch_instruction_link_with(GArchInstruction *, GArchInstruction *, InstructionLinkType, ...);  /* Change la nature d'un lien entre deux instructions. */ -void g_arch_instruction_change_link(GArchInstruction *, GArchInstruction *, InstructionLinkType, InstructionLinkType); +bool g_arch_instruction_change_link(GArchInstruction *, GArchInstruction *, InstructionLinkType, InstructionLinkType);  /* Indique si l'instruction a une ou plusieurs origines. */  bool g_arch_instruction_has_sources(const GArchInstruction *); diff --git a/src/arch/link.c b/src/arch/link.c index bc80e39..02cda22 100644 --- a/src/arch/link.c +++ b/src/arch/link.c @@ -79,6 +79,7 @@ void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon  *                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.             * +*                index   = indice de l'opérande à traiter dans l'instruction. *  *                                                                             *  *  Description : Etablit un lien d'appel selon une instruction donnée.        *  *                                                                             * @@ -87,8 +88,8 @@ void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -#include "instruction-int.h" -void handle_branch_if_true_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +#include "instruction-int.h" // REMME +void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format, size_t index)  {      GArchOperand *op;                       /* Opérande numérique en place */      virt_t virt;                            /* Adresse virtuelle           */ @@ -96,9 +97,9 @@ void handle_branch_if_true_as_link(GArchInstruction *instr, GArchProcessor *proc      GArchInstruction *target;               /* Ligne visée par la référence*/      GArchInstruction *list;                 /* Ensemble des instructions   */ -    assert(g_arch_instruction_count_operands(instr) > 0); +    assert(g_arch_instruction_count_operands(instr) > index); -    op = g_arch_instruction_get_operand(instr, 0); +    op = g_arch_instruction_get_operand(instr, index);      virt = VMPA_NO_VIRTUAL; diff --git a/src/arch/link.h b/src/arch/link.h index 1923e0b..319b3a0 100644 --- a/src/arch/link.h +++ b/src/arch/link.h @@ -35,7 +35,19 @@  void handle_jump_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *);  /* Etablit un lien d'appel selon une instruction donnée. */ -void handle_branch_if_true_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *, size_t); + + +static inline void handle_branch_if_true_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +{ +    handle_branch_as_link(ins, proc, ctx, fmt, 0); +} + +static inline void handle_comp_and_branch_if_true_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +{ +    handle_branch_as_link(ins, proc, ctx, fmt, 1); +} +  /* Etablit un lien d'appel selon une instruction donnée. */  void handle_call_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); diff --git a/src/arch/target.c b/src/arch/target.c index 7509711..01c2bfe 100644 --- a/src/arch/target.c +++ b/src/arch/target.c @@ -328,3 +328,26 @@ bool g_target_operand_resolve(GTargetOperand *operand, const GBinFormat *format)      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = opérande dont le contenu est à raffiner.           * +*                diff    = décallage entre le symbole et l'adresse initiale.  * +*                                                                             * +*  Description : Fournit les indications concernant le symbole associé.       * +*                                                                             * +*  Retour      : Symbole résolu ou NULL si aucun.                             * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *operand, phys_t *diff) +{ +    if (diff != NULL) +        *diff = operand->diff; + +    return operand->symbol; + +} diff --git a/src/arch/target.h b/src/arch/target.h index ada1a6c..f226ee1 100644 --- a/src/arch/target.h +++ b/src/arch/target.h @@ -66,6 +66,9 @@ virt_t g_target_operand_get_addr(const GTargetOperand *);  /* Tente une résolution de symbole. */  bool g_target_operand_resolve(GTargetOperand *, const GBinFormat *); +/* Fournit les indications concernant le symbole associé. */ +GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *, phys_t *); +  #endif  /* _ARCH_TARGET_H */ | 
