summaryrefslogtreecommitdiff
path: root/src/arch/post.c
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/post.c
parentb3efd0bbc506e701ea9872f50b8b4db974f35954 (diff)
Applied some code refactoring to remove usages of GBinFormat in favor of GExeFormat.
Diffstat (limited to 'src/arch/post.c')
-rw-r--r--src/arch/post.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/arch/post.c b/src/arch/post.c
index 4cc6d12..ebbf40b 100644
--- a/src/arch/post.c
+++ b/src/arch/post.c
@@ -49,16 +49,17 @@
* *
******************************************************************************/
-void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format, size_t index, SymbolType type)
+void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format, size_t index, SymbolType type)
{
GArchOperand *op; /* Opérande numérique en place */
virt_t addr; /* Adresse visée par le saut */
+ GBinFormat *bfmt; /* Version basique du format */
MemoryDataSize ptr_size; /* Taille de l'espace mémoire */
GArchOperand *new; /* Instruction de ciblage */
- vmpa2t target;
+ vmpa2t target; /* Emplacement de la cible */
mrange_t trange; /* Etendue du symbole à créer */
- VMPA_BUFFER(loc);
- char name[5 + VMPA_MAX_LEN];
+ VMPA_BUFFER(loc); /* Conversion en chaîne */
+ char name[5 + VMPA_MAX_LEN]; /* Etiquette de la destination */
GBinRoutine *routine; /* Nouvelle routine trouvée */
GBinSymbol *symbol; /* Nouveau symbole construit */
@@ -66,13 +67,15 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro
assert(G_IS_IMM_OPERAND(op));
if (g_imm_operand_to_virt_t(G_IMM_OPERAND(op), &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);
+
ptr_size = g_arch_processor_get_memory_size(proc);
new = g_target_operand_new(ptr_size, addr);
- if (!g_target_operand_resolve(G_TARGET_OPERAND(new), format, true))
+ if (!g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true))
{
vmpa2_virt_to_string(&target, MDS_UNDEFINED, loc, NULL);
@@ -100,9 +103,9 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro
symbol = g_binary_symbol_new(type);
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);
}