From 945f58cb1e1b8b6dc444dd0668bd1a2986cd899e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 29 Oct 2016 13:55:02 +0200 Subject: Told GCC to pack enumerations to save memory space. --- ChangeLog | 8 +++ configure.ac | 5 ++ src/analysis/disass/fetch.c | 2 +- src/arch/immediate.c | 144 ++------------------------------------------ src/arch/instruction-int.h | 3 +- 5 files changed, 20 insertions(+), 142 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1569aac..f326cdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 16-10-29 Cyrille Bagard + * configure.ac: + * src/analysis/disass/fetch.c: + * src/arch/immediate.c: + * src/arch/instruction-int.h: + Tell GCC to pack enumerations to save memory space. + +16-10-29 Cyrille Bagard + * src/arch/arm/instruction-int.h: * src/arch/arm/instruction.c: * src/arch/arm/instruction.h: diff --git a/configure.ac b/configure.ac index ca54caa..c34cfb6 100644 --- a/configure.ac +++ b/configure.ac @@ -141,6 +141,11 @@ fi AC_ARG_ENABLE(debug, [ --enable-debug compile with debugging support [def=no]], [enable_debug=yes], [enable_debug=no]) +#--- Small enumerations + +CFLAGS="$CFLAGS -fshort-enums" + +AC_SUBST(CFLAGS) #--- Is debug mode needed ? diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 7d8161a..ab3f3c7 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -97,7 +97,7 @@ static void g_delayed_fetching_dispose(GDelayedFetching *); static void g_delayed_fetching_finalize(GDelayedFetching *); /* Crée une tâche de récupération d'instructions différée. */ -static GDelayedFetching *g_delayed_fetching_new(const GDelayedFetching *, unsigned int, virt_t); +static GDelayedFetching *g_delayed_fetching_new(const GDelayedFetching *, DisassPriorityLevel, virt_t); /* Assure la récupération d'instructions en différé. */ static void g_delayed_fetching_process(GDelayedFetching *, GtkExtStatusBar *); diff --git a/src/arch/immediate.c b/src/arch/immediate.c index 777ae14..9de8c39 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -44,32 +44,8 @@ struct _GImmOperand { GArchOperand parent; /* Instance parente */ - MemoryDataSize size; /* Taille de l'opérande */ uint64_t raw; /* Valeur transtypée */ - - /** - * Note : dans le cas d'une valeur signée, - * signed_imm contient la valeur lue/donnée, et - * unsigned_imm la valeur humainement lisible (ie. positive). - */ - - union - { - uint8_t val8; /* Valeur sur 8 bits */ - uint16_t val16; /* Valeur sur 16 bits */ - uint32_t val32; /* Valeur sur 32 bits */ - uint64_t val64; /* Valeur sur 64 bits */ - - } unsigned_imm; - - union - { - int8_t val8; /* Valeur sur 8 bits */ - int16_t val16; /* Valeur sur 16 bits */ - int32_t val32; /* Valeur sur 32 bits */ - int64_t val64; /* Valeur sur 64 bits */ - - } signed_imm; + MemoryDataSize size; /* Taille de l'opérande */ bool zpad; /* Ajoute des 0 à l'impression */ ImmOperandDisplay def_display; /* Type par défaut d'affichage */ @@ -1009,31 +985,7 @@ void g_imm_operand_as_uleb128(const GImmOperand *operand, uleb128_t *val) bool g_imm_operand_to_vmpa_t(const GImmOperand *operand, vmpa_t *addr) { - bool result; /* Bilan à renvoyer */ - - result = true; - - switch (operand->size) - { - case MDS_4_BITS_UNSIGNED: - case MDS_8_BITS_UNSIGNED: - *addr = operand->unsigned_imm.val8; - break; - case MDS_16_BITS_UNSIGNED: - *addr = operand->unsigned_imm.val16; - break; - case MDS_32_BITS_UNSIGNED: - *addr = operand->unsigned_imm.val32; - break; - case MDS_64_BITS_UNSIGNED: - *addr = operand->unsigned_imm.val64; - break; - default: - result = false; - break; - } - - return result; + return false; } @@ -1054,51 +1006,7 @@ bool g_imm_operand_to_vmpa_t(const GImmOperand *operand, vmpa_t *addr) bool g_imm_operand_to_size_t(const GImmOperand *operand, size_t *value, bool *negative) { - bool result; /* Bilan à renvoyer */ - - *negative = g_imm_operand_is_negative(operand); - - switch (operand->size) - { - case MDS_4_BITS_UNSIGNED: - case MDS_8_BITS_UNSIGNED: - result = (sizeof(size_t) >= 1); - if (result) *value = operand->unsigned_imm.val8; - break; - case MDS_16_BITS_UNSIGNED: - result = (sizeof(size_t) >= 2); - if (result) *value = operand->unsigned_imm.val16; - break; - case MDS_32_BITS_UNSIGNED: - result = (sizeof(size_t) >= 4); - if (result) *value = operand->unsigned_imm.val32; - break; - case MDS_64_BITS_UNSIGNED: - result = (sizeof(size_t) >= 8); - if (result) *value = operand->unsigned_imm.val64; - break; - case MDS_8_BITS_SIGNED: - result = (sizeof(size_t) >= 1); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val8; - break; - case MDS_16_BITS_SIGNED: - result = (sizeof(size_t) >= 2); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val16; - break; - case MDS_32_BITS_SIGNED: - result = (sizeof(size_t) >= 4); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val32; - break; - case MDS_64_BITS_SIGNED: - result = (sizeof(size_t) >= 8); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val64; - break; - default: - result = false; - break; - } - - return result; + return false; } @@ -1119,50 +1027,6 @@ bool g_imm_operand_to_size_t(const GImmOperand *operand, size_t *value, bool *ne bool g_imm_operand_to_off_t(const GImmOperand *operand, off_t *value, bool *negative) { - bool result; /* Bilan à renvoyer */ - - *negative = g_imm_operand_is_negative(operand); - - switch (operand->size) - { - case MDS_4_BITS_UNSIGNED: - case MDS_8_BITS_UNSIGNED: - result = (sizeof(off_t) >= 1); - if (result) *value = operand->unsigned_imm.val8; - break; - case MDS_16_BITS_UNSIGNED: - result = (sizeof(off_t) >= 2); - if (result) *value = operand->unsigned_imm.val16; - break; - case MDS_32_BITS_UNSIGNED: - result = (sizeof(off_t) >= 4); - if (result) *value = operand->unsigned_imm.val32; - break; - case MDS_64_BITS_UNSIGNED: - result = (sizeof(off_t) >= 8); - if (result) *value = operand->unsigned_imm.val64; - break; - case MDS_8_BITS_SIGNED: - result = (sizeof(off_t) >= 1); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val8; - break; - case MDS_16_BITS_SIGNED: - result = (sizeof(off_t) >= 2); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val16; - break; - case MDS_32_BITS_SIGNED: - result = (sizeof(off_t) >= 4); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val32; - break; - case MDS_64_BITS_SIGNED: - result = (sizeof(off_t) >= 8); - if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val64; - break; - default: - result = false; - break; - } - - return result; + return false; } diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index e4d886b..f2964e6 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -57,7 +57,6 @@ struct _GArchInstruction phys_t max_displayed_len; /* Quantité de code affichée */ - ArchInstrFlag flags; /* Informations complémentaires*/ const instr_hook_fc *hooks; /* Traitements complémentaires */ mrange_t range; /* Emplacement en mémoire */ @@ -74,6 +73,8 @@ struct _GArchInstruction gint hold_link_access; /* Suivi des verrouillages */ #endif + ArchInstrFlag flags; /* Informations complémentaires*/ + //get_instruction_rw_regs_fc get_rw_regs; /* Liste des registres liés */ //print_instruction_fc print; /* Imprime l'ensemble */ //get_instruction_keyword_fc get_key; /* Texte humain équivalent */ -- cgit v0.11.2-87-g4458