summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/archbase.h25
-rw-r--r--src/arch/arm/context-int.h1
-rw-r--r--src/arch/arm/context.c18
-rw-r--r--src/arch/arm/v7/context.c10
-rw-r--r--src/arch/context-int.h12
-rw-r--r--src/arch/context.c69
-rw-r--r--src/arch/context.h2
7 files changed, 118 insertions, 19 deletions
diff --git a/src/arch/archbase.h b/src/arch/archbase.h
index 24cfd77..fc6fe4d 100644
--- a/src/arch/archbase.h
+++ b/src/arch/archbase.h
@@ -74,6 +74,31 @@ typedef enum _MemoryDataSize
#define MDS_IS_SIGNED(mds) (mds & 0x80)
+#define MDS_FROM_BYTES(sz) \
+ ({ \
+ MemoryDataSize __result; \
+ switch (sz) \
+ { \
+ case 1: \
+ __result = MDS_8_BITS_UNSIGNED; \
+ break; \
+ case 2: \
+ __result = MDS_16_BITS_UNSIGNED; \
+ break; \
+ case 4: \
+ __result = MDS_32_BITS_UNSIGNED; \
+ break; \
+ case 8: \
+ __result = MDS_64_BITS_UNSIGNED; \
+ break; \
+ default: \
+ __result = MDS_UNDEFINED; \
+ break; \
+ } \
+ __result; \
+ })
+
+
#define MDS_4_BITS MDS_4_BITS_UNSIGNED
#define MDS_8_BITS MDS_8_BITS_UNSIGNED
#define MDS_16_BITS MDS_16_BITS_UNSIGNED
diff --git a/src/arch/arm/context-int.h b/src/arch/arm/context-int.h
index 51ed6d0..fbd3a6f 100644
--- a/src/arch/arm/context-int.h
+++ b/src/arch/arm/context-int.h
@@ -50,6 +50,7 @@ struct _GArmContext
disass_arm_area *areas; /* Désassemblage découpé */
size_t acount; /* Nombre de zones définies */
+ GMutex areas_access; /* Accès aux découpes de zones */
};
diff --git a/src/arch/arm/context.c b/src/arch/arm/context.c
index b54de42..d805e8c 100644
--- a/src/arch/arm/context.c
+++ b/src/arch/arm/context.c
@@ -139,6 +139,7 @@ static void g_arm_context_class_init(GArmContextClass *klass)
static void g_arm_context_init(GArmContext *ctx)
{
+ g_mutex_init(&ctx->areas_access);
}
@@ -157,6 +158,8 @@ static void g_arm_context_init(GArmContext *ctx)
static void g_arm_context_dispose(GArmContext *ctx)
{
+ g_mutex_clear(&ctx->areas_access);
+
G_OBJECT_CLASS(g_arm_context_parent_class)->dispose(G_OBJECT(ctx));
}
@@ -263,11 +266,11 @@ void _g_arm_context_define_encoding(GArmContext *ctx, virt_t addr, unsigned int
{
size_t selected; /* Zone associée à une adresse */
- /* TODO : pose de verroux ? */
+ g_mutex_lock(&ctx->areas_access);
selected = find_disass_arm_area(ctx->areas, addr, 0, ctx->acount - 1);
- assert(ctx->areas[selected].start != addr || ctx->areas[selected].marker == marker);
+ //assert(ctx->areas[selected].start != addr || ctx->areas[selected].marker == marker);
/* S'agit-il d'une redéfinition ? */
if (ctx->areas[selected].start == addr)
@@ -290,6 +293,8 @@ void _g_arm_context_define_encoding(GArmContext *ctx, virt_t addr, unsigned int
}
+ g_mutex_unlock(&ctx->areas_access);
+
}
@@ -308,13 +313,18 @@ void _g_arm_context_define_encoding(GArmContext *ctx, virt_t addr, unsigned int
unsigned int _g_arm_context_find_encoding(GArmContext *ctx, virt_t addr)
{
+ unsigned int result; /* Identifiant à retourner */
size_t selected; /* Zone associée à une adresse */
- /* TODO : pose de verroux ? */
+ g_mutex_lock(&ctx->areas_access);
selected = find_disass_arm_area(ctx->areas, addr, 0, ctx->acount - 1);
- return ctx->areas[selected].marker;
+ result = ctx->areas[selected].marker;
+
+ g_mutex_unlock(&ctx->areas_access);
+
+ return result;
}
diff --git a/src/arch/arm/v7/context.c b/src/arch/arm/v7/context.c
index 885ce70..030457e 100644
--- a/src/arch/arm/v7/context.c
+++ b/src/arch/arm/v7/context.c
@@ -245,7 +245,15 @@ void g_armv7_context_push_drop_point_ext(GArmV7Context *ctx, virt_t addr, ArmV7I
g_armv7_context_define_encoding(ctx, addr, marker);
- G_PROC_CONTEXT_CLASS(g_armv7_context_parent_class)->push_point(G_PROC_CONTEXT(ctx), addr);
+ /**
+ * Il faut impérativement passer pour l'interface publique afin :
+ * - de poser le verrou associé.
+ * - de déclencher l'émission du signal lié.
+ *
+ * Pas d'appel via G_PROC_CONTEXT_CLASS(g_armv7_context_parent_class)->push_point() donc.
+ */
+
+ g_proc_context_push_drop_point(G_PROC_CONTEXT(ctx), addr);
}
diff --git a/src/arch/context-int.h b/src/arch/context-int.h
index 64465a2..086a8ec 100644
--- a/src/arch/context-int.h
+++ b/src/arch/context-int.h
@@ -29,6 +29,10 @@
+/* Granularité des allocations */
+#define DP_ALLOC_BLOCK 10
+
+
/* Ajoute une adresse virtuelle comme point de départ de code. */
typedef void (* push_drop_point_fc) (GProcContext *, virt_t);
@@ -39,7 +43,9 @@ struct _GProcContext
GObject parent; /* A laisser en premier */
virt_t *drop_points; /* Liste de points de départ */
- size_t dp_count; /* Taille de cette liste */
+ size_t dp_allocated; /* Taille de liste allouée */
+ size_t dp_count; /* Quantité utile de la liste */
+ GMutex dp_access; /* Accès à la liste FIFO */
vmpa2t *extra_symbols; /* Adresses de symboles */
size_t esyms_count; /* Nombres de nouveautés */
@@ -54,6 +60,10 @@ struct _GProcContextClass
push_drop_point_fc push_point; /* Inclusion de points de chute*/
+ /* Signaux */
+
+ void (* drop_point_pushed) (GProcContext *);
+
};
diff --git a/src/arch/context.c b/src/arch/context.c
index 5427e4a..968a6ea 100644
--- a/src/arch/context.c
+++ b/src/arch/context.c
@@ -65,6 +65,14 @@ static void g_proc_context_class_init(GProcContextClass *klass)
{
klass->push_point = (push_drop_point_fc)_g_proc_context_push_drop_point;
+ g_signal_new("drop-point-pushed",
+ G_TYPE_PROC_CONTEXT,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GProcContextClass, drop_point_pushed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
}
@@ -83,7 +91,9 @@ static void g_proc_context_class_init(GProcContextClass *klass)
static void g_proc_context_init(GProcContext *ctx)
{
ctx->drop_points = NULL;
+ ctx->dp_allocated = 0;
ctx->dp_count = 0;
+ g_mutex_init(&ctx->dp_access);
ctx->extra_symbols = NULL;
ctx->esyms_count = 0;
@@ -106,9 +116,15 @@ static void g_proc_context_init(GProcContext *ctx)
static void _g_proc_context_push_drop_point(GProcContext *ctx, virt_t addr)
{
- ctx->drop_points = (virt_t *)realloc(ctx->drop_points, ++ctx->dp_count * sizeof(virt_t));
+ if (ctx->dp_count >= ctx->dp_allocated)
+ {
+ ctx->dp_allocated += DP_ALLOC_BLOCK;
+
+ ctx->drop_points = (virt_t *)realloc(ctx->drop_points, ctx->dp_allocated * sizeof(virt_t));
+
+ }
- ctx->drop_points[ctx->dp_count - 1] = addr;
+ ctx->drop_points[ctx->dp_count++] = addr;
}
@@ -128,7 +144,13 @@ static void _g_proc_context_push_drop_point(GProcContext *ctx, virt_t addr)
void g_proc_context_push_drop_point(GProcContext *ctx, virt_t addr)
{
- return G_PROC_CONTEXT_GET_CLASS(ctx)->push_point(ctx, addr);
+ g_mutex_lock(&ctx->dp_access);
+
+ G_PROC_CONTEXT_GET_CLASS(ctx)->push_point(ctx, addr);
+
+ g_mutex_unlock(&ctx->dp_access);
+
+ g_signal_emit_by_name(ctx, "drop-point-pushed");
}
@@ -147,7 +169,15 @@ void g_proc_context_push_drop_point(GProcContext *ctx, virt_t addr)
bool g_proc_context_has_drop_points(const GProcContext *ctx)
{
- return ctx->dp_count > 0;
+ bool result; /* Etat à retourner */
+
+ g_mutex_lock(&ctx->dp_access);
+
+ result = (ctx->dp_count > 0);
+
+ g_mutex_unlock(&ctx->dp_access);
+
+ return result;
}
@@ -172,9 +202,13 @@ bool g_proc_context_has_addr_as_drop_points(const GProcContext *ctx, virt_t addr
result = false;
+ g_mutex_lock(&ctx->dp_access);
+
for (i = 0; i < ctx->dp_count && !result; i++)
result = (ctx->drop_points[i] == addr);
+ g_mutex_unlock(&ctx->dp_access);
+
return result;
}
@@ -183,27 +217,38 @@ bool g_proc_context_has_addr_as_drop_points(const GProcContext *ctx, virt_t addr
/******************************************************************************
* *
* Paramètres : ctx = contexte de désassemblage à compléter. *
+* virt = adresse d'un point de départ de code à traiter. *
* *
* Description : Fournit une adresse virtuelle comme point de départ de code. *
* *
-* Retour : Adresse d'un point de départ de code à traiter. *
+* Retour : true si une adresse a pu être dépilée, false sinon. *
* *
* Remarques : - *
* *
******************************************************************************/
-virt_t g_proc_context_pop_drop_point(GProcContext *ctx)
+bool g_proc_context_pop_drop_point(GProcContext *ctx, virt_t *virt)
{
- virt_t result; /* Adresse à retourner */
+ bool result; /* Bilan d'accès à retourner */
- assert(ctx->dp_count > 0);
+ g_mutex_lock(&ctx->dp_access);
- result = ctx->drop_points[0];
+ if (ctx->dp_count > 0)
+ {
+ result = true;
+
+ *virt = ctx->drop_points[0];
+
+ if (ctx->dp_count > 1)
+ memmove(&ctx->drop_points[0], &ctx->drop_points[1], (ctx->dp_count - 1) * sizeof(virt_t));
- if (ctx->dp_count > 1)
- memmove(&ctx->drop_points[0], &ctx->drop_points[1], (ctx->dp_count - 1) * sizeof(virt_t));
+ ctx->dp_count--;
+
+ }
+ else
+ result = false;
- ctx->drop_points = (virt_t *)realloc(ctx->drop_points, --ctx->dp_count * sizeof(virt_t));
+ g_mutex_unlock(&ctx->dp_access);
return result;
diff --git a/src/arch/context.h b/src/arch/context.h
index 390d9f9..973b7ae 100644
--- a/src/arch/context.h
+++ b/src/arch/context.h
@@ -61,7 +61,7 @@ bool g_proc_context_has_drop_points(const GProcContext *);
bool g_proc_context_has_addr_as_drop_points(const GProcContext *, virt_t);
/* Fournit une adresse virtuelle comme point de départ de code. */
-virt_t g_proc_context_pop_drop_point(GProcContext *);
+bool g_proc_context_pop_drop_point(GProcContext *, virt_t *);
/* Empile une adresse de nouveau symbole à prendre en compte. */
void g_proc_context_push_new_symbol_at(GProcContext *, const vmpa2t *);