summaryrefslogtreecommitdiff
path: root/src/arch/arm/v7
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-12-04 08:01:50 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-12-04 08:01:50 (GMT)
commit6803c5d5b86416d1748d4d37a5cc5cb44fe007b1 (patch)
treea7a1c2aa9b946a134e93fc6d0c720111f6122138 /src/arch/arm/v7
parent172fce9bab61de1ffa89f731b5d10f96e209afc1 (diff)
Processed ARM / Thumb16 / Thumb32 data int the proper way.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@434 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm/v7')
-rw-r--r--src/arch/arm/v7/processor.c67
-rw-r--r--src/arch/arm/v7/thumb_32.c8
2 files changed, 34 insertions, 41 deletions
diff --git a/src/arch/arm/v7/processor.c b/src/arch/arm/v7/processor.c
index 7f263a6..dac9639 100644
--- a/src/arch/arm/v7/processor.c
+++ b/src/arch/arm/v7/processor.c
@@ -205,60 +205,59 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
{
GArchInstruction *result; /* Instruction à renvoyer */
phys_t start; /* Point de départ de lecture */
- uint32_t raw; /* Donnée 32 bits à analyser */
-
-
-
- //printf("Position :: 0x%x\n", (unsigned int)get_phy_addr(pos));
-
- // @ 0xae6c
- // 0xe1a0000a
-
- // 1110 0001 1010 0000 0000 0000 0000 1010
-
-
- //exit(1);
+ phys_t diff; /* Avancée dans la lecture */
+ uint16_t raw16; /* Donnée 16 bits à analyser */
+ uint32_t raw32; /* Donnée 32 bits à analyser */
+ start = get_phy_addr(pos);
+ diff = 4;
+ if (1/*Thumb*/)
+ {
+ if (!read_u16(&raw16, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
+ return NULL;
+ switch (raw16 >> 11)
+ {
+ case 0b11101:
+ case 0b11110:
+ case 0b11111:
- start = get_phy_addr(pos);
+ raw32 = raw16 << 16;
- if (!read_u32(&raw, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
- return NULL;
+ if (!read_u16(&raw16, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
+ return NULL;
- /*
- if (raw == 0xe1a0000a)
- printf("process @ 0x%x :: 0x%08x\n", start, raw);
- */
+ raw32 |= raw16;
- /*
- if (raw == 0xe1a0000a)
- printf("read !!!!!!!\n");
- */
+ result = process_armv7_thumb_32_instruction_set_encoding(raw32);
+ break;
- /* TODO : thumb... */
+ default:
+ diff = 2;
+ result = process_armv7_thumb_16_instruction_set_encoding(raw16);
+ break;
+ }
- //result = process_armv7_instruction_set_encoding(raw);
- result = process_armv7_thumb_32_instruction_set_encoding(raw);
+ }
+ else
+ {
+ if (!read_u32(&raw32, data, &start, end, G_ARCH_PROCESSOR(proc)->endianness))
+ return NULL;
- /*
- if (raw == 0xe1a0000a)
- printf(" --> %p\n", result);
- */
+ result = process_armv7_arm_instruction_set_encoding(raw32);
+ }
if (result != NULL)
- advance_vmpa(pos, 4);
+ advance_vmpa(pos, diff);
else
result = g_raw_instruction_new_array(data, MDS_32_BITS, 1, pos, end,
G_ARCH_PROCESSOR(proc)->endianness);
-
-
return result;
}
diff --git a/src/arch/arm/v7/thumb_32.c b/src/arch/arm/v7/thumb_32.c
index 6af804c..87233b4 100644
--- a/src/arch/arm/v7/thumb_32.c
+++ b/src/arch/arm/v7/thumb_32.c
@@ -128,9 +128,6 @@ GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t raw)
* § A6.3 32-bit Thumb instruction encoding
*/
- if (raw == 0x0b00f04f || raw == 0x4ff000b0)
- printf("[INIT] raw = 0x%x - mask :: %d\n", raw, (((raw >> 29) & b111) != b111));
-
if (((raw >> 29) & b111) != b111) return NULL;
result = NULL;
@@ -139,9 +136,6 @@ GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t raw)
op2 = (raw >> 20) & b1111111;
op = (raw >> 15) & b1;
- if (raw == 0x0b00f04f)
- printf("OP1 :: %d\n", op1);
-
switch (op1)
{
case b01:
@@ -244,7 +238,7 @@ static GArchInstruction *process_armv7_thumb_32_data_processing_modified_immedia
* § A6.3.1 Data-processing (modified immediate)
*/
- if ((raw & 0xfa0080000) != 0xf0000000) return NULL;
+ if ((raw & 0xfa008000) != 0xf0000000) return NULL;
result = NULL;