From 429b54556283116a29c5d699af0cf891bb1c1055 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 17 Aug 2022 23:37:24 +0200 Subject: Disable the extra data storage inside the GObject structure. --- plugins/arm/v7/operand.c | 4 ++-- plugins/arm/v7/operands/it.c | 4 ++-- plugins/arm/v7/operands/limitation.c | 4 ++-- plugins/arm/v7/operands/maccess.c | 4 ++-- plugins/arm/v7/operands/register.c | 4 ++-- plugins/arm/v7/operands/reglist.c | 4 ++-- plugins/arm/v7/operands/shift.c | 8 ++++---- plugins/dalvik/operands/args.c | 12 ++++++------ plugins/dalvik/operands/pool.c | 8 ++++---- src/analysis/type-int.h | 4 ++-- src/arch/instruction-int.h | 4 ++-- src/arch/instructions/undefined-int.h | 4 ++-- src/arch/operand-int.h | 4 ++-- src/arch/operands/immediate-int.h | 4 ++-- src/arch/operands/known.c | 12 ++++++------ src/arch/operands/proxy.c | 12 ++++++------ src/arch/operands/target-int.h | 4 ++-- src/format/format-int.h | 4 ++-- src/format/symbol-int.h | 4 ++-- src/glibext/objhole.h | 28 ++++++++++++++++++++++++++-- 20 files changed, 80 insertions(+), 56 deletions(-) diff --git a/plugins/arm/v7/operand.c b/plugins/arm/v7/operand.c index 8f93e78..ad7b572 100644 --- a/plugins/arm/v7/operand.c +++ b/plugins/arm/v7/operand.c @@ -169,10 +169,10 @@ static void g_armv7_operand_finalize(GArmV7Operand *operand) static guint g_armv7_operand_hash(const GArmV7Operand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + operand_extra_data_t *extra; /* Données insérées à modifier */ GArchOperandClass *class; /* Classe parente normalisée */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/plugins/arm/v7/operands/it.c b/plugins/arm/v7/operands/it.c index b2fb2f6..0286e06 100644 --- a/plugins/arm/v7/operands/it.c +++ b/plugins/arm/v7/operands/it.c @@ -61,9 +61,9 @@ struct _GArmV7ITCondOperand * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_ARMV7_ITCOND_OP_EXTRA(op) (a7itcop_extra_data_t *)&op->extra +# define GET_ARMV7_ITCOND_OP_EXTRA(op) ((a7itcop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/plugins/arm/v7/operands/limitation.c b/plugins/arm/v7/operands/limitation.c index f2e8373..fe8d9fb 100644 --- a/plugins/arm/v7/operands/limitation.c +++ b/plugins/arm/v7/operands/limitation.c @@ -66,9 +66,9 @@ struct _GArmV7LimitationOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_ARMV7_LIMITATION_OP_EXTRA(op) (a7limop_extra_data_t *)&op->extra +# define GET_ARMV7_LIMITATION_OP_EXTRA(op) ((a7limop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/plugins/arm/v7/operands/maccess.c b/plugins/arm/v7/operands/maccess.c index d503b12..b67b65a 100644 --- a/plugins/arm/v7/operands/maccess.c +++ b/plugins/arm/v7/operands/maccess.c @@ -682,11 +682,11 @@ static void g_armv7_maccess_operand_update_inner_instances(GArmV7MAccessOperand static guint g_armv7_maccess_operand_hash(const GArmV7MAccessOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + operand_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ size_t count; /* Quantité d'éléments utiles */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/plugins/arm/v7/operands/register.c b/plugins/arm/v7/operands/register.c index 026d0d5..21dc129 100644 --- a/plugins/arm/v7/operands/register.c +++ b/plugins/arm/v7/operands/register.c @@ -63,9 +63,9 @@ struct _GArmV7RegisterOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_ARMV7_REGISTER_OP_EXTRA(op) (a7regop_extra_data_t *)&op->extra +# define GET_ARMV7_REGISTER_OP_EXTRA(op) ((a7regop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/plugins/arm/v7/operands/reglist.c b/plugins/arm/v7/operands/reglist.c index d53a7e1..df93f77 100644 --- a/plugins/arm/v7/operands/reglist.c +++ b/plugins/arm/v7/operands/reglist.c @@ -447,11 +447,11 @@ static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *operand, G static guint g_armv7_reglist_operand_hash(const GArmV7RegListOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + operand_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ size_t i; /* Boucle de parcours */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/plugins/arm/v7/operands/shift.c b/plugins/arm/v7/operands/shift.c index ccdfe5c..1e1a8ab 100644 --- a/plugins/arm/v7/operands/shift.c +++ b/plugins/arm/v7/operands/shift.c @@ -72,9 +72,9 @@ struct _GArmV7ShiftOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_ARMV7_SHIFT_OP_EXTRA(op) (a7shiftop_extra_data_t *)&op->extra +# define GET_ARMV7_SHIFT_OP_EXTRA(op) ((a7shiftop_extra_data_t *)&((GArchOperand *)op)->extra) #else @@ -561,11 +561,11 @@ static void g_armv7_shift_operand_update_inner_instances(GArmV7ShiftOperand *ope static guint g_armv7_shift_operand_hash(const GArmV7ShiftOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + a7shiftop_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ a7shiftop_extra_data_t *op_extra; /* Données internes à manipuler*/ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARMV7_SHIFT_OP_EXTRA(G_ARMV7_SHIFT_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/plugins/dalvik/operands/args.c b/plugins/dalvik/operands/args.c index b1aa59f..01ed122 100644 --- a/plugins/dalvik/operands/args.c +++ b/plugins/dalvik/operands/args.c @@ -324,8 +324,8 @@ GArchOperand *g_dalvik_args_operand_get(const GDalvikArgsOperand *operand, size_ static int g_dalvik_args_operand_compare(const GDalvikArgsOperand *a, const GDalvikArgsOperand *b, bool lock) { int result; /* Bilan à renvoyer */ - lockable_obj_extra_t *ea; /* Données insérées à consulter*/ - lockable_obj_extra_t *eb; /* Données insérées à consulter*/ + operand_extra_data_t *ea; /* Données insérées à consulter*/ + operand_extra_data_t *eb; /* Données insérées à consulter*/ size_t i; /* Boucle de parcours */ GArchOperandClass *class; /* Classe parente normalisée */ @@ -335,8 +335,8 @@ static int g_dalvik_args_operand_compare(const GDalvikArgsOperand *a, const GDal else { - ea = GET_GOBJECT_EXTRA(G_OBJECT(a), lockable_obj_extra_t); - eb = GET_GOBJECT_EXTRA(G_OBJECT(b), lockable_obj_extra_t); + ea = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(a)); + eb = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(b)); if (lock) { @@ -611,10 +611,10 @@ static void g_dalvik_args_operand_update_inner_instances(GDalvikArgsOperand *ope static guint g_dalvik_args_operand_hash(const GDalvikArgsOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + operand_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/plugins/dalvik/operands/pool.c b/plugins/dalvik/operands/pool.c index 4570c86..a07b3e0 100644 --- a/plugins/dalvik/operands/pool.c +++ b/plugins/dalvik/operands/pool.c @@ -75,9 +75,9 @@ struct _GDalvikPoolOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_DALVIK_POOL_OP_EXTRA(op) (dpoolop_extra_data_t *)&op->extra +# define GET_DALVIK_POOL_OP_EXTRA(op) ((dpoolop_extra_data_t *)&((GArchOperand *)op)->extra) #else @@ -662,12 +662,12 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff static guint g_dalvik_pool_operand_hash(const GDalvikPoolOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + dpoolop_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ DalvikPoolType type; /* Type porté par l'opérande */ uint32_t index; /* Indice de l'élément */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_DALVIK_POOL_OP_EXTRA(G_DALVIK_POOL_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/src/analysis/type-int.h b/src/analysis/type-int.h index 8999b19..5a804ab 100644 --- a/src/analysis/type-int.h +++ b/src/analysis/type-int.h @@ -88,7 +88,7 @@ struct _GDataType { GObject parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -128,7 +128,7 @@ struct _GDataTypeClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_DATA_TYPE_EXTRA(tp) (type_extra_data_t *)&tp->extra diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index f8998a1..7dbbe27 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -90,7 +90,7 @@ struct _GArchInstruction { GObject parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -162,7 +162,7 @@ struct _GArchInstructionClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_ARCH_INSTR_EXTRA(ins) (instr_extra_data_t *)&ins->extra diff --git a/src/arch/instructions/undefined-int.h b/src/arch/instructions/undefined-int.h index 491ec31..a9b7627 100644 --- a/src/arch/instructions/undefined-int.h +++ b/src/arch/instructions/undefined-int.h @@ -73,9 +73,9 @@ struct _GUndefInstructionClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_UNDEF_INSTR_EXTRA(ins) (undef_extra_data_t *)&ins->extra +# define GET_UNDEF_INSTR_EXTRA(ins) ((undef_extra_data_t *)&((GArchInstruction *)ins)->extra) #else diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index d424e94..e78c2b0 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -88,7 +88,7 @@ struct _GArchOperand { GObject parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -129,7 +129,7 @@ struct _GArchOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_ARCH_OP_EXTRA(op) (operand_extra_data_t *)&op->extra diff --git a/src/arch/operands/immediate-int.h b/src/arch/operands/immediate-int.h index 46bc3ce..d2313f5 100644 --- a/src/arch/operands/immediate-int.h +++ b/src/arch/operands/immediate-int.h @@ -70,9 +70,9 @@ struct _GImmOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_IMM_OP_EXTRA(op) (immop_extra_data_t *)&op->extra +# define GET_IMM_OP_EXTRA(op) ((immop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/src/arch/operands/known.c b/src/arch/operands/known.c index a4b3844..152bdac 100644 --- a/src/arch/operands/known.c +++ b/src/arch/operands/known.c @@ -292,12 +292,12 @@ GArchOperand *g_known_imm_operand_new(const GImmOperand *old, const char *alt) static int g_known_imm_operand_compare(const GKnownImmOperand *a, const GKnownImmOperand *b, bool lock) { int result; /* Bilan à retourner */ - lockable_obj_extra_t *ea; /* Données insérées à consulter*/ - lockable_obj_extra_t *eb; /* Données insérées à consulter*/ + immop_extra_data_t *ea; /* Données insérées à consulter*/ + immop_extra_data_t *eb; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - ea = GET_GOBJECT_EXTRA(G_OBJECT(a), lockable_obj_extra_t); - eb = GET_GOBJECT_EXTRA(G_OBJECT(b), lockable_obj_extra_t); + ea = GET_IMM_OP_EXTRA(G_IMM_OPERAND(a)); + eb = GET_IMM_OP_EXTRA(G_IMM_OPERAND(b)); if (lock) { @@ -364,10 +364,10 @@ static void g_known_imm_operand_print(const GKnownImmOperand *operand, GBufferLi static guint g_known_imm_operand_hash(const GKnownImmOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + immop_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_IMM_OP_EXTRA(G_IMM_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/src/arch/operands/proxy.c b/src/arch/operands/proxy.c index 91690a7..c71f96f 100644 --- a/src/arch/operands/proxy.c +++ b/src/arch/operands/proxy.c @@ -241,12 +241,12 @@ GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand) static int g_proxy_operand_compare(const GProxyOperand *a, const GProxyOperand *b, bool lock) { int result; /* Bilan à retourner */ - lockable_obj_extra_t *ea; /* Données insérées à consulter*/ - lockable_obj_extra_t *eb; /* Données insérées à consulter*/ + operand_extra_data_t *ea; /* Données insérées à consulter*/ + operand_extra_data_t *eb; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - ea = GET_GOBJECT_EXTRA(G_OBJECT(a), lockable_obj_extra_t); - eb = GET_GOBJECT_EXTRA(G_OBJECT(b), lockable_obj_extra_t); + ea = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(a)); + eb = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(b)); if (lock) { @@ -309,10 +309,10 @@ static void g_proxy_operand_print(const GProxyOperand *operand, GBufferLine *lin static guint g_proxy_operand_hash(const GProxyOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + operand_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/src/arch/operands/target-int.h b/src/arch/operands/target-int.h index ac4cdcd..aa48b2b 100644 --- a/src/arch/operands/target-int.h +++ b/src/arch/operands/target-int.h @@ -65,9 +65,9 @@ struct _GTargetOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_TARGET_OP_EXTRA(op) (tarop_extra_data_t *)&op->extra +# define GET_TARGET_OP_EXTRA(op) ((tarop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/src/format/format-int.h b/src/format/format-int.h index 11505d0..3e6ae3e 100644 --- a/src/format/format-int.h +++ b/src/format/format-int.h @@ -77,7 +77,7 @@ struct _GBinFormat { GKnownFormat parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -135,7 +135,7 @@ struct _GBinFormatClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_BIN_FORMAT_EXTRA(fmt) (fmt_extra_data_t *)&fmt->extra diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h index 7f8bb7f..48a27ed 100644 --- a/src/format/symbol-int.h +++ b/src/format/symbol-int.h @@ -67,7 +67,7 @@ struct _GBinSymbol { GObject parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -103,7 +103,7 @@ struct _GBinSymbolClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_BIN_SYMBOL_EXTRA(sym) (sym_extra_data_t *)&sym->extra diff --git a/src/glibext/objhole.h b/src/glibext/objhole.h index c256cfb..38f4bd5 100644 --- a/src/glibext/objhole.h +++ b/src/glibext/objhole.h @@ -43,11 +43,33 @@ * GData *qdata; * }; * - * L'espace entre les deux derniers champs est exploité ici. + * En revanche, le fichier "glib/gobject/gobject.c" précise la définition + * réelle de la structure selon l'environnement : + * + * #if SIZEOF_INT == 4 && GLIB_SIZEOF_VOID_P == 8 + * #define HAVE_OPTIONAL_FLAGS + * #endif + * + * typedef struct + * { + * GTypeInstance g_type_instance; + * guint ref_count; + * #ifdef HAVE_OPTIONAL_FLAGS + * guint optional_flags; + * #endif + * GData *qdata; + * } GObjectReal; + * + * G_STATIC_ASSERT(sizeof(GObject) == sizeof(GObjectReal)); + * G_STATIC_ASSERT(G_STRUCT_OFFSET(GObject, ref_count) == G_STRUCT_OFFSET(GObjectReal, ref_count)); + * G_STATIC_ASSERT(G_STRUCT_OFFSET(GObject, qdata) == G_STRUCT_OFFSET(GObjectReal, qdata)); + * + * L'espace entre les deux derniers champs ne peut donc être pleinement exploité deux fois. */ +#if 0 -#define GET_GOBJECT_EXTRA(obj, tp) \ +# define GET_GOBJECT_EXTRA(obj, tp) \ ({ \ BUILD_BUG_ON(sizeof(tp) > sizeof(guint)); \ tp *___result; \ @@ -56,6 +78,8 @@ ___result; \ }) +#endif + /** * Choix du bit de verrou pour le champ "lock". -- cgit v0.11.2-87-g4458