summaryrefslogtreecommitdiff
path: root/src/arch/arm/v7
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-12-05 22:32:21 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-12-05 22:32:21 (GMT)
commit0a7b9b66bdcf386a36ec13ec480b52aa17406385 (patch)
tree95b9cfac29b50aa92eac9cbc9e754c9787f55438 /src/arch/arm/v7
parent12154652c576144405011b5bd267c15c9667f223 (diff)
Defined a new kind of operands for memory accesses.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@436 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm/v7')
-rw-r--r--src/arch/arm/v7/helpers.h106
-rw-r--r--src/arch/arm/v7/opcodes/Makefile.am6
-rw-r--r--src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h4
-rw-r--r--src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h3
-rw-r--r--src/arch/arm/v7/opdefs/Makefile.am4
-rw-r--r--src/arch/arm/v7/opdefs/ldr_A8862.d137
-rw-r--r--src/arch/arm/v7/opdefs/ldr_A8864.d78
-rw-r--r--src/arch/arm/v7/opdefs/mov_A88102.d2
-rw-r--r--src/arch/arm/v7/opdefs/mov_A88103.d90
-rw-r--r--src/arch/arm/v7/opdefs/str_A88203.d135
-rw-r--r--src/arch/arm/v7/operands/Makefile.am2
-rw-r--r--src/arch/arm/v7/operands/maccess.c281
-rw-r--r--src/arch/arm/v7/operands/maccess.h69
-rw-r--r--src/arch/arm/v7/operands/offset.c243
-rw-r--r--src/arch/arm/v7/operands/offset.h66
-rw-r--r--src/arch/arm/v7/operands/shift.c22
-rw-r--r--src/arch/arm/v7/operands/shift.h10
-rw-r--r--src/arch/arm/v7/thumb_32.c4
18 files changed, 1198 insertions, 64 deletions
diff --git a/src/arch/arm/v7/helpers.h b/src/arch/arm/v7/helpers.h
index 394302b..4ef7087 100644
--- a/src/arch/arm/v7/helpers.h
+++ b/src/arch/arm/v7/helpers.h
@@ -29,6 +29,8 @@
#include "pseudo.h"
+#include "operands/maccess.h"
+#include "operands/offset.h"
#include "operands/shift.h"
#include "../../operand.h"
@@ -36,48 +38,48 @@
-#define ARMExpandImm_C(imm12, c) \
- ({ \
- GArchOperand *__result; \
- uint32_t __val; \
- if (armv7_arm_expand_imm_c(imm12, (bool []) { c }, &__val)) \
- __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
- else \
- __result = NULL; \
- __result; \
+#define ARMExpandImm_C(imm12, c) \
+ ({ \
+ GArchOperand *__result; \
+ uint32_t __val; \
+ if (armv7_arm_expand_imm_c(imm12, (bool []) { c }, &__val)) \
+ __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
+ else \
+ __result = NULL; \
+ __result; \
})
-#define ARMExpandImm(imm12) \
- ({ \
- GArchOperand *__result; \
- uint32_t __val; \
- if (armv7_arm_expand_imm(imm12, &__val)) \
- __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
- else \
- __result = NULL; \
- __result; \
+#define ARMExpandImm(imm12) \
+ ({ \
+ GArchOperand *__result; \
+ uint32_t __val; \
+ if (armv7_arm_expand_imm(imm12, &__val)) \
+ __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
+ else \
+ __result = NULL; \
+ __result; \
})
-#define ThumbExpandImm_C(imm12, c) \
- ({ \
- GArchOperand *__result; \
- uint32_t __val; \
- if (armv7_thumb_expand_imm_c(imm12, (bool []) { c }, &__val)) \
- __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
- else \
- __result = NULL; \
- __result; \
+#define ThumbExpandImm_C(imm12, c) \
+ ({ \
+ GArchOperand *__result; \
+ uint32_t __val; \
+ if (armv7_thumb_expand_imm_c(imm12, (bool []) { c }, &__val)) \
+ __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
+ else \
+ __result = NULL; \
+ __result; \
})
-#define ThumbExpandImm(imm12) \
- ({ \
- GArchOperand *__result; \
- uint32_t __val; \
- if (armv7_thumb_expand_imm(imm12, &__val)) \
- __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
- else \
- __result = NULL; \
- __result; \
+#define ThumbExpandImm(imm12) \
+ ({ \
+ GArchOperand *__result; \
+ uint32_t __val; \
+ if (armv7_thumb_expand_imm(imm12, &__val)) \
+ __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \
+ else \
+ __result = NULL; \
+ __result; \
})
@@ -86,8 +88,8 @@
-#define DecodeImmShift(type, imm5) \
- ({ \
+#define DecodeImmShift(type, imm5) \
+ ({ \
GArchOperand *__result; \
SRType __shift_t; \
uint32_t __shift_n; \
@@ -142,6 +144,34 @@ return shift_t;
+
+
+
+/**
+ * Glue purement interne.
+ */
+
+
+#define MakeAccessOffset(add, off) \
+ g_armv7_offset_operand_new(add, off)
+
+
+#define MakeMemoryAccess(base, off, add, wr) \
+ ({ \
+ GArchOperand *__off; \
+ __off = MakeAccessOffset(add, off); \
+ g_armv7_maccess_operand_new(base, __off, wr); \
+ })
+
+
+#define MakeMemoryNotIndexed(base, wr) \
+ g_armv7_maccess_operand_new(base, NULL, wr)
+
+
+
+
+
+
/* Effectue une rotation vers la droit d'une valeur. */
GArchOperand *ror_armv7_imm(uint32_t, unsigned int);
diff --git a/src/arch/arm/v7/opcodes/Makefile.am b/src/arch/arm/v7/opcodes/Makefile.am
index b2f5695..30d0e16 100644
--- a/src/arch/arm/v7/opcodes/Makefile.am
+++ b/src/arch/arm/v7/opcodes/Makefile.am
@@ -12,6 +12,7 @@ libarcharmv7opcodes_la_SOURCES = \
arm_cmn.c \
arm_cmp.c \
arm_eor.c \
+ arm_ldr.c \
arm_mla.c \
arm_mls.c \
arm_mov.c \
@@ -23,6 +24,7 @@ libarcharmv7opcodes_la_SOURCES = \
arm_sbc.c \
arm_smlal.c \
arm_smull.c \
+ arm_str.c \
arm_sub.c \
arm_subs.c \
arm_teq.c \
@@ -40,6 +42,7 @@ libarcharmv7opcodes_la_SOURCES = \
thumb_16_cmn.c \
thumb_16_cmp.c \
thumb_16_eor.c \
+ thumb_16_ldr.c \
thumb_16_mla.c \
thumb_16_mls.c \
thumb_16_mov.c \
@@ -51,6 +54,7 @@ libarcharmv7opcodes_la_SOURCES = \
thumb_16_sbc.c \
thumb_16_smlal.c \
thumb_16_smull.c \
+ thumb_16_str.c \
thumb_16_sub.c \
thumb_16_subs.c \
thumb_16_teq.c \
@@ -68,6 +72,7 @@ libarcharmv7opcodes_la_SOURCES = \
thumb_32_cmn.c \
thumb_32_cmp.c \
thumb_32_eor.c \
+ thumb_32_ldr.c \
thumb_32_mla.c \
thumb_32_mls.c \
thumb_32_mov.c \
@@ -79,6 +84,7 @@ libarcharmv7opcodes_la_SOURCES = \
thumb_32_sbc.c \
thumb_32_smlal.c \
thumb_32_smull.c \
+ thumb_32_str.c \
thumb_32_sub.c \
thumb_32_subs.c \
thumb_32_teq.c \
diff --git a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h b/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h
index 3f7e8e5..4620f83 100644
--- a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h
+++ b/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h
@@ -25,8 +25,6 @@
#define armv7_read_thumb_16_instr_ldrb_register(r) NULL
#define armv7_read_thumb_16_instr_ldrh_immediate_thumb(r) NULL
#define armv7_read_thumb_16_instr_ldrh_register(r) NULL
-#define armv7_read_thumb_16_instr_ldr_immediate_thumb(r) NULL
-#define armv7_read_thumb_16_instr_ldr_literal(r) NULL
#define armv7_read_thumb_16_instr_ldr_register_thumb(r) NULL
#define armv7_read_thumb_16_instr_ldrsb_register(r) NULL
#define armv7_read_thumb_16_instr_ldrsh_register(r) NULL
@@ -34,7 +32,6 @@
#define armv7_read_thumb_16_instr_lsl_register(r) NULL
#define armv7_read_thumb_16_instr_lsr_immediate(r) NULL
#define armv7_read_thumb_16_instr_lsr_register(r) NULL
-#define armv7_read_thumb_16_instr_mov_register_thumb(r) NULL
#define armv7_read_thumb_16_instr_mul(r) NULL
#define armv7_read_thumb_16_instr_mvn_register(r) NULL
#define armv7_read_thumb_16_instr_nop(r) NULL
@@ -54,7 +51,6 @@
#define armv7_read_thumb_16_instr_strb_register(r) NULL
#define armv7_read_thumb_16_instr_strh_immediate_thumb(r) NULL
#define armv7_read_thumb_16_instr_strh_register(r) NULL
-#define armv7_read_thumb_16_instr_str_immediate_thumb(r) NULL
#define armv7_read_thumb_16_instr_str_register(r) NULL
#define armv7_read_thumb_16_instr_sub_immediate_thumb(r) NULL
#define armv7_read_thumb_16_instr_sub_register(r) NULL
diff --git a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h b/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h
index 8cd59a0..999cd0d 100644
--- a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h
+++ b/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h
@@ -22,8 +22,6 @@
#define armv7_read_thumb_32_instr_isb(r) NULL
#define armv7_read_thumb_32_instr_ldmdb_ldmea(r) NULL
#define armv7_read_thumb_32_instr_ldm_ldmia_ldmfd_thumb(r) NULL
-#define armv7_read_thumb_32_instr_ldr_immediate_thumb(r) NULL
-#define armv7_read_thumb_32_instr_ldr_literal(r) NULL
#define armv7_read_thumb_32_instr_ldr_register_thumb(r) NULL
#define armv7_read_thumb_32_instr_ldrt(r) NULL
#define armv7_read_thumb_32_instr_lsl_register(r) NULL
@@ -97,7 +95,6 @@
#define armv7_read_thumb_32_instr_strh_immediate_thumb(r) NULL
#define armv7_read_thumb_32_instr_strh_register(r) NULL
#define armv7_read_thumb_32_instr_strht(r) NULL
-#define armv7_read_thumb_32_instr_str_immediate_thumb(r) NULL
#define armv7_read_thumb_32_instr_str_register(r) NULL
#define armv7_read_thumb_32_instr_strt(r) NULL
#define armv7_read_thumb_32_instr_sub_immediate_thumb(r) NULL
diff --git a/src/arch/arm/v7/opdefs/Makefile.am b/src/arch/arm/v7/opdefs/Makefile.am
index ff9f4a5..348cbf6 100644
--- a/src/arch/arm/v7/opdefs/Makefile.am
+++ b/src/arch/arm/v7/opdefs/Makefile.am
@@ -38,9 +38,12 @@ ARMV7_DEFS = \
cmp_A8838.d \
eor_A8846.d \
eor_A8847.d \
+ ldr_A8862.d \
+ ldr_A8864.d \
mla_A88100.d \
mls_A88101.d \
mov_A88102.d \
+ mov_A88103.d \
mov_A88104.d \
mul_A88114.d \
mvn_A88115.d \
@@ -55,6 +58,7 @@ ARMV7_DEFS = \
sbc_A88162.d \
smlal_A88178.d \
smull_A88189.d \
+ str_A88203.d \
sub_A88222.d \
sub_A88223.d \
teq_A88237.d \
diff --git a/src/arch/arm/v7/opdefs/ldr_A8862.d b/src/arch/arm/v7/opdefs/ldr_A8862.d
new file mode 100644
index 0000000..7799fce
--- /dev/null
+++ b/src/arch/arm/v7/opdefs/ldr_A8862.d
@@ -0,0 +1,137 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ##FILE## - traduction d'instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+@title LDR (immediate, Thumb)
+
+@encoding(t1) {
+
+ @half 0 1 1 0 1 imm5(5) Rn(3) Rt(3)
+
+ @syntax <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm5:'00', 7, 32);
+ access = MakeMemoryAccess(Rgn, imm32, 1, 0)
+
+ }
+
+}
+
+@encoding(t2) {
+
+ @half 1 0 0 1 1 Rt(3) imm8(8)
+
+ @syntax <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Sp = Register(13)
+ imm32 = ZeroExtend(imm8:'00', 10, 32);
+ access = MakeMemoryAccess(Sp, imm32, 1, 0)
+
+ }
+
+}
+
+@encoding(T3) {
+
+ @word 1 1 1 1 1 0 0 0 1 1 0 1 Rn(4) Rt(4) imm12(12)
+
+ @syntax "ldr.W" <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm12, 12, 32);
+ access = MakeMemoryAccess(Rgn, imm32, 1, 0)
+
+ }
+
+ @rules {
+
+ //if Rn == '1111' then SEE LDR (literal);
+ //if t == 15 && InITBlock() && !LastInITBlock() then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(T41) {
+
+ @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 1 U(1) W(1) imm8(8)
+
+ @syntax <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm8, 8, 32);
+ access = MakeMemoryAccess(Rgn, imm32, U, W)
+
+ }
+
+ @rules {
+
+ //if Rn == '1111' then SEE LDR (literal);
+ //if P == '1' && U == '1' && W == '0' then SEE LDRT;
+ //if Rn == '1101' && P == '0' && U == '1' && W == '1' && imm8 == '00000100' then SEE POP;
+ //if P == '0' && W == '0' then UNDEFINED;
+ //if (wback && n == t) || (t == 15 && InITBlock() && !LastInITBlock()) then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(T42) {
+
+ @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 0 U(1) W(1) imm8(8)
+
+ @syntax <Rgt> <base> <offset>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm8, 8, 32);
+ base = MakeMemoryNotIndexed(Rgn, W)
+ offset = MakeAccessOffset(U, imm32)
+
+ }
+
+ @rules {
+
+ //if Rn == '1111' then SEE LDR (literal);
+ //if P == '1' && U == '1' && W == '0' then SEE LDRT;
+ //if Rn == '1101' && P == '0' && U == '1' && W == '1' && imm8 == '00000100' then SEE POP;
+ //if P == '0' && W == '0' then UNDEFINED;
+ //if (wback && n == t) || (t == 15 && InITBlock() && !LastInITBlock()) then UNPREDICTABLE;
+
+ }
+
+}
diff --git a/src/arch/arm/v7/opdefs/ldr_A8864.d b/src/arch/arm/v7/opdefs/ldr_A8864.d
new file mode 100644
index 0000000..acb6f94
--- /dev/null
+++ b/src/arch/arm/v7/opdefs/ldr_A8864.d
@@ -0,0 +1,78 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ##FILE## - traduction d'instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+@title LDR (literal)
+
+@encoding(t1) {
+
+ @half 0 1 0 0 1 Rt(3) imm8(8)
+
+ @syntax <Rgt> <label>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ imm32 = ZeroExtend(imm8:'00', 10, 32)
+ label = MakeAccessOffset(1, imm32)
+
+ }
+
+}
+
+@encoding(T2) {
+
+ @word 1 1 1 1 1 0 0 0 U(1) 1 0 1 1 1 1 1 Rt(4) imm12(12)
+
+ @syntax <Rgt> <label>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ imm32 = ZeroExtend(imm12, 12, 32)
+ label = MakeAccessOffset(U, imm32)
+
+ }
+
+ @rules {
+
+ //if t == 15 && InITBlock() && !LastInITBlock() then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(A1) {
+
+ @word cond(4) 0 1 0 1 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12)
+
+ @syntax <Rgt> <label>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ imm32 = ZeroExtend(imm12, 12, 32)
+ label = MakeAccessOffset(U, imm32)
+
+ }
+
+}
diff --git a/src/arch/arm/v7/opdefs/mov_A88102.d b/src/arch/arm/v7/opdefs/mov_A88102.d
index a71969f..ae67b22 100644
--- a/src/arch/arm/v7/opdefs/mov_A88102.d
+++ b/src/arch/arm/v7/opdefs/mov_A88102.d
@@ -108,7 +108,7 @@
@word cond(4) 0 0 1 1 0 0 0 0 imm4(4) Rd(4) imm12(12)
- @syntax {c} <Rd> <const>
+ @syntax "movw" {c} <Rd> <const>
@conv {
diff --git a/src/arch/arm/v7/opdefs/mov_A88103.d b/src/arch/arm/v7/opdefs/mov_A88103.d
new file mode 100644
index 0000000..d1f9b9c
--- /dev/null
+++ b/src/arch/arm/v7/opdefs/mov_A88103.d
@@ -0,0 +1,90 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ##FILE## - traduction d'instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+@title MOV (register, Thumb)
+
+@encoding(t1) {
+
+ @half 0 1 0 0 0 1 1 0 D(1) Rm(4) Rd(3)
+
+ @syntax <Rgd> <Rgm>
+
+ @conv {
+
+ Rgd = Register(D:Rd)
+ Rgm = Register(Rm)
+
+ }
+
+ @rules {
+
+ //if d == 15 && InITBlock() && !LastInITBlock() then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(t2) {
+
+ @half 0 0 0 0 0 0 0 0 0 0 Rm(3) Rd(3)
+
+ @syntax <Rgd> <Rgm>
+
+ @conv {
+
+ S = SetFlags(1)
+ Rgd = Register(Rd)
+ Rgm = Register(Rm)
+
+ }
+
+ @rules {
+
+ //if InITBlock() then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(T3) {
+
+ @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 0 0 0 Rd(4) 0 0 0 0 Rm(4)
+
+ @syntax {S} <Rgd> <Rgm>
+
+ @conv {
+
+ S = SetFlags(S)
+ Rgd = Register(Rd)
+ Rgm = Register(Rm)
+
+ }
+
+ @rules {
+
+ //if setflags && (d IN {13,15} || m IN {13,15}) then UNPREDICTABLE;
+ //if !setflags && (d == 15 || m == 15 || (d == 13 && m == 13)) then UNPREDICTABLE;
+
+ }
+
+}
diff --git a/src/arch/arm/v7/opdefs/str_A88203.d b/src/arch/arm/v7/opdefs/str_A88203.d
new file mode 100644
index 0000000..2952e1a
--- /dev/null
+++ b/src/arch/arm/v7/opdefs/str_A88203.d
@@ -0,0 +1,135 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ##FILE## - traduction d'instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+@title STR (immediate, Thumb)
+
+@encoding(t1) {
+
+ @half 0 1 1 0 0 imm5(5) Rn(3) Rt(3)
+
+ @syntax <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm5:'00', 7, 32);
+ access = MakeMemoryAccess(Rgn, imm32, 1, 0)
+
+ }
+
+}
+
+@encoding(t2) {
+
+ @half 1 0 0 1 0 Rt(3) imm8(8)
+
+ @syntax <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Sp = Register(13)
+ imm32 = ZeroExtend(imm8:'00', 10, 32);
+ access = MakeMemoryAccess(Sp, imm32, 1, 0)
+
+ }
+
+}
+
+@encoding(T3) {
+
+ @word 1 1 1 1 1 0 0 0 1 1 0 0 Rn(4) Rt(4) imm12(12)
+
+ @syntax "str.W" <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm12, 12, 32);
+ access = MakeMemoryAccess(Rgn, imm32, 1, 0)
+
+ }
+
+ @rules {
+
+ //if Rn == '1111' then UNDEFINED;
+ //if t == 15 then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(T41) {
+
+ @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 1 1 U(1) W(1) imm8(8)
+
+ @syntax <Rgt> <access>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm8, 8, 32);
+ access = MakeMemoryAccess(Rgn, imm32, U, W)
+
+ }
+
+ @rules {
+
+ //if P == '1' && U == '1' && W == '0' then SEE STRT;
+ //if Rn == '1101' && P == '1' && U == '0' && W == '1' && imm8 == '00000100' then SEE PUSH;
+ //if Rn == '1111' || (P == '0' && W == '0') then UNDEFINED;
+ //if t == 15 || (wback && n == t) then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(T42) {
+
+ @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 1 0 U(1) W(1) imm8(8)
+
+ @syntax <Rgt> <base> <offset>
+
+ @conv {
+
+ Rgt = Register(Rt)
+ Rgn = Register(Rn)
+ imm32 = ZeroExtend(imm8, 8, 32);
+ base = MakeMemoryNotIndexed(Rgn, W)
+ offset = MakeAccessOffset(U, imm32)
+
+ }
+
+ @rules {
+
+ //if P == '1' && U == '1' && W == '0' then SEE STRT;
+ //if Rn == '1101' && P == '1' && U == '0' && W == '1' && imm8 == '00000100' then SEE PUSH;
+ //if Rn == '1111' || (P == '0' && W == '0') then UNDEFINED;
+ //if t == 15 || (wback && n == t) then UNPREDICTABLE;
+
+ }
+
+}
diff --git a/src/arch/arm/v7/operands/Makefile.am b/src/arch/arm/v7/operands/Makefile.am
index a14b644..8733bfe 100644
--- a/src/arch/arm/v7/operands/Makefile.am
+++ b/src/arch/arm/v7/operands/Makefile.am
@@ -2,6 +2,8 @@
noinst_LTLIBRARIES = libarcharmv7operands.la
libarcharmv7operands_la_SOURCES = \
+ maccess.h maccess.c \
+ offset.h offset.c \
shift.h shift.c
libarcharmv7operands_la_LIBADD =
diff --git a/src/arch/arm/v7/operands/maccess.c b/src/arch/arm/v7/operands/maccess.c
new file mode 100644
index 0000000..72b63d8
--- /dev/null
+++ b/src/arch/arm/v7/operands/maccess.c
@@ -0,0 +1,281 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * maccess.c - accès à la mémorie à partir d'un registre et d'un décallage
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "maccess.h"
+
+
+#include "../../../operand-int.h"
+
+
+
+/* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */
+struct _GArmV7MAccessOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ GArchOperand *base; /* Base de l'accès en mémoire */
+ GArchOperand *offset; /* Décallage pour l'adresse */
+ bool write_back; /* Mise à jour de la base */
+
+};
+
+
+/* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */
+struct _GArmV7MAccessOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des accès à la mémoire chez ARM. */
+static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *);
+
+/* Initialise une instance d'accès à la mémoire chez ARM. */
+static void g_armv7_maccess_operand_init(GArmV7MAccessOperand *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */
+G_DEFINE_TYPE(GArmV7MAccessOperand, g_armv7_maccess_operand, G_TYPE_ARCH_OPERAND);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des accès à la mémoire chez ARM. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GArchOperandClass *operand; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+ operand = G_ARCH_OPERAND_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_maccess_operand_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_armv7_maccess_operand_finalize;
+
+ operand->print = (operand_print_fc)g_armv7_maccess_operand_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise une instance d'accès à la mémoire chez ARM. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_maccess_operand_init(GArmV7MAccessOperand *operand)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *operand)
+{
+ g_object_unref(G_OBJECT(operand->base));
+
+ if (operand->offset != NULL)
+ g_object_unref(G_OBJECT(operand->offset));
+
+ G_OBJECT_CLASS(g_armv7_maccess_operand_parent_class)->dispose(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_maccess_operand_parent_class)->finalize(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : base = représente le registre de la base d'accès. *
+* offset = détermine le décallage entre l'adresse et la base. *
+* writeb = indique une mise à jour de la base après usage. *
+* *
+* Description : Crée un accès à la mémoire depuis une base et un décallage. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, bool writeb)
+{
+ GArmV7MAccessOperand *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_MACCESS_OPERAND, NULL);
+
+ result->base = base;
+ result->offset = offset;
+ result->write_back = writeb;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* line = ligne tampon où imprimer l'opérande donné. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Traduit un opérande en version humainement lisible. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "[", 1, RTT_HOOK);
+
+ g_arch_operand_print(operand->base, line, syntax);
+
+ if (operand->offset != NULL)
+ {
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW);
+
+ g_arch_operand_print(operand->offset, line, syntax);
+
+ }
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK);
+
+ if (operand->write_back)
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "!", 1, RTT_PUNCT);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Founit la base d'un accès à la mémoire. *
+* *
+* Retour : Opérande en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *operand)
+{
+ return operand->base;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Founit le décallage d'un accès à la mémoire depuis la base. *
+* *
+* Retour : Opérande en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *operand)
+{
+ return operand->offset;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Indique si la base est mise à jour après usage. *
+* *
+* Retour : Statut des opérations menées. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *operand)
+{
+ return operand->write_back;
+
+}
diff --git a/src/arch/arm/v7/operands/maccess.h b/src/arch/arm/v7/operands/maccess.h
new file mode 100644
index 0000000..9198cfa
--- /dev/null
+++ b/src/arch/arm/v7/operands/maccess.h
@@ -0,0 +1,69 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * maccess.h - prototypes pour les accès à la mémorie à partir d'un registre et d'un décallage
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_V7_OPERANDS_MACCESS_H
+#define _ARCH_ARM_V7_OPERANDS_MACCESS_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "../pseudo.h"
+#include "../../../operand.h"
+
+
+
+#define G_TYPE_ARMV7_MACCESS_OPERAND g_armv7_maccess_operand_get_type()
+#define G_ARMV7_MACCESS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_maccess_operand_get_type(), GArmV7MAccessOperand))
+#define G_IS_ARMV7_MACCESS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_maccess_operand_get_type()))
+#define G_ARMV7_MACCESS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_MACCESS_OPERAND, GArmV7MAccessOperandClass))
+#define G_IS_ARMV7_MACCESS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_MACCESS_OPERAND))
+#define G_ARMV7_MACCESS_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_MACCESS_OPERAND, GArmV7MAccessOperandClass))
+
+
+/* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */
+typedef struct _GArmV7MAccessOperand GArmV7MAccessOperand;
+
+/* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */
+typedef struct _GArmV7MAccessOperandClass GArmV7MAccessOperandClass;
+
+
+/* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */
+GType g_armv7_maccess_operand_get_type(void);
+
+/* Crée un accès à la mémoire depuis une base et un décallage. */
+GArchOperand *g_armv7_maccess_operand_new(GArchOperand *, GArchOperand *, bool);
+
+/* Founit la base d'un accès à la mémoire. */
+GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *);
+
+/* Founit le décallage d'un accès à la mémoire depuis la base. */
+GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *);
+
+/* Indique si la base est mise à jour après usage. */
+bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *);
+
+
+
+#endif /* _ARCH_ARM_V7_OPERANDS_MACCESS_H */
diff --git a/src/arch/arm/v7/operands/offset.c b/src/arch/arm/v7/operands/offset.c
new file mode 100644
index 0000000..9a9506a
--- /dev/null
+++ b/src/arch/arm/v7/operands/offset.c
@@ -0,0 +1,243 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * offset.c - constitution d'un décallage positif ou négatif
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "offset.h"
+
+
+#include "../../../operand-int.h"
+
+
+
+/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */
+struct _GArmV7OffsetOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ bool positive; /* Sens du décallage */
+ GArchOperand *value; /* Valeur du décallage */
+
+};
+
+
+/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (classe) */
+struct _GArmV7OffsetOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des décallages relatifs ARMv7. */
+static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *);
+
+/* Initialise une instance de décallage relatif ARMv7. */
+static void g_armv7_offset_operand_init(GArmV7OffsetOperand *);
+
+/* Supprime toutes les références externes. */
+static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini par la GLib pour un décallage relatif ARMv7. */
+G_DEFINE_TYPE(GArmV7OffsetOperand, g_armv7_offset_operand, G_TYPE_ARCH_OPERAND);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des décallages relatifs ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GArchOperandClass *operand; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+ operand = G_ARCH_OPERAND_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_offset_operand_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_armv7_offset_operand_finalize;
+
+ operand->print = (operand_print_fc)g_armv7_offset_operand_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise une instance de décallage relatif ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_offset_operand_init(GArmV7OffsetOperand *operand)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *operand)
+{
+ g_object_unref(G_OBJECT(operand->value));
+
+ G_OBJECT_CLASS(g_armv7_offset_operand_parent_class)->dispose(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *operand)
+{
+ G_OBJECT_CLASS(g_armv7_offset_operand_parent_class)->finalize(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : positive = indique si la quantité doit être ajoutée ou non. *
+* value = valeur du décallage à appliquer. *
+* *
+* Description : Crée un décallage selon un sens et une valeur donnés. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_offset_operand_new(bool positive, GArchOperand *value)
+{
+ GArmV7OffsetOperand *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV7_OFFSET_OPERAND, NULL);
+
+ result->positive = positive;
+ result->value = value;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* line = ligne tampon où imprimer l'opérande donné. *
+* syntax = type de représentation demandée. *
+* *
+* Description : Traduit un opérande en version humainement lisible. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ if (!operand->positive)
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "-", 1, RTT_KEY_WORD);
+
+ g_arch_operand_print(operand->value, line, syntax);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Indique le sens du décallage représenté. *
+* *
+* Retour : Indication d'ajout ou de retrait. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv7_offset_operand_is_positive(const GArmV7OffsetOperand *operand)
+{
+ return operand->positive;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Founit la valeur utilisée pour un décallage. *
+* *
+* Retour : Opérande en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *operand)
+{
+ return operand->value;
+
+}
diff --git a/src/arch/arm/v7/operands/offset.h b/src/arch/arm/v7/operands/offset.h
new file mode 100644
index 0000000..156a3c4
--- /dev/null
+++ b/src/arch/arm/v7/operands/offset.h
@@ -0,0 +1,66 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * offset.h - prototypes pour la constitution d'un décallage positif ou négatif
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_ARM_V7_OPERANDS_OFFSET_H
+#define _ARCH_ARM_V7_OPERANDS_OFFSET_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "../pseudo.h"
+#include "../../../operand.h"
+
+
+
+#define G_TYPE_ARMV7_OFFSET_OPERAND g_armv7_offset_operand_get_type()
+#define G_ARMV7_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_offset_operand_get_type(), GArmV7OffsetOperand))
+#define G_IS_ARMV7_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_offset_operand_get_type()))
+#define G_ARMV7_OFFSET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_OFFSET_OPERAND, GArmV7OffsetOperandClass))
+#define G_IS_ARMV7_OFFSET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_OFFSET_OPERAND))
+#define G_ARMV7_OFFSET_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_OFFSET_OPERAND, GArmV7OffsetOperandClass))
+
+
+/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */
+typedef struct _GArmV7OffsetOperand GArmV7OffsetOperand;
+
+/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (classe) */
+typedef struct _GArmV7OffsetOperandClass GArmV7OffsetOperandClass;
+
+
+/* Indique le type défini par la GLib pour un décallage relatif ARMv7. */
+GType g_armv7_offset_operand_get_type(void);
+
+/* Crée un décallage selon un sens et une valeur donnés. */
+GArchOperand *g_armv7_offset_operand_new(bool, GArchOperand *);
+
+/* Indique le sens du décallage représenté. */
+bool g_armv7_offset_operand_is_positive(const GArmV7OffsetOperand *);
+
+/* Founit la valeur utilisée pour un décallage. */
+GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *);
+
+
+
+#endif /* _ARCH_ARM_V7_OPERANDS_OFFSET_H */
diff --git a/src/arch/arm/v7/operands/shift.c b/src/arch/arm/v7/operands/shift.c
index 253302f..7a90a70 100644
--- a/src/arch/arm/v7/operands/shift.c
+++ b/src/arch/arm/v7/operands/shift.c
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * args.c - listes d'opérandes rassemblées en arguments
+ * shift.c - décallages de valeurs
*
* Copyright (C) 2010-2013 Cyrille Bagard
*
@@ -196,28 +196,28 @@ GArchOperand *g_armv7_shift_operand_new(SRType type, GArchOperand *value)
static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *operand, GBufferLine *line, AsmSyntax syntax)
{
- switch (operand->shift_type)
- {
+ switch (operand->shift_type)
+ {
case SRType_LSL:
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "lsl", 3, RTT_KEY_WORD);
- break;
+ break;
case SRType_LSR:
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "lsr", 3, RTT_KEY_WORD);
- break;
+ break;
case SRType_ASR:
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "asr", 3, RTT_KEY_WORD);
- break;
+ break;
case SRType_ROR:
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "ror", 3, RTT_KEY_WORD);
- break;
+ break;
case SRType_RRX:
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "rrx", 3, RTT_KEY_WORD);
- break;
- }
+ break;
+ }
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW);
- g_arch_operand_print(operand->shift_value, line, syntax);
+ g_arch_operand_print(operand->shift_value, line, syntax);
}
diff --git a/src/arch/arm/v7/operands/shift.h b/src/arch/arm/v7/operands/shift.h
index e39f6c0..06efef1 100644
--- a/src/arch/arm/v7/operands/shift.h
+++ b/src/arch/arm/v7/operands/shift.h
@@ -1,8 +1,8 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * args.h - prototypes pour les listes d'opérandes rassemblées en arguments
+ * shift.h - prototypes pour les décallages de valeurs
*
- * Copyright (C) 2010-2012x Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -21,8 +21,8 @@
*/
-#ifndef _ARCH_DALVIK_OPERANDS_ARGS_H
-#define _ARCH_DALVIK_OPERANDS_ARGS_H
+#ifndef _ARCH_ARM_V7_OPERANDS_SHIFT_H
+#define _ARCH_ARM_V7_OPERANDS_SHIFT_H
#include <glib-object.h>
@@ -62,4 +62,4 @@ GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *);
-#endif /* _ARCH_DALVIK_OPERANDS_ARGS_H */
+#endif /* _ARCH_ARM_V7_OPERANDS_SHIFT_H */
diff --git a/src/arch/arm/v7/thumb_32.c b/src/arch/arm/v7/thumb_32.c
index 87233b4..00b3171 100644
--- a/src/arch/arm/v7/thumb_32.c
+++ b/src/arch/arm/v7/thumb_32.c
@@ -182,7 +182,7 @@ GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t raw)
else if ((op2 & b1100111) == b0000011)
result = process_armv7_thumb_32_load_halfword_memory_hints(raw);
- else if ((op2 & b1100111) == b1100111)
+ else if ((op2 & b1100111) == b0000101)
result = process_armv7_thumb_32_load_word(raw);
/*
@@ -772,7 +772,7 @@ static GArchInstruction *process_armv7_thumb_32_load_word(uint32_t raw)
* § A6.3.7 Load word
*/
- if (((raw >> 22) & 0xfe700000) != 0xf8500000) return NULL;
+ if ((raw & 0xfe700000) != 0xf8500000) return NULL;
result = NULL;