summaryrefslogtreecommitdiff
path: root/src/arch/arm/v7
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-12-12 18:05:45 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-12-12 18:05:45 (GMT)
commitdcc0438ff24efd5958b8d46940eb395ff2b7ed77 (patch)
treea977fdbd43abd34bbea73f1fd1aef89f364230f2 /src/arch/arm/v7
parentb3efd0bbc506e701ea9872f50b8b4db974f35954 (diff)
Applied some code refactoring to remove usages of GBinFormat in favor of GExeFormat.
Diffstat (limited to 'src/arch/arm/v7')
-rw-r--r--src/arch/arm/v7/fetch.c19
-rw-r--r--src/arch/arm/v7/fetch.h33
-rw-r--r--src/arch/arm/v7/link.c4
-rw-r--r--src/arch/arm/v7/link.h5
-rw-r--r--src/arch/arm/v7/post.c13
-rw-r--r--src/arch/arm/v7/post.h9
6 files changed, 42 insertions, 41 deletions
diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c
index 8c36f9b..7296717 100644
--- a/src/arch/arm/v7/fetch.c
+++ b/src/arch/arm/v7/fetch.c
@@ -34,6 +34,7 @@
#include "operands/offset.h"
#include "../register.h"
#include "../../raw.h"
+#include "../../../format/format.h"
@@ -53,7 +54,7 @@
* *
******************************************************************************/
-void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset)
+void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset)
{
const mrange_t *range; /* Emplacementt d'instruction */
virt_t pc; /* Position dans l'exécution */
@@ -120,7 +121,7 @@ void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchPr
* *
******************************************************************************/
-void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset)
+void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset)
{
const mrange_t *range; /* Emplacementt d'instruction */
virt_t pc; /* Position dans l'exécution */
@@ -189,7 +190,7 @@ void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchP
* *
******************************************************************************/
-void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset)
+void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset)
{
const mrange_t *range; /* Emplacementt d'instruction */
virt_t pc; /* Position dans l'exécution */
@@ -248,7 +249,7 @@ void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArch
* *
******************************************************************************/
-void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset)
+void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset)
{
GArchOperand *op; /* Opérande numérique en place */
GArmRegister *reg; /* Registre matériel manipulé */
@@ -310,7 +311,7 @@ void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchP
* *
******************************************************************************/
-void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format)
+void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format)
{
const mrange_t *range; /* Emplacementt d'instruction */
virt_t pc; /* Position dans l'exécution */
@@ -363,7 +364,7 @@ void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcess
* *
******************************************************************************/
-void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset)
+void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset)
{
const mrange_t *range; /* Emplacementt d'instruction */
phys_t phys_pc; /* Position dans l'exécution */
@@ -423,7 +424,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst
val_offset = phys_pc + offset;
- if (!g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), val_offset, &sym_addr))
+ if (!g_exe_format_translate_offset_into_vmpa(format, val_offset, &sym_addr))
{
assert(0);
return;
@@ -441,7 +442,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst
/* Lecture de la valeur vers laquelle renvoyer */
- content = g_binary_format_get_content(format);
+ content = g_binary_format_get_content(G_BIN_FORMAT(format));
copy_vmpa(&pos, &sym_addr);
@@ -461,7 +462,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst
vmpa2_virt_to_string(get_mrange_addr(range), MDS_32_BITS, loc, NULL);
snprintf(name, name_len, _("Value used @ %s"), loc);
- ADD_RAW_AS_SYM(format, symbol, &sym_addr, sym_instr, comment, name);
+ ADD_RAW_AS_SYM(G_BIN_FORMAT(format), symbol, &sym_addr, sym_instr, comment, name);
free(name);
diff --git a/src/arch/arm/v7/fetch.h b/src/arch/arm/v7/fetch.h
index e8e57e5..e8a89d6 100644
--- a/src/arch/arm/v7/fetch.h
+++ b/src/arch/arm/v7/fetch.h
@@ -27,83 +27,82 @@
#include "context.h"
#include "../../instruction.h"
-#include "../../../format/format.h"
/* Complète un désassemblage accompli pour une instruction. */
-void help_fetching_with_instruction_b_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet);
+void help_fetching_with_instruction_b_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet);
-static inline void help_fetching_with_instruction_b_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_b_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_ARM);
}
-static inline void help_fetching_with_instruction_b_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_b_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB);
}
/* Complète un désassemblage accompli pour une instruction. */
-void help_fetching_with_instruction_bl_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet);
+void help_fetching_with_instruction_bl_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet);
-static inline void help_fetching_with_instruction_bl_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_bl_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_ARM);
}
-static inline void help_fetching_with_instruction_bl_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_bl_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB);
}
/* Complète un désassemblage accompli pour une instruction. */
-void help_fetching_with_instruction_blx_with_dest(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet);
+void help_fetching_with_instruction_blx_with_dest(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet);
-static inline void help_fetching_with_instruction_blx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_blx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_THUMB);
}
-static inline void help_fetching_with_instruction_blx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_blx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_ARM);
}
/* Complète un désassemblage accompli pour une instruction. */
-void help_fetching_with_instruction_bx_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet);
+void help_fetching_with_instruction_bx_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet);
-static inline void help_fetching_with_instruction_bx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_bx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_ARM);
}
-static inline void help_fetching_with_instruction_bx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_bx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB);
}
/* Complète un désassemblage accompli pour une instruction. */
-void help_fetching_with_instruction_cb_n_z(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *);
+void help_fetching_with_instruction_cb_n_z(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *);
/* Complète un désassemblage accompli pour une instruction. */
-void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet);
+void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet);
-static inline void help_fetching_with_instruction_ldr_literal_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_ldr_literal_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_ARM);
}
-static inline void help_fetching_with_instruction_ldr_literal_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt)
+static inline void help_fetching_with_instruction_ldr_literal_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt)
{
help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB);
}
diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c
index e9fc4bc..90d78bc 100644
--- a/src/arch/arm/v7/link.c
+++ b/src/arch/arm/v7/link.c
@@ -47,7 +47,7 @@
* *
******************************************************************************/
-void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format)
+void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format)
{
GArchOperand *op; /* Opérande numérique en place */
GArmRegister *reg; /* Registre matériel manipulé */
@@ -81,7 +81,7 @@ void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArc
* *
******************************************************************************/
-void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format)
+void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format)
{
GArchOperand *op; /* Opérande numérique en place */
GArmV7RegListOperand *reglist; /* Autre version de l'instance */
diff --git a/src/arch/arm/v7/link.h b/src/arch/arm/v7/link.h
index 0b658fc..136b787 100644
--- a/src/arch/arm/v7/link.h
+++ b/src/arch/arm/v7/link.h
@@ -27,15 +27,14 @@
#include "context.h"
#include "../../instruction.h"
-#include "../../../format/format.h"
/* Encadre les sauts à partir de registres ARMv7. */
-void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *);
+void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *);
/* Détecte les fins de procédures à base d'instructions 'pop'. */
-void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *);
+void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *);
diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c
index b6c0f14..9abe232 100644
--- a/src/arch/arm/v7/post.c
+++ b/src/arch/arm/v7/post.c
@@ -43,10 +43,11 @@
* *
******************************************************************************/
-void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format)
+void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format)
{
GArchOperand *op; /* Opérande numérique en place */
uint32_t addr; /* Adresse visée par le saut */
+ GBinFormat *bfmt; /* Version basique du format */
GArchOperand *new; /* Instruction de ciblage */
vmpa2t target;
mrange_t trange; /* Etendue du symbole à créer */
@@ -62,11 +63,13 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc
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))
+ && g_exe_format_translate_address_into_vmpa(format, addr, &target))
{
+ bfmt = G_BIN_FORMAT(format);
+
new = g_target_operand_new(MDS_32_BITS_UNSIGNED, addr);
- if (!g_target_operand_resolve(G_TARGET_OPERAND(new), format, true))
+ if (!g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true))
{
addr &= ~0x1;
@@ -96,11 +99,11 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc
symbol = g_binary_symbol_new(STP_CODE_LABEL);
g_binary_symbol_attach_routine(symbol, routine);
- g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
+ g_binary_format_add_symbol(bfmt, symbol);
- g_target_operand_resolve(G_TARGET_OPERAND(new), format, true);
+ g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true);
}
else
diff --git a/src/arch/arm/v7/post.h b/src/arch/arm/v7/post.h
index 5237045..a8acb3c 100644
--- a/src/arch/arm/v7/post.h
+++ b/src/arch/arm/v7/post.h
@@ -27,23 +27,22 @@
#include "../../instruction.h"
#include "../../post.h"
-#include "../../../format/format.h"
-static inline void post_process_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt)
+static inline void post_process_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt)
{
post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_CODE_LABEL);
}
-static inline void post_process_branch_and_link_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt)
+static inline void post_process_branch_and_link_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt)
{
post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_ROUTINE);
}
-static inline void post_process_comp_and_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt)
+static inline void post_process_comp_and_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt)
{
post_process_target_resolution(ins, proc, ctx, fmt, 1, STP_CODE_LABEL);
@@ -51,7 +50,7 @@ static inline void post_process_comp_and_branch_instructions(GArchInstruction *i
/* Complète un désassemblage accompli pour une instruction. */
-void post_process_ldr_instructions(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *);
+void post_process_ldr_instructions(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *);