summaryrefslogtreecommitdiff
path: root/src/arch/arm/v7/link.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-01-09 22:30:16 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-01-09 22:30:16 (GMT)
commitcc3e31eecd90766ae4f0bb391428c5c59567ef4c (patch)
treee442bbaf401855f7bac411ac45e3545aa96ba661 /src/arch/arm/v7/link.c
parent50a4c165df49b04fe55278d5dcfa6b56d3cc1125 (diff)
Chosen the right encoding to use when disassembling ARM binary.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@452 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm/v7/link.c')
-rw-r--r--src/arch/arm/v7/link.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c
index 65ae09e..69b43bc 100644
--- a/src/arch/arm/v7/link.c
+++ b/src/arch/arm/v7/link.c
@@ -27,6 +27,9 @@
#include <assert.h>
+#include "context.h"
+
+
/******************************************************************************
* *
@@ -42,12 +45,14 @@
* *
******************************************************************************/
-void handle_links_with_thumb_instruction_bl(GArchInstruction *instr, GProcContext *context, GBinFormat *format)
+void handle_links_with_thumb_instruction_bl(GArchInstruction *instr, GArmV7Context *context, GBinFormat *format)
{
const mrange_t *range; /* Emplacementt d'instruction */
virt_t pc; /* Position dans l'exécution */
GArchOperand *op; /* Opérande numérique en place */
int32_t offset; /* Décallage encodé en dur */
+ virt_t target; /* Adresse virtuelle visée */
+ ArmV7InstrSet iset; /* Type de jeu courant */
range = g_arch_instruction_get_range(instr);
@@ -70,6 +75,11 @@ void handle_links_with_thumb_instruction_bl(GArchInstruction *instr, GProcContex
//printf("[@ 0x%08x] Add 0x%08x to %p\n", (uint32_t)get_virt_addr(get_mrange_addr(range)), (uint32_t)(pc + offset), context);
+ target = pc + offset;
+ iset = g_armv7_context_find_encoding(context, get_virt_addr(get_mrange_addr(range)));
+
+ g_armv7_context_define_encoding(context, target, iset);
+
}
@@ -87,12 +97,14 @@ void handle_links_with_thumb_instruction_bl(GArchInstruction *instr, GProcContex
* *
******************************************************************************/
-void handle_links_with_thumb_instruction_blx(GArchInstruction *instr, GProcContext *context, GBinFormat *format)
+void handle_links_with_thumb_instruction_blx(GArchInstruction *instr, GArmV7Context *context, GBinFormat *format)
{
const mrange_t *range; /* Emplacementt d'instruction */
virt_t pc; /* Position dans l'exécution */
GArchOperand *op; /* Opérande numérique en place */
int32_t offset; /* Décallage encodé en dur */
+ virt_t target; /* Adresse virtuelle visée */
+ ArmV7InstrSet iset; /* Type de jeu courant */
range = g_arch_instruction_get_range(instr);
@@ -116,5 +128,16 @@ void handle_links_with_thumb_instruction_blx(GArchInstruction *instr, GProcConte
//printf("[@ 0x%08x] Add 0x%08x to %p\n", (uint32_t)get_virt_addr(get_mrange_addr(range)), (uint32_t)(pc + offset), context);
+ target = pc + offset;
+ iset = g_armv7_context_find_encoding(context, get_virt_addr(get_mrange_addr(range)));
+
+ printf(" --link-- @ 0x%08x iset = %u\n", (unsigned int)target, (unsigned int)iset);
+
+ if (iset == AV7IS_ARM)
+ g_armv7_context_define_encoding(context, target, AV7IS_THUMB);
+ else
+ g_armv7_context_define_encoding(context, target, AV7IS_ARM);
+
+
}