summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/arm/v7/Makefile.am1
-rw-r--r--src/arch/arm/v7/link.c65
-rw-r--r--src/arch/arm/v7/link.h39
-rw-r--r--src/arch/arm/v7/opdefs/Makefile.am1
-rw-r--r--src/arch/arm/v7/opdefs/bx_A8827.d4
5 files changed, 109 insertions, 1 deletions
diff --git a/src/arch/arm/v7/Makefile.am b/src/arch/arm/v7/Makefile.am
index 6f5362d..564716d 100644
--- a/src/arch/arm/v7/Makefile.am
+++ b/src/arch/arm/v7/Makefile.am
@@ -8,6 +8,7 @@ libarcharmv7_la_SOURCES = \
fetch.h fetch.c \
helpers.h helpers.c \
instruction.h instruction.c \
+ link.h link.c \
post.h post.c \
processor.h processor.c \
pseudo.h pseudo.c \
diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c
new file mode 100644
index 0000000..4443fdb
--- /dev/null
+++ b/src/arch/arm/v7/link.c
@@ -0,0 +1,65 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * link.c - édition des liens après la phase de désassemblage ARM v7
+ *
+ * Copyright (C) 2016 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 "link.h"
+
+
+#include <assert.h>
+
+
+#include "../register.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction ARM à traiter. *
+* proc = représentation de l'architecture utilisée. *
+* context = contexte associé à la phase de désassemblage. *
+* format = acès aux données du binaire d'origine. *
+* *
+* Description : Encadre les sauts à partir de registres ARMv7. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format)
+{
+ GArchOperand *op; /* Opérande numérique en place */
+ GArmRegister *reg; /* Registre matériel manipulé */
+
+ op = g_arch_instruction_get_operand(instr, 0);
+ assert(G_IS_REGISTER_OPERAND(op));
+
+ reg = G_ARM_REGISTER(g_register_operand_get_register(G_REGISTER_OPERAND(op)));
+
+ if (g_arm_register_get_index(reg) == 14 /* lr */)
+ g_arch_instruction_set_flag(instr, AIF_RETURN_POINT);
+
+ else
+ g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); /* FIXME : jump inconnu ! */
+
+}
diff --git a/src/arch/arm/v7/link.h b/src/arch/arm/v7/link.h
new file mode 100644
index 0000000..3251647
--- /dev/null
+++ b/src/arch/arm/v7/link.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * link.h - prototypes pour l'édition des liens après la phase de désassemblage ARM v7
+ *
+ * Copyright (C) 2016 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_LINK_H
+#define _ARCH_ARM_V7_LINK_H
+
+
+#include "context.h"
+#include "../../instruction.h"
+#include "../../../format/format.h"
+
+
+
+/* Encadre les sauts à partir de registres ARMv7. */
+void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *);
+
+
+
+#endif /* _ARCH_ARM_V7_LINK_H */
diff --git a/src/arch/arm/v7/opdefs/Makefile.am b/src/arch/arm/v7/opdefs/Makefile.am
index 133810b..7844578 100644
--- a/src/arch/arm/v7/opdefs/Makefile.am
+++ b/src/arch/arm/v7/opdefs/Makefile.am
@@ -41,6 +41,7 @@ FIXED_C_INCLUDES = \
\n\#include \"..\/helpers.h\" \
\n\#include \"..\/instruction.h\" \
\n\#include \"..\/fetch.h\" \
+ \n\#include \"..\/link.h\" \
\n\#include \"..\/post.h\" \
\n\#include \"..\/..\/instruction.h\" \
\n\#include \"..\/..\/link.h\" \
diff --git a/src/arch/arm/v7/opdefs/bx_A8827.d b/src/arch/arm/v7/opdefs/bx_A8827.d
index f278d85..f3681e7 100644
--- a/src/arch/arm/v7/opdefs/bx_A8827.d
+++ b/src/arch/arm/v7/opdefs/bx_A8827.d
@@ -40,6 +40,7 @@
@hooks {
fetch = help_fetching_with_instruction_bx_from_thumb
+ link = handle_armv7_conditional_branch_from_register
}
@@ -65,7 +66,8 @@
@hooks {
- fetch = help_fetching_with_instruction_bx_from_thumb
+ fetch = help_fetching_with_instruction_bx_from_arm
+ link = handle_armv7_conditional_branch_from_register
}