summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/Makefile.am1
-rw-r--r--src/arch/arm/v7/Makefile.am1
-rw-r--r--src/arch/arm/v7/helpers.c2
-rw-r--r--src/arch/arm/v7/opdefs/bl_A8825.d12
-rw-r--r--src/arch/arm/v7/post.c216
-rw-r--r--src/arch/arm/v7/post.h41
-rw-r--r--src/arch/arm/v7/processor.c28
-rw-r--r--src/arch/immediate.c1
-rw-r--r--src/arch/instruction-int.h2
-rw-r--r--src/arch/instruction.c48
-rw-r--r--src/arch/instruction.h12
-rw-r--r--src/arch/target.c325
-rw-r--r--src/arch/target.h71
13 files changed, 752 insertions, 8 deletions
diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am
index 1c63016..33747fb 100644
--- a/src/arch/Makefile.am
+++ b/src/arch/Makefile.am
@@ -16,6 +16,7 @@ libarch_la_SOURCES = \
raw.h raw.c \
register-int.h \
register.h register.c \
+ target.h target.c \
translate.h \
vmpa.h vmpa.c
diff --git a/src/arch/arm/v7/Makefile.am b/src/arch/arm/v7/Makefile.am
index 0bb88aa..704b3a6 100644
--- a/src/arch/arm/v7/Makefile.am
+++ b/src/arch/arm/v7/Makefile.am
@@ -5,6 +5,7 @@ libarcharmv7_la_SOURCES = \
arm.h arm.c \
helpers.h helpers.c \
instruction.h instruction.c \
+ post.h post.c \
processor.h processor.c \
pseudo.h pseudo.c \
register.h register.c \
diff --git a/src/arch/arm/v7/helpers.c b/src/arch/arm/v7/helpers.c
index 8acfeb5..45c6ba5 100644
--- a/src/arch/arm/v7/helpers.c
+++ b/src/arch/arm/v7/helpers.c
@@ -145,7 +145,7 @@ GArchOperand *sign_extend_armv7_imm(uint32_t value, bool topbit, unsigned int si
mds = MDS_ ## sz ## _BITS_SIGNED; \
val ## sz = value; \
if (topbit) \
- for (i = msb + 1; i < sz; i++) \
+ for (i = msb; i < sz; i++) \
val ## sz |= (1 << i); \
result = g_imm_operand_new_from_value(mds, val ## sz); \
break;
diff --git a/src/arch/arm/v7/opdefs/bl_A8825.d b/src/arch/arm/v7/opdefs/bl_A8825.d
index c9ef5d0..dc9c922 100644
--- a/src/arch/arm/v7/opdefs/bl_A8825.d
+++ b/src/arch/arm/v7/opdefs/bl_A8825.d
@@ -25,7 +25,7 @@
@encoding(T1) {
- @word 1 1 1 1 0 S(1) imm10H(10) 1 1 J1(1) 1 J2(1) imm10L(10) H(1)
+ @word 1 1 1 1 0 S(1) imm10(10) 1 1 J1(1) 1 J2(1) imm11(11)
@syntax <imm32>
@@ -33,7 +33,7 @@
I1 = NOT(J1 EOR S)
I2 = NOT(J2 EOR S)
- imm32 = SignExtend(S:I1:I2:imm10H:imm10L:'00', s, 32)
+ imm32 = SignExtend(S:I1:I2:imm10:imm11:'0', S, 32)
}
@@ -41,15 +41,15 @@
@encoding(T2) {
- @word 1 1 1 1 0 S(1) imm10(10) 1 1 J1(1) 0 J2(1) imm11(11)
+ @word 1 1 1 1 0 S(1) imm10H(10) 1 1 J1(1) 0 J2(1) imm10L(10) H(1)
- @syntax <imm32>
+ @syntax "blx" <imm32>
@conv {
I1 = NOT(J1 EOR S)
I2 = NOT(J2 EOR S)
- imm32 = SignExtend(S:I1:I2:imm10:imm11:'0', S, 32)
+ imm32 = SignExtend(S:I1:I2:imm10H:imm10L:'00', S, 32)
}
@@ -73,7 +73,7 @@
@word cond(4) 1 0 1 H(1) imm24(24)
- @syntax <imm32>
+ @syntax "blx" <imm32>
@conv {
diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c
new file mode 100644
index 0000000..8ba12d8
--- /dev/null
+++ b/src/arch/arm/v7/post.c
@@ -0,0 +1,216 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * post.c - traitements complémentaires à la phase de désassemblage
+ *
+ * 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 "post.h"
+
+
+
+
+
+#include "../../target.h"
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction ARMv7 à traiter. *
+* format = acès aux données du binaire d'origine. *
+* *
+* Description : Complète un désassemblage accompli pour une instruction. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void post_process_thumb_instruction_bl(GArchInstruction *instr, GBinFormat *format)
+{
+
+
+ const mrange_t *range;
+
+ virt_t pc;
+
+
+
+
+
+ GArchOperand *op;
+ vmpa_t val;
+ GArchOperand *new;
+
+ vmpa2t target;
+ mrange_t trange;
+ VMPA_BUFFER(loc);
+ char name[5 + VMPA_MAX_LEN];
+ GBinRoutine *routine; /* Nouvelle routine trouvée */
+ GBinSymbol *symbol; /* Nouveau symbole construit */
+
+
+
+
+ range = g_arch_instruction_get_range(instr);
+
+ pc = get_virt_addr(get_mrange_addr(range)) + 4 /* PC++ */;
+ printf(" -- PC = 0x%x\n", (unsigned int)pc);
+
+
+ op = g_arch_instruction_get_operand(instr, 0);
+
+ g_imm_operand_to_vmpa_t(G_IMM_OPERAND(op), &val);
+
+ printf(" -> %llx = %lld ==>> 0x%x\n", val, val, (unsigned int)(pc + val));
+
+
+
+ new = g_target_operand_new(MDS_32_BITS, pc + val);
+
+ if (!g_target_operand_resolve(G_TARGET_OPERAND(new), format))
+ {
+ init_vmpa(&target, VMPA_NO_PHYSICAL, pc + val);
+ init_mrange(&trange, &target, 0);
+
+ vmpa2_virt_to_string(&target, MDS_32_BITS, loc, NULL);
+ snprintf(name, sizeof(name), "loc_%s", loc + 2);
+
+ routine = g_binary_routine_new();
+ g_binary_routine_set_name(routine, strdup(name));
+ //routine = try_to_demangle_routine(name);
+
+ g_binary_routine_set_range(routine, &trange);
+
+ symbol = g_binary_symbol_new(STP_ROUTINE, NULL, ~0);
+ g_binary_symbol_attach_routine(symbol, routine);
+ g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
+
+
+
+ g_target_operand_resolve(G_TARGET_OPERAND(new), format);
+
+
+ }
+
+
+ g_arch_instruction_replace_operand(instr, new, op);
+ //g_arch_instruction_attach_extra_operand(result, new);
+
+
+
+}
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction ARMv7 à traiter. *
+* format = acès aux données du binaire d'origine. *
+* *
+* Description : Complète un désassemblage accompli pour une instruction. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void post_process_thumb_instruction_blx(GArchInstruction *instr, GBinFormat *format)
+{
+
+
+
+
+
+ const mrange_t *range;
+
+ virt_t pc;
+
+
+
+ GArchOperand *op;
+ vmpa_t val;
+ GArchOperand *new;
+
+ vmpa2t target;
+ mrange_t trange;
+ VMPA_BUFFER(loc);
+ char name[5 + VMPA_MAX_LEN];
+ GBinRoutine *routine; /* Nouvelle routine trouvée */
+ GBinSymbol *symbol; /* Nouveau symbole construit */
+
+
+
+ range = g_arch_instruction_get_range(instr);
+
+ pc = get_virt_addr(get_mrange_addr(range)) + 4 /* PC++ */;
+
+ printf(" -- PC = 0x%x -> 0x%x\n", (unsigned int)pc, (unsigned int)pc - pc % 4);
+ pc = pc - pc % 4;
+
+ op = g_arch_instruction_get_operand(instr, 0);
+
+ g_imm_operand_to_vmpa_t(G_IMM_OPERAND(op), &val);
+
+ printf(" -> %llx = %lld ==>> 0x%x\n", val, val, (unsigned int)(pc + val));
+
+
+
+ new = g_target_operand_new(MDS_32_BITS, pc + val);
+
+ if (!g_target_operand_resolve(G_TARGET_OPERAND(new), format))
+ {
+ init_vmpa(&target, VMPA_NO_PHYSICAL, pc + val);
+ init_mrange(&trange, &target, 0);
+
+ vmpa2_virt_to_string(&target, MDS_32_BITS, loc, NULL);
+ snprintf(name, sizeof(name), "loc_%s", loc + 2);
+
+ routine = g_binary_routine_new();
+ g_binary_routine_set_name(routine, strdup(name));
+ //routine = try_to_demangle_routine(name);
+
+ g_binary_routine_set_range(routine, &trange);
+
+ symbol = g_binary_symbol_new(STP_ROUTINE, NULL, ~0);
+ g_binary_symbol_attach_routine(symbol, routine);
+ g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
+
+
+
+ g_target_operand_resolve(G_TARGET_OPERAND(new), format);
+
+
+ }
+
+ g_arch_instruction_replace_operand(instr, new, op);
+ //g_arch_instruction_attach_extra_operand(result, new);
+
+
+
+
+}
+
diff --git a/src/arch/arm/v7/post.h b/src/arch/arm/v7/post.h
new file mode 100644
index 0000000..d9ad99e
--- /dev/null
+++ b/src/arch/arm/v7/post.h
@@ -0,0 +1,41 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * post.h - prototypes pour les traitements complémentaires à la phase de désassemblage
+ *
+ * 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_POST_H
+#define _ARCH_ARM_V7_POST_H
+
+
+#include "../../instruction.h"
+#include "../../../format/format.h"
+
+
+
+/* Complète un désassemblage accompli pour une instruction. */
+void post_process_thumb_instruction_bl(GArchInstruction *, GBinFormat *);
+
+/* Complète un désassemblage accompli pour une instruction. */
+void post_process_thumb_instruction_blx(GArchInstruction *, GBinFormat *);
+
+
+
+#endif /* _ARCH_ARM_V7_POST_H */
diff --git a/src/arch/arm/v7/processor.c b/src/arch/arm/v7/processor.c
index dac9639..2b8617b 100644
--- a/src/arch/arm/v7/processor.c
+++ b/src/arch/arm/v7/processor.c
@@ -200,7 +200,7 @@ GArmV7Processor *g_armv7_processor_new(void)
* Remarques : - *
* *
******************************************************************************/
-
+#include "post.h"
static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *proc, GArmContext *ctx, const bin_t *data, vmpa2t *pos, phys_t end)
{
GArchInstruction *result; /* Instruction à renvoyer */
@@ -209,6 +209,9 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
uint16_t raw16; /* Donnée 16 bits à analyser */
uint32_t raw32; /* Donnée 32 bits à analyser */
+
+
+
start = get_phy_addr(pos);
diff = 4;
@@ -258,6 +261,29 @@ static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *pr
result = g_raw_instruction_new_array(data, MDS_32_BITS, 1, pos, end,
G_ARCH_PROCESSOR(proc)->endianness);
+
+
+
+
+ if (strcmp(g_arch_instruction_get_keyword(result, 0), "bl") == 0/* && pc == 0x000085b2*/)
+ {
+
+
+ g_arch_instruction_set_post_prod_function(result, post_process_thumb_instruction_bl);
+
+
+
+ }
+
+ if (strcmp(g_arch_instruction_get_keyword(result, 0), "blx") == 0/* && pc == 0x000085b2*/)
+ {
+
+ g_arch_instruction_set_post_prod_function(result, post_process_thumb_instruction_blx);
+
+
+ }
+
+
return result;
}
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index 574fc3d..f8ef432 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -857,6 +857,7 @@ bool g_imm_operand_to_vmpa_t(const GImmOperand *operand, vmpa_t *addr)
*addr = operand->unsigned_imm.val64;
break;
default:
+ *addr = operand->signed_imm.val32;//////
result = false;
break;
}
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index f96753a..aedd468 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -58,6 +58,8 @@ struct _GArchInstruction
const char *suffix; /* Complément au nom affiché */
char *cached_keyword; /* Désignation complète */
+ instr_post_prod_fc post_prod; /* A remplacer par un signal... */
+
mrange_t range; /* Emplacement en mémoire */
/* ------- %< ----------- */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index c8640b4..a96f0e4 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -167,6 +167,51 @@ void g_arch_instruction_append_suffix(GArchInstruction *instr, const char *suffi
/******************************************************************************
* *
+* Paramètres : instr = instruction quelconque à modifier. *
+* post = fonction à appeler sur commande. *
+* *
+* Description : Définit une fonction de post-traitement après désassemblage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_arch_instruction_set_post_prod_function(GArchInstruction *instr, instr_post_prod_fc post)
+{
+ instr->post_prod = post;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction quelconque à traiter. *
+* data = données éventuelles associées à l'opération. *
+* *
+* Description : Complète un désassemblage accompli pour une instruction. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_arch_instruction_call_post_prod_function(GArchInstruction *instr, void *data)
+{
+ if (instr->post_prod != NULL)
+ instr->post_prod(instr, data);
+
+}
+
+
+
+
+
+
+/******************************************************************************
+* *
* Paramètres : instr = instruction quelconque à modifier. *
* address = adresse virtuelle et/ou position physique. *
* length = taille de l'instruction. *
@@ -321,7 +366,10 @@ void g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand *n
break;
if (i < instr->operands_count)
+ {
+ g_object_unref(G_OBJECT(instr->operands[i]));
instr->operands[i] = new;
+ }
}
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 287e34f..7b9fe66 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -35,6 +35,7 @@
#include "../decomp/context.h"
#include "../decomp/instruction.h"
//#include "../format/executable.h"
+#include "../format/format.h"
@@ -59,6 +60,17 @@ GType g_arch_instruction_get_type(void);
/* Etend la désignation d'un nom d'instruction. */
void g_arch_instruction_append_suffix(GArchInstruction *, const char *);
+/* Complète un désassemblage accompli pour une instruction. */
+typedef void (* instr_post_prod_fc)(GArchInstruction *, void *);
+
+/* Définit une fonction de post-traitement après désassemblage. */
+void g_arch_instruction_set_post_prod_function(GArchInstruction *, instr_post_prod_fc);
+
+/* Complète un désassemblage accompli pour une instruction. */
+void g_arch_instruction_call_post_prod_function(GArchInstruction *, void *);
+
+
+
/* Définit la localisation d'une instruction. */
void g_arch_instruction_set_range(GArchInstruction *, const mrange_t *);
diff --git a/src/arch/target.c b/src/arch/target.c
new file mode 100644
index 0000000..93ccbe4
--- /dev/null
+++ b/src/arch/target.c
@@ -0,0 +1,325 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * target.c - opérandes ciblant un symbole
+ *
+ * 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 "target.h"
+
+
+#include <inttypes.h>
+#include <malloc.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+
+#include "operand-int.h"
+#include "../common/extstr.h"
+#include "../format/format.h"
+
+
+
+/* Définition d'un opérande ciblant idéalement un symbole connu (instance) */
+struct _GTargetOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ MemoryDataSize size; /* Taille de l'opérande */
+ virt_t addr; /* Adresse de l'élément visé */
+
+ GBinSymbol *symbol; /* Eventuel symbole associé */
+ phys_t diff; /* Position dans le symbole */
+
+};
+
+
+/* Définition d'un opérande ciblant idéalement un symbole connu (classe) */
+struct _GTargetOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des opérandes ciblant des symboles. */
+static void g_target_operand_class_init(GTargetOperandClass *);
+
+/* Initialise la classe des opérandes ciblant des symboles. */
+static void g_target_operand_init(GTargetOperand *);
+
+/* Supprime toutes les références externes. */
+static void g_target_operand_dispose(GTargetOperand *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_target_operand_finalize(GTargetOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_target_operand_print(const GTargetOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini pour un opérande de valeur numérique. */
+G_DEFINE_TYPE(GTargetOperand, g_target_operand, G_TYPE_ARCH_OPERAND);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des opérandes ciblant des symboles. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_target_operand_class_init(GTargetOperandClass *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_target_operand_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_target_operand_finalize;
+
+ operand->print = (operand_print_fc)g_target_operand_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise la classe des opérandes ciblant des symboles. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_target_operand_init(GTargetOperand *operand)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_target_operand_dispose(GTargetOperand *operand)
+{
+ if (operand->symbol != NULL)
+ g_object_unref(G_OBJECT(operand->symbol));
+
+ G_OBJECT_CLASS(g_target_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_target_operand_finalize(GTargetOperand *operand)
+{
+ G_OBJECT_CLASS(g_target_operand_parent_class)->finalize(G_OBJECT(operand));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : size = taille des adresse mémoire virtuelles. *
+* addr = adresse virtuelle d'un élément à retrouver. *
+* *
+* Description : Crée un opérande réprésentant une valeur numérique. *
+* *
+* Retour : Instruction mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_target_operand_new(MemoryDataSize size, virt_t addr)
+{
+ GTargetOperand *result; /* Opérande à retourner */
+
+ result = g_object_new(G_TYPE_TARGET_OPERAND, NULL);
+
+ result->size = size;
+ result->addr = addr;
+
+ 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_target_operand_print(const GTargetOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ const char *label; /* Etiquette liée à un symbole */
+ vmpa2t tmp; /* Coquille vide pour argument */
+ VMPA_BUFFER(value); /* Adresse brute à imprimer */
+ size_t len; /* Taille de l'élément inséré */
+
+ if (operand->symbol != NULL)
+ {
+ if (operand->diff > 0)
+ g_buffer_line_insert_text(line, BLC_MAIN, "<", 1, RTT_LTGT);
+
+ label = g_binary_symbol_get_label(operand->symbol);
+ g_buffer_line_insert_text(line, BLC_MAIN, label, strlen(label), RTT_LABEL);
+
+ if (operand->diff > 0)
+ {
+ g_buffer_line_insert_text(line, BLC_MAIN, "+", 1, RTT_SIGNS);
+
+ init_vmpa(&tmp, operand->diff, VMPA_NO_VIRTUAL);
+ vmpa2_phys_to_string(&tmp, MDS_4_BITS, value, &len);
+
+ g_buffer_line_insert_text(line, BLC_MAIN, value, len, RTT_LABEL);
+
+ g_buffer_line_insert_text(line, BLC_MAIN, ">", 1, RTT_LTGT);
+
+ }
+
+ }
+ else
+ {
+ init_vmpa(&tmp, VMPA_NO_PHYSICAL, operand->addr);
+ vmpa2_virt_to_string(&tmp, operand->size, value, &len);
+
+ g_buffer_line_insert_text(line, BLC_MAIN, value, len, RTT_LABEL);
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = structure dont le contenu est à consulter. *
+* *
+* Description : Renseigne la taille de la valeur indiquée à la construction. *
+* *
+* Retour : Taille de la valeur représentée en mémoire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+MemoryDataSize g_target_operand_get_size(const GTargetOperand *operand)
+{
+ return operand->size;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = structure dont le contenu est à définir. *
+* *
+* Description : Fournit l'adresse en mémoire de l'élément visé. *
+* *
+* Retour : Adresse en mémoire virtuelle associée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+virt_t g_target_operand_get_addr(const GTargetOperand *operand)
+{
+ return operand->addr;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande dont le contenu est à raffiner. *
+* format = format du binaire d'origine à consulter. *
+* *
+* Description : Tente une résolution de symbole. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_target_operand_resolve(GTargetOperand *operand, const GBinFormat *format)
+{
+ bool result; /* Bilan à retourner */
+ vmpa2t addr; /* Adresse de recherche */
+
+ if (operand->symbol != NULL)
+ g_object_unref(G_OBJECT(operand->symbol));
+
+ operand->symbol = NULL;
+ operand->diff = 0;
+
+ init_vmpa(&addr, VMPA_NO_PHYSICAL, operand->addr);
+
+ result = g_binary_format_resolve_symbol(format, &addr, &operand->symbol, &operand->diff);
+
+ /**
+ * En cas de succès, le compteur de références du symbole trouvé a été incrémenté.
+ */
+
+ return result;
+
+}
diff --git a/src/arch/target.h b/src/arch/target.h
new file mode 100644
index 0000000..ada1a6c
--- /dev/null
+++ b/src/arch/target.h
@@ -0,0 +1,71 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * target.h - prototypes pour les opérandes ciblant un symbole
+ *
+ * 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_TARGET_H
+#define _ARCH_TARGET_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "archbase.h"
+#include "operand.h"
+#include "vmpa.h"
+#include "../format/format.h"
+
+
+
+#define G_TYPE_TARGET_OPERAND g_target_operand_get_type()
+#define G_TARGET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_target_operand_get_type(), GTargetOperand))
+#define G_IS_TARGET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_target_operand_get_type()))
+#define G_TARGET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_TARGET_OPERAND, GTargetOperandClass))
+#define G_IS_TARGET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_TARGET_OPERAND))
+#define G_TARGET_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_TARGET_OPERAND, GTargetOperandClass))
+
+
+/* Définition d'un opérande ciblant idéalement un symbole connu (instance) */
+typedef struct _GTargetOperand GTargetOperand;
+
+/* Définition d'un opérande ciblant idéalement un symbole connu (classe) */
+typedef struct _GTargetOperandClass GTargetOperandClass;
+
+
+/* Indique le type défini pour un opérande d'architecture. */
+GType g_target_operand_get_type(void);
+
+/* Crée un opérande réprésentant une valeur numérique. */
+GArchOperand *g_target_operand_new(MemoryDataSize, virt_t);
+
+/* Renseigne la taille de la valeur indiquée à la construction. */
+MemoryDataSize g_target_operand_get_size(const GTargetOperand *);
+
+/* Fournit l'adresse en mémoire de l'élément visé. */
+virt_t g_target_operand_get_addr(const GTargetOperand *);
+
+/* Tente une résolution de symbole. */
+bool g_target_operand_resolve(GTargetOperand *, const GBinFormat *);
+
+
+
+#endif /* _ARCH_TARGET_H */