diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-01-30 23:37:39 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-01-30 23:37:39 (GMT) |
commit | d246c98c515cb44c5bc4c742a674bae2e824872b (patch) | |
tree | 2ea1ec27ae5fba761ee778ba4ddb85c7752ebbf5 /src/arch/arm | |
parent | 262c95e0b088a56e9fd919edc57ad19f85e2e40e (diff) |
Bound a symbol for each loaded value for 'ldr' instructions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@462 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm')
-rw-r--r-- | src/arch/arm/v7/link.c | 86 |
1 files changed, 75 insertions, 11 deletions
diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c index da5e30e..308d4e5 100644 --- a/src/arch/arm/v7/link.c +++ b/src/arch/arm/v7/link.c @@ -25,10 +25,15 @@ #include <assert.h> -#include <operands/offset.h> +#include <malloc.h> +#include <i18n.h> + + +#include "operands/offset.h" #include "../register.h" +#include "../../raw.h" @@ -347,21 +352,20 @@ void handle_links_with_instruction_ldr_literal_with_orig(GArchInstruction *instr phys_t phys_pc; /* Position dans l'exécution */ GArchOperand *op; /* Opérande de surcouche */ GArchOperand *sub_op; /* Opérande numérique en place */ - - uint32_t offset; /* Décallage encodé en dur */ bool ret; /* Bilan d'une récupération */ - - off_t val_offset; /* Position de valeur à lire */ - - - + vmpa2t sym_addr; /* Adresse de nouveau symbole */ off_t length; /* Taille des données à lire */ const bin_t *data; /* Données binaires à lire */ - - uint32_t target; /* Adresse virtuelle visée */ + mrange_t sym_range; /* Espace du nouveau symbole */ + VMPA_BUFFER(loc); /* Adresse au format texte */ + size_t name_len; /* Taille de nomination finale */ + char *name; /* Désignation humaine */ + GArchInstruction *sym_instr; /* Instruction de symbole */ + GBinSymbol *symbol; /* Nouveau symbole construit */ + GDbComment *comment; /* Définition de commentaire */ GArchOperand *new; /* Instruction de ciblage */ /* Récupération de l'adresse visée par le chargement */ @@ -401,13 +405,24 @@ void handle_links_with_instruction_ldr_literal_with_orig(GArchInstruction *instr return; } - /* Lecture de la valeur vers laquelle renvoyer */ + /* Transformations et conservation d'une position de symbole */ if (g_armv7_offset_operand_is_positive(G_ARMV7_OFFSET_OPERAND(op))) val_offset = phys_pc + offset; else val_offset = phys_pc - offset; + init_vmpa(&sym_addr, val_offset, VMPA_NO_VIRTUAL); + init_mrange(&sym_range, &sym_addr, 4); + + + + + + + + + /* Lecture de la valeur vers laquelle renvoyer */ data = g_binary_format_get_content(format, &length); @@ -422,6 +437,55 @@ void handle_links_with_instruction_ldr_literal_with_orig(GArchInstruction *instr printf(">>>>>>> @got target :: 0x%08x\n", (unsigned int)target); + + + + /* Réalise l'intégration du symbole associé */ + + sym_instr = g_raw_instruction_new_from_value(&sym_addr, MDS_32_BITS_UNSIGNED, target); + + name_len = strlen(_("Value used @ %s")) + VMPA_MAX_LEN + 1; + + name = (char *)calloc(name_len, sizeof(char)); + + 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); + + free(name); + + + + g_proc_context_push_new_symbol_at(G_PROC_CONTEXT(context), &sym_addr); + printf("repush :: from 0x%x :: %x / %x\n", + (unsigned int)get_phy_addr(get_mrange_addr(range)), + (unsigned int)sym_addr.physical, (unsigned int)sym_addr.virtual); + + + printf("add sym %p\n", symbol); + + + + //g_proc_context_push_new_symbol_at(context, &sym_addr); + + + + + + + + + + + + + + + + + + //g_imm_operand_set_value(G_IMM_OPERAND(sub_op), MDS_32_BITS_UNSIGNED, target); |