summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/format/symbol-int.h47
-rw-r--r--src/format/symbol.c48
-rw-r--r--src/format/symbol.h12
3 files changed, 95 insertions, 12 deletions
diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h
index f1fb396..e2c3292 100644
--- a/src/format/symbol-int.h
+++ b/src/format/symbol-int.h
@@ -26,6 +26,7 @@
#include "symbol.h"
+#include "../glibext/objhole.h"
@@ -33,6 +34,19 @@
typedef char * (* get_symbol_label_fc) (const GBinSymbol *);
+/* Informations glissées dans la structure GObject de GArchInstruction */
+typedef union _sym_obj_extra
+{
+ struct
+ {
+ SymbolType stype; /* Type du symbole */
+ SymbolStatus status; /* Visibilité du symbole */
+
+ };
+
+ gint lock; /* Gestion d'accès aux fanions */
+
+} sym_obj_extra;
/* Symbole d'exécutable (instance) */
struct _GBinSymbol
@@ -40,13 +54,42 @@ struct _GBinSymbol
GObject parent; /* A laisser en premier */
mrange_t range; /* Couverture mémoire */
- SymbolType stype; /* Type du symbole */
- SymbolStatus status; /* Visibilité du symbole */
char *alt; /* Nom alternatif */
+#if __SIZEOF_INT__ == __SIZEOF_LONG__
+
+ /**
+ * L'inclusion des informations suivantes dépend de l'architecture.
+ *
+ * Si la structure GObject possède un trou, on remplit de préférence
+ * ce dernier.
+ */
+
+ sym_obj_extra extra; /* Externalisation embarquée */
+
+#endif
+
};
+/**
+ * Accès aux informations éventuellement déportées.
+ */
+
+#if __SIZEOF_INT__ == __SIZEOF_LONG__
+
+# define INIT_BIN_SYMBOL_EXTRA(sym) ins->extra.lock = 0
+
+# define GET_BIN_SYMBOL_EXTRA(sym) &ins->extra
+
+#else
+
+# define INIT_BIN_SYMBOL_EXTRA(sym) INIT_GOBJECT_EXTRA(G_OBJECT(sym))
+
+# define GET_BIN_SYMBOL_EXTRA(sym) GET_GOBJECT_EXTRA(G_OBJECT(sym), sym_obj_extra)
+
+#endif
+
/* Symbole d'exécutable (classe) */
struct _GBinSymbolClass
{
diff --git a/src/format/symbol.c b/src/format/symbol.c
index 30987ae..c10c46d 100644
--- a/src/format/symbol.c
+++ b/src/format/symbol.c
@@ -123,6 +123,8 @@ static void g_binary_symbol_class_init(GBinSymbolClass *klass)
static void g_binary_symbol_init(GBinSymbol *symbol)
{
+ INIT_BIN_SYMBOL_EXTRA(symbol);
+
g_binary_symbol_set_stype(symbol, STP_COUNT);
g_binary_symbol_set_status(symbol, SSS_INTERNAL);
@@ -328,7 +330,15 @@ const mrange_t *g_binary_symbol_get_range(const GBinSymbol *symbol)
void g_binary_symbol_set_stype(GBinSymbol *symbol, SymbolType type)
{
- symbol->stype = type;
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ extra->stype = type;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
}
@@ -347,7 +357,18 @@ void g_binary_symbol_set_stype(GBinSymbol *symbol, SymbolType type)
SymbolType g_binary_symbol_get_stype(const GBinSymbol *symbol)
{
- return symbol->stype;
+ SymbolType result; /* Type à retourner */
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = extra->stype;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
}
@@ -367,7 +388,15 @@ SymbolType g_binary_symbol_get_stype(const GBinSymbol *symbol)
void g_binary_symbol_set_status(GBinSymbol *symbol, SymbolStatus status)
{
- symbol->status = status;
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ extra->status = status;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
}
@@ -386,7 +415,18 @@ void g_binary_symbol_set_status(GBinSymbol *symbol, SymbolStatus status)
SymbolStatus g_binary_symbol_get_status(const GBinSymbol *symbol)
{
- return symbol->status;
+ SymbolStatus result; /* Visibilité à retourner */
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = extra->status;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
}
diff --git a/src/format/symbol.h b/src/format/symbol.h
index 35bc1ce..48f740e 100644
--- a/src/format/symbol.h
+++ b/src/format/symbol.h
@@ -64,12 +64,12 @@ typedef enum _SymbolStatus
} SymbolStatus;
-#define G_TYPE_BIN_SYMBOL g_binary_symbol_get_type()
-#define G_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_binary_symbol_get_type(), GBinSymbol))
-#define G_IS_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_binary_symbol_get_type()))
-#define G_BIN_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BIN_SYMBOL, GBinSymbolClass))
-#define G_IS_BIN_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BIN_SYMBOL))
-#define G_BIN_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BIN_SYMBOL, GBinSymbolClass))
+#define G_TYPE_BIN_SYMBOL g_binary_symbol_get_type()
+#define G_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BIN_SYMBOL, GBinSymbol))
+#define G_IS_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_BIN_SYMBOL))
+#define G_BIN_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BIN_SYMBOL, GBinSymbolClass))
+#define G_IS_BIN_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BIN_SYMBOL))
+#define G_BIN_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BIN_SYMBOL, GBinSymbolClass))
/* Symbole d'exécutable (instance) */