summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-06-01 11:37:31 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-06-01 11:37:31 (GMT)
commit1b8152d6f95b03f81aa6a4043c23a45a9f74c418 (patch)
treea7b625acaee0b9584f3b2b6aa49bd507b652bd5c
parent8724afdc73e0ddad86f46de1a3fbe0254575a76e (diff)
Changed the old bin_routine structure to a GBinRoutine GObject.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@68 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
-rw-r--r--ChangeLog19
-rw-r--r--src/analysis/binary.c2
-rw-r--r--src/analysis/prototype.c97
-rw-r--r--src/analysis/prototype.h37
-rw-r--r--src/format/dwarf/Makefile.am2
-rw-r--r--src/format/elf/e_elf.c10
-rw-r--r--src/format/elf/e_elf.h2
-rw-r--r--src/format/exe_format-int.h2
-rw-r--r--src/format/exe_format.c2
-rw-r--r--src/format/exe_format.h2
-rwxr-xr-xsrc/format/java/e_java.c4
-rw-r--r--src/format/mangling/demangler-int.h2
-rw-r--r--src/format/mangling/demangler.c4
-rw-r--r--src/format/mangling/demangler.h2
-rw-r--r--src/format/mangling/itanium_gram.y32
-rwxr-xr-xsrc/format/pe/Makefile.am2
16 files changed, 152 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index a722f65..39f5365 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+09-06-01 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/analysis/binary.c:
+ * src/analysis/prototype.c:
+ * src/analysis/prototype.h:
+ * src/format/dwarf/Makefile.am:
+ * src/format/elf/e_elf.c:
+ * src/format/elf/e_elf.h:
+ * src/format/exe_format.c:
+ * src/format/exe_format.h:
+ * src/format/exe_format-int.h:
+ * src/format/java/e_java.c:
+ * src/format/mangling/demangler.c:
+ * src/format/mangling/demangler.h:
+ * src/format/mangling/demangler-int.h:
+ * src/format/mangling/itanium_gram.y:
+ * src/format/pe/Makefile.am:
+ Change the old bin_routine structure to a GBinRoutine GObject.
+
09-05-31 Cyrille Bagard <nocbos@gmail.com>
* configure.ac:
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 84401a3..d25a458 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -572,7 +572,7 @@ void disassemble_openida_binary(openida_binary *binary)
GArchInstruction *instr;
- bin_routine **routines; /* Liste des routines trouvées */
+ GBinRoutine **routines; /* Liste des routines trouvées */
size_t routines_count; /* Nombre de ces routines */
bin_part **parts;
diff --git a/src/analysis/prototype.c b/src/analysis/prototype.c
index 0d2ebf5..1e27f2c 100644
--- a/src/analysis/prototype.c
+++ b/src/analysis/prototype.c
@@ -32,14 +32,12 @@
-/* Variable représentant un prototype de routine */
-struct _bin_routine
+/* Représentation générique de routine (instance) */
+struct _GBinRoutine
{
+ GObject parent; /* A laisser en premier */
- uint64_t offset; /* Position physique/mémoire */
-
-
-
+ vmpa_t addr; /* Position physique/mémoire */
RoutineType type; /* Type de routine */
@@ -53,6 +51,61 @@ struct _bin_routine
};
+/* Représentation générique de routine (classe) */
+struct _GBinRoutineClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des représentation de routine. */
+static void g_bin_routine_class_init(GBinRoutineClass *);
+
+/* Initialise une instance représentation de routine. */
+static void g_bin_routine_init(GBinRoutine *);
+
+
+
+/* Indique le type définit pour une représentation de routine. */
+G_DEFINE_TYPE(GBinRoutine, g_bin_routine, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des représentation de routine. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_bin_routine_class_init(GBinRoutineClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : line = instance à initialiser. *
+* *
+* Description : Initialise une instance représentation de routine. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_bin_routine_init(GBinRoutine *line)
+{
+
+}
+
/******************************************************************************
* *
@@ -66,11 +119,11 @@ struct _bin_routine
* *
******************************************************************************/
-bin_routine *create_binary_routine(void)
+GBinRoutine *g_binary_routine_new(void)
{
- bin_routine *result; /* Structure à retourner */
+ GBinRoutine *result; /* Structure à retourner */
- result = (bin_routine *)calloc(1, sizeof(bin_routine));
+ result = g_object_new(G_TYPE_BIN_ROUTINE, NULL);
return result;
@@ -88,8 +141,8 @@ bin_routine *create_binary_routine(void)
* Remarques : - *
* *
******************************************************************************/
-
-void delete_binary_routine(bin_routine *routine)
+#if 0 /* FIXME */
+void g_binary_routine_finalize(GBinRoutine *routine)
{
size_t i; /* Boucle de parcours */
@@ -105,12 +158,12 @@ void delete_binary_routine(bin_routine *routine)
free(routine);
}
-
+#endif
/******************************************************************************
* *
* Paramètres : routine = routine à mettre à jour. *
-* offset = position mémoire ou physique déclarée. *
+* addr = position mémoire ou physique déclarée. *
* *
* Description : Définit la position physique / en mémoire d'une routine. *
* *
@@ -120,9 +173,9 @@ void delete_binary_routine(bin_routine *routine)
* *
******************************************************************************/
-void set_binary_routine_offset(bin_routine *routine, uint64_t offset)
+void g_binary_routine_set_address(GBinRoutine *routine, vmpa_t addr)
{
- routine->offset = offset;
+ routine->addr = addr;
}
@@ -139,9 +192,9 @@ void set_binary_routine_offset(bin_routine *routine, uint64_t offset)
* *
******************************************************************************/
-uint64_t get_binary_routine_offset(const bin_routine *routine)
+vmpa_t g_binary_routine_get_address(const GBinRoutine *routine)
{
- return routine->offset;
+ return routine->addr;
}
@@ -159,7 +212,7 @@ uint64_t get_binary_routine_offset(const bin_routine *routine)
* *
******************************************************************************/
-void set_binary_routine_type(bin_routine *routine, RoutineType type)
+void g_binary_routine_set_type(GBinRoutine *routine, RoutineType type)
{
routine->type = type;
@@ -179,7 +232,7 @@ void set_binary_routine_type(bin_routine *routine, RoutineType type)
* *
******************************************************************************/
-void set_binary_routine_name(bin_routine *routine, char *name)
+void g_binary_routine_set_name(GBinRoutine *routine, char *name)
{
if (routine->name != NULL)
free(routine->name);
@@ -202,7 +255,7 @@ void set_binary_routine_name(bin_routine *routine, char *name)
* *
******************************************************************************/
-void set_binary_routine_return_type(bin_routine *routine, variable *var)
+void g_binary_routine_set_return_type(GBinRoutine *routine, variable *var)
{
if (routine->ret_type != NULL)
delete_var(routine->ret_type);
@@ -225,7 +278,7 @@ void set_binary_routine_return_type(bin_routine *routine, variable *var)
* *
******************************************************************************/
-void add_arg_to_binary_routine(bin_routine *routine, variable *var)
+void g_binary_routine_add_arg(GBinRoutine *routine, variable *var)
{
routine->args_count++;
@@ -249,7 +302,7 @@ void add_arg_to_binary_routine(bin_routine *routine, variable *var)
* *
******************************************************************************/
-char *routine_to_string(const bin_routine *routine)
+char *g_binary_routine_to_string(const GBinRoutine *routine)
{
char *result; /* Chaîne à renvoyer */
size_t i; /* Boucle de parcours */
diff --git a/src/analysis/prototype.h b/src/analysis/prototype.h
index 891f294..3fd822e 100644
--- a/src/analysis/prototype.h
+++ b/src/analysis/prototype.h
@@ -25,10 +25,12 @@
#define _ANALYSIS_PROTOTYPE_H
+#include <glib-object.h>
#include <stdint.h>
#include "variable.h"
+#include "../arch/archbase.h"
@@ -42,36 +44,45 @@ typedef enum _RoutineType
} RoutineType;
-/* Variable représentant un prototype de routine */
-typedef struct _bin_routine bin_routine;
+#define G_TYPE_BIN_ROUTINE g_bin_routine_get_type()
+#define G_BIN_ROUTINE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_bin_routine_get_type(), GBinRoutine))
+#define G_IS_BIN_ROUTINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_bin_routine_get_type()))
+#define G_BIN_ROUTINE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_bin_routine_get_type(), GBinRoutineIface))
-/* Crée une représentation de routine. */
-bin_routine *create_binary_routine(void);
+/* Représentation générique de routine (instance) */
+typedef struct _GBinRoutine GBinRoutine;
+
+/* Représentation générique de routine (classe) */
+typedef struct _GBinRoutineClass GBinRoutineClass;
+
-/* Supprime une représentation de routine de la mémoire. */
-void delete_binary_routine(bin_routine *);
+/* Indique le type définit pour une représentation de routine. */
+GType g_bin_routine_get_type(void);
+
+/* Crée une représentation de routine. */
+GBinRoutine *g_binary_routine_new(void);
/* Définit la position physique / en mémoire d'une routine. */
-void set_binary_routine_offset(bin_routine *, uint64_t);
+void g_binary_routine_set_address(GBinRoutine *, vmpa_t);
/* Fournit la position physique / en mémoire d'une routine. */
-uint64_t get_binary_routine_offset(const bin_routine *);
+vmpa_t g_binary_routine_get_address(const GBinRoutine *);
/* Définit le type d'une routine. */
-void set_binary_routine_type(bin_routine *, RoutineType);
+void g_binary_routine_set_type(GBinRoutine *, RoutineType);
/* Définit le nom humain d'une routine. */
-void set_binary_routine_name(bin_routine *, char *);
+void g_binary_routine_set_name(GBinRoutine *, char *);
/* Définit le type de retour d'une routine. */
-void set_binary_routine_return_type(bin_routine *, variable *);
+void g_binary_routine_set_return_type(GBinRoutine *, variable *);
/* Ajoute un argument à une routine. */
-void add_arg_to_binary_routine(bin_routine *, variable *);
+void g_binary_routine_add_arg(GBinRoutine *, variable *);
/* Décrit le prototype de la routine sous forme de caractères. */
-char *routine_to_string(const bin_routine *);
+char *g_binary_routine_to_string(const GBinRoutine *);
diff --git a/src/format/dwarf/Makefile.am b/src/format/dwarf/Makefile.am
index 6bfccf0..de1d228 100644
--- a/src/format/dwarf/Makefile.am
+++ b/src/format/dwarf/Makefile.am
@@ -11,7 +11,7 @@ libformatdwarf_la_SOURCES = \
libformatdwarf_la_LDFLAGS = $(LIBGTK_LIBS)
-INCLUDES =
+INCLUDES = $(LIBGTK_CFLAGS)
AM_CPPFLAGS =
diff --git a/src/format/elf/e_elf.c b/src/format/elf/e_elf.c
index b5e3406..373df2b 100644
--- a/src/format/elf/e_elf.c
+++ b/src/format/elf/e_elf.c
@@ -576,14 +576,14 @@ bool resolve_elf_symbol(const elf_format *format, char **label, SymbolType *type
* *
******************************************************************************/
-bin_routine **get_all_elf_routines(const elf_format *format, size_t *count)
+GBinRoutine **get_all_elf_routines(const elf_format *format, size_t *count)
{
- bin_routine **result; /* Tableau à retourner */
+ GBinRoutine **result; /* Tableau à retourner */
size_t i; /* Boucle de parcours */
- result = (bin_routine **)calloc(format->sym_count, sizeof(bin_routine *));
+ result = (GBinRoutine **)calloc(format->sym_count, sizeof(GBinRoutine *));
*count = format->sym_count;
-
+ /*
for (i = 0; i < format->sym_count; i++)
{
result[i] = create_binary_routine();
@@ -592,7 +592,7 @@ bin_routine **get_all_elf_routines(const elf_format *format, size_t *count)
set_binary_routine_name(result[i], strdup(format->symbols[i].name));
}
-
+ */
return result;
}
diff --git a/src/format/elf/e_elf.h b/src/format/elf/e_elf.h
index f0c2c12..9327fe6 100644
--- a/src/format/elf/e_elf.h
+++ b/src/format/elf/e_elf.h
@@ -56,7 +56,7 @@ size_t get_elf_symbols(const elf_format *, char ***, SymbolType **, uint64_t **)
bool resolve_elf_symbol(const elf_format *, char **, SymbolType *, uint64_t *);
/* Fournit le prototype de toutes les routines détectées. */
-bin_routine **get_all_elf_routines(const elf_format *, size_t *);
+GBinRoutine **get_all_elf_routines(const elf_format *, size_t *);
diff --git a/src/format/exe_format-int.h b/src/format/exe_format-int.h
index bb96ea5..781b1c3 100644
--- a/src/format/exe_format-int.h
+++ b/src/format/exe_format-int.h
@@ -70,7 +70,7 @@ typedef size_t (* get_resolved_fc) (const exe_format *, char ***, ResolvedType *
typedef bool (* resolve_symbol_fc) (const exe_format *, char **, SymbolType *, uint64_t *);
/* Fournit le prototype de toutes les routines détectées. */
-typedef bin_routine ** (* get_all_routines_fc) (const exe_format *, size_t *);
+typedef GBinRoutine ** (* get_all_routines_fc) (const exe_format *, size_t *);
/* Support générique d'un format d'exécutable */
diff --git a/src/format/exe_format.c b/src/format/exe_format.c
index 5ddb934..6a5c55c 100644
--- a/src/format/exe_format.c
+++ b/src/format/exe_format.c
@@ -515,7 +515,7 @@ bool resolve_exe_symbol(const exe_format *format, char **label, SymbolType *type
* *
******************************************************************************/
-bin_routine **get_all_exe_routines(const exe_format *format, size_t *count)
+GBinRoutine **get_all_exe_routines(const exe_format *format, size_t *count)
{
return format->get_all_routines(format, count);
diff --git a/src/format/exe_format.h b/src/format/exe_format.h
index de9f025..a6d91f2 100644
--- a/src/format/exe_format.h
+++ b/src/format/exe_format.h
@@ -148,7 +148,7 @@ size_t get_exe_resolved_items(const exe_format *, char ***, ResolvedType **, uin
bool resolve_exe_symbol(const exe_format *, char **, SymbolType *, uint64_t *);
/* Fournit le prototype de toutes les routines détectées. */
-bin_routine **get_all_exe_routines(const exe_format *, size_t *);
+GBinRoutine **get_all_exe_routines(const exe_format *, size_t *);
diff --git a/src/format/java/e_java.c b/src/format/java/e_java.c
index 18300e8..76172b2 100755
--- a/src/format/java/e_java.c
+++ b/src/format/java/e_java.c
@@ -48,7 +48,7 @@ bin_part **get_java_default_code_parts(const java_format *, size_t *);
/* Fournit le prototype de toutes les routines détectées. */
-bin_routine **get_all_java_routines(const java_format *, size_t *);
+GBinRoutine **get_all_java_routines(const java_format *, size_t *);
@@ -275,7 +275,7 @@ bin_part **get_java_default_code_parts(const java_format *format, size_t *count)
* *
******************************************************************************/
-bin_routine **get_all_java_routines(const java_format *format, size_t *count)
+GBinRoutine **get_all_java_routines(const java_format *format, size_t *count)
{
*count = 0;
diff --git a/src/format/mangling/demangler-int.h b/src/format/mangling/demangler-int.h
index 2189bd0..f137fa0 100644
--- a/src/format/mangling/demangler-int.h
+++ b/src/format/mangling/demangler-int.h
@@ -34,7 +34,7 @@
typedef bool (* can_be_demangled_fc) (name_demangler *, const char *);
/* Procède au décodage d'une chaîne de caractères. */
-typedef bin_routine * (* demangle_routine_fc) (name_demangler *, const char *);
+typedef GBinRoutine * (* demangle_routine_fc) (name_demangler *, const char *);
/* Décodeur de nom d'éléments */
diff --git a/src/format/mangling/demangler.c b/src/format/mangling/demangler.c
index 5675800..e8b6b0f 100644
--- a/src/format/mangling/demangler.c
+++ b/src/format/mangling/demangler.c
@@ -120,9 +120,9 @@ name_demangler *get_demangler_by_type(DemanglerType type)
* *
******************************************************************************/
-bin_routine *try_to_demangle_routine(name_demangler *demangler, const char *name)
+GBinRoutine *try_to_demangle_routine(name_demangler *demangler, const char *name)
{
- bin_routine *result; /* Construction à remonter */
+ GBinRoutine *result; /* Construction à remonter */
result = NULL;
diff --git a/src/format/mangling/demangler.h b/src/format/mangling/demangler.h
index 259d73d..3c9a6c1 100644
--- a/src/format/mangling/demangler.h
+++ b/src/format/mangling/demangler.h
@@ -52,7 +52,7 @@ bool init_all_demanglers(void);
name_demangler *get_demangler_by_type(DemanglerType);
/* Tente de décoder une chaîne de caractères donnée. */
-bin_routine *try_to_demangle_routine(name_demangler *, const char *);
+GBinRoutine *try_to_demangle_routine(name_demangler *, const char *);
diff --git a/src/format/mangling/itanium_gram.y b/src/format/mangling/itanium_gram.y
index 7c13c79..4fa7bcb 100644
--- a/src/format/mangling/itanium_gram.y
+++ b/src/format/mangling/itanium_gram.y
@@ -39,7 +39,7 @@ typedef struct _itanium_demangler
bool can_be_itanium_demangled(itanium_demangler *, const char *);
/* Procède au décodage d'une chaîne de caractères. */
-bin_routine *demangle_itanium_routine(itanium_demangler *, const char *);
+GBinRoutine *demangle_itanium_routine(itanium_demangler *, const char *);
@@ -104,7 +104,7 @@ char *strmerge(char *str1, const char *sep, char *str2);
}
%parse-param { itanium_demangler *demangler }
-%parse-param { bin_routine *routine }
+%parse-param { GBinRoutine *routine }
%token ITANIUM_SIGNATURE
@@ -207,8 +207,8 @@ encoding:
name:
- nested_name { $$ = $1; set_binary_routine_name(routine, $1); }
- | unscoped_name { $$ = $1; /*set_binary_routine_name(routine, $1);*/ }
+ nested_name { $$ = $1; g_binary_routine_set_name(routine, $1); }
+ | unscoped_name { $$ = $1; /*g_binary_routine_set_name(routine, $1);*/ }
| unscoped_template_name template_args { $$ = stradd($1, $2); /* TODO : merge -> free */ }
;
@@ -256,12 +256,12 @@ identifier:
;
ctor_dtor_name:
- C1 { set_binary_routine_type(routine, RTT_CONSTRUCTOR); }
- | C2 { set_binary_routine_type(routine, RTT_CONSTRUCTOR); }
- | C3 { set_binary_routine_type(routine, RTT_CONSTRUCTOR); }
- | D1 { set_binary_routine_type(routine, RTT_DESTRUCTOR); }
- | D2 { set_binary_routine_type(routine, RTT_DESTRUCTOR); }
- | D3 { set_binary_routine_type(routine, RTT_DESTRUCTOR); }
+ C1 { g_binary_routine_set_type(routine, RTT_CONSTRUCTOR); }
+ | C2 { g_binary_routine_set_type(routine, RTT_CONSTRUCTOR); }
+ | C3 { g_binary_routine_set_type(routine, RTT_CONSTRUCTOR); }
+ | D1 { g_binary_routine_set_type(routine, RTT_DESTRUCTOR); }
+ | D2 { g_binary_routine_set_type(routine, RTT_DESTRUCTOR); }
+ | D3 { g_binary_routine_set_type(routine, RTT_DESTRUCTOR); }
;
@@ -319,8 +319,8 @@ builtin_type:
bare_function_type:
- bare_function_type type { add_arg_to_binary_routine(routine, $2); }
- | type { add_arg_to_binary_routine(routine, $1); }
+ bare_function_type type { g_binary_routine_add_arg(routine, $2); }
+ | type { g_binary_routine_add_arg(routine, $1); }
;
class_enum_type:
@@ -448,13 +448,13 @@ bool can_be_itanium_demangled(itanium_demangler *itanium, const char *name)
* *
******************************************************************************/
-bin_routine *demangle_itanium_routine(itanium_demangler *demangler, const char *name)
+GBinRoutine *demangle_itanium_routine(itanium_demangler *demangler, const char *name)
{
- bin_routine *result; /* Construction à retourner */
+ GBinRoutine *result; /* Construction à retourner */
YY_BUFFER_STATE buffer; /* Tampon pour bison */
int ret; /* Bilan de l'appel */
- result = create_binary_routine();
+ result = g_binary_routine_new();
buffer = yy_scan_string(name);
ret = yyparse(demangler, result);
@@ -462,7 +462,7 @@ bin_routine *demangle_itanium_routine(itanium_demangler *demangler, const char *
if (ret != 0)
{
- delete_binary_routine(result);
+ /*delete_binary_routine(result); FIXME */
result = NULL;
}
diff --git a/src/format/pe/Makefile.am b/src/format/pe/Makefile.am
index 7fb0d91..a11d912 100755
--- a/src/format/pe/Makefile.am
+++ b/src/format/pe/Makefile.am
@@ -8,7 +8,7 @@ libformatpe_la_SOURCES = \
libformatpe_la_LDFLAGS =
-INCLUDES =
+INCLUDES = $(LIBGTK_CFLAGS)
AM_CPPFLAGS =