diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-01-15 14:47:04 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-01-15 14:47:04 (GMT) |
commit | af2ac16182b6243f17e06ec75e441014159abe5e (patch) | |
tree | f0e82673bf5e63e3b06244c2139d8f10dca0203f /src/arch/target.c | |
parent | 56e060d11c238ac7c7b3ecf0eb0527bbaebd5b4b (diff) |
Improved symbol resolving using fully defined locations.
Diffstat (limited to 'src/arch/target.c')
-rw-r--r-- | src/arch/target.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/arch/target.c b/src/arch/target.c index 4655351..63ae295 100644 --- a/src/arch/target.c +++ b/src/arch/target.c @@ -43,7 +43,7 @@ struct _GTargetOperand GArchOperand parent; /* Instance parente */ MemoryDataSize size; /* Taille de l'opérande */ - virt_t addr; /* Adresse de l'élément visé */ + vmpa2t addr; /* Adresse de l'élément visé */ GBinSymbol *symbol; /* Eventuel symbole associé */ phys_t diff; /* Position dans le symbole */ @@ -171,7 +171,7 @@ static void g_target_operand_finalize(GTargetOperand *operand) /****************************************************************************** * * * Paramètres : size = taille des adresse mémoire virtuelles. * -* addr = adresse virtuelle d'un élément à retrouver. * +* addr = localisation d'un élément à retrouver. * * * * Description : Crée un opérande réprésentant une valeur numérique. * * * @@ -181,14 +181,14 @@ static void g_target_operand_finalize(GTargetOperand *operand) * * ******************************************************************************/ -GArchOperand *g_target_operand_new(MemoryDataSize size, virt_t addr) +GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr) { GTargetOperand *result; /* Opérande à retourner */ result = g_object_new(G_TYPE_TARGET_OPERAND, NULL); result->size = size; - result->addr = addr; + copy_vmpa(&result->addr, addr); return G_ARCH_OPERAND(result); @@ -240,8 +240,7 @@ static void g_target_operand_print(const GTargetOperand *operand, GBufferLine *l } else { - init_vmpa(&tmp, VMPA_NO_PHYSICAL, operand->addr); - vmpa2_virt_to_string(&tmp, operand->size, value, &len); + vmpa2_virt_to_string(&operand->addr, operand->size, value, &len); g_buffer_line_append_text(line, BLC_MAIN, value, len, RTT_LABEL, G_OBJECT(operand)); @@ -271,19 +270,20 @@ MemoryDataSize g_target_operand_get_size(const GTargetOperand *operand) /****************************************************************************** * * -* Paramètres : operand = structure dont le contenu est à définir. * +* Paramètres : operand = structure dont le contenu est à consulter. * +* addr = localisation à renseigner. [OUT] * * * * Description : Fournit l'adresse en mémoire de l'élément visé. * * * -* Retour : Adresse en mémoire virtuelle associée. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -virt_t g_target_operand_get_addr(const GTargetOperand *operand) +void g_target_operand_get_addr(const GTargetOperand *operand, vmpa2t *addr) { - return operand->addr; + copy_vmpa(addr, &operand->addr); } @@ -305,17 +305,11 @@ virt_t g_target_operand_get_addr(const GTargetOperand *operand) bool g_target_operand_resolve(GTargetOperand *operand, GBinFormat *format, bool strict) { bool result; /* Bilan à retourner */ - vmpa2t addr; /* Adresse de recherche */ if (operand->symbol != NULL) g_object_unref(G_OBJECT(operand->symbol)); - operand->symbol = NULL; - operand->diff = 0; - - init_vmpa(&addr, VMPA_NO_PHYSICAL, operand->addr); - - result = g_binary_format_resolve_symbol(format, &addr, strict, &operand->symbol, &operand->diff); + result = g_binary_format_resolve_symbol(format, &operand->addr, strict, &operand->symbol, &operand->diff); return result; @@ -337,9 +331,16 @@ bool g_target_operand_resolve(GTargetOperand *operand, GBinFormat *format, bool GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *operand, phys_t *diff) { + GBinSymbol *result; /* Symbole associé à retourner */ + if (diff != NULL) *diff = operand->diff; - return operand->symbol; + result = operand->symbol; + + if (result != NULL) + g_object_ref(G_OBJECT(result)); + + return result; } |