diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/dalvik/dop_aget.c | 6 | ||||
-rw-r--r-- | src/arch/dalvik/dop_aput.c | 6 | ||||
-rw-r--r-- | src/arch/dalvik/dop_arithm.c | 14 | ||||
-rw-r--r-- | src/arch/dalvik/dop_array.c | 4 | ||||
-rw-r--r-- | src/arch/dalvik/dop_const.c | 4 | ||||
-rw-r--r-- | src/arch/dalvik/dop_invoke.c | 6 | ||||
-rw-r--r-- | src/arch/dalvik/operand.c | 30 | ||||
-rw-r--r-- | src/arch/dalvik/register.c | 29 | ||||
-rw-r--r-- | src/arch/dalvik/register.h | 3 | ||||
-rw-r--r-- | src/arch/operand-int.h | 5 | ||||
-rw-r--r-- | src/arch/operand.c | 27 | ||||
-rw-r--r-- | src/arch/operand.h | 3 |
12 files changed, 114 insertions, 23 deletions
diff --git a/src/arch/dalvik/dop_aget.c b/src/arch/dalvik/dop_aget.c index 77e6ef2..5ea57cc 100644 --- a/src/arch/dalvik/dop_aget.c +++ b/src/arch/dalvik/dop_aget.c @@ -52,13 +52,13 @@ GDecInstruction *dalvik_decomp_instr_aget(const GArchInstruction *instr, GDecCon GDecInstruction *access; /* Représentation de l'accès */ operand = g_arch_instruction_get_operand(instr, 0); - content = g_pseudo_register_new(); + content = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 1); - array = g_pseudo_register_new(); + array = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 2); - index = g_pseudo_register_new(); + index = g_dec_context_convert_register(ctx, operand); access = g_array_access_new(G_DEC_EXPRESSION(array), G_DEC_EXPRESSION(index)); result = g_assign_expression_new(G_DEC_EXPRESSION(content), G_DEC_EXPRESSION(access)); diff --git a/src/arch/dalvik/dop_aput.c b/src/arch/dalvik/dop_aput.c index 2e4527e..3b75667 100644 --- a/src/arch/dalvik/dop_aput.c +++ b/src/arch/dalvik/dop_aput.c @@ -52,13 +52,13 @@ GDecInstruction *dalvik_decomp_instr_aput(const GArchInstruction *instr, GDecCon GDecInstruction *access; /* Représentation de l'accès */ operand = g_arch_instruction_get_operand(instr, 0); - content = g_pseudo_register_new(); + content = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 1); - array = g_pseudo_register_new(); + array = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 2); - index = g_pseudo_register_new(); + index = g_dec_context_convert_register(ctx, operand); access = g_array_access_new(G_DEC_EXPRESSION(array), G_DEC_EXPRESSION(index)); result = g_assign_expression_new(G_DEC_EXPRESSION(access), G_DEC_EXPRESSION(content)); diff --git a/src/arch/dalvik/dop_arithm.c b/src/arch/dalvik/dop_arithm.c index 388f906..7657f99 100644 --- a/src/arch/dalvik/dop_arithm.c +++ b/src/arch/dalvik/dop_arithm.c @@ -51,7 +51,6 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr, GArchOperand *operand; /* Opérande de l'instruction */ GDecInstruction *dest; /* Enregistrement du résultat */ GDecInstruction *op1; /* Premier opérande utilisé */ - GDecInstruction *op2; /* Second opérande utilisé */ GDecInstruction *arithm; /* Opération arithmétique */ switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) @@ -84,15 +83,12 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr, } operand = g_arch_instruction_get_operand(instr, 0); - dest = g_pseudo_register_new(); + dest = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 1); - op1 = g_pseudo_register_new(); - - operand = g_arch_instruction_get_operand(instr, 2); - op2 = g_pseudo_register_new(); + op1 = g_dec_context_convert_register(ctx, operand); - arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2)); + arithm = g_arithm_expression_new(G_DEC_EXPRESSION(dest), type, G_DEC_EXPRESSION(op1)); result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); return result; @@ -159,10 +155,10 @@ GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, G } operand = g_arch_instruction_get_operand(instr, 0); - dest = g_pseudo_register_new(); + dest = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 1); - op1 = g_pseudo_register_new(); + op1 = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 2); op2 = g_imm_expression_new(G_IMM_OPERAND(operand)); diff --git a/src/arch/dalvik/dop_array.c b/src/arch/dalvik/dop_array.c index 035b3eb..fa9f94f 100644 --- a/src/arch/dalvik/dop_array.c +++ b/src/arch/dalvik/dop_array.c @@ -60,11 +60,11 @@ GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *instr, operand = g_arch_instruction_get_operand(instr, 1); - reg = g_pseudo_register_new(); + reg = g_dec_context_convert_register(ctx, operand); len = g_dalvik_alength_new(G_DEC_EXPRESSION(reg)); operand = g_arch_instruction_get_operand(instr, 0); - reg = g_pseudo_register_new(); + reg = g_dec_context_convert_register(ctx, operand); result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(len)); diff --git a/src/arch/dalvik/dop_const.c b/src/arch/dalvik/dop_const.c index eab7acd..ea88089 100644 --- a/src/arch/dalvik/dop_const.c +++ b/src/arch/dalvik/dop_const.c @@ -59,8 +59,8 @@ GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecCo - operand = g_arch_instruction_get_operand(instr, 1); - reg = g_pseudo_register_new(); + operand = g_arch_instruction_get_operand(instr, 0); + reg = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 1); imm = g_imm_expression_new(G_IMM_OPERAND(operand)); diff --git a/src/arch/dalvik/dop_invoke.c b/src/arch/dalvik/dop_invoke.c index e4fa1fb..6fdca06 100644 --- a/src/arch/dalvik/dop_invoke.c +++ b/src/arch/dalvik/dop_invoke.c @@ -117,7 +117,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst //GDecInstruction *g_routine_call_new(GBinRoutine *routine, bool is_object) /* operand = g_arch_instruction_get_operand(instr, 1); - reg = g_pseudo_register_new(); + reg = g_dec_context_convert_register(ctx, operand); operand = g_arch_instruction_get_operand(instr, 1); imm = g_imm_expression_new(G_IMM_OPERAND(operand)); @@ -141,8 +141,8 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst { case DOP_MOVE_RESULT: - operand = g_arch_instruction_get_operand(instr, 0); - reg = g_pseudo_register_new(); + operand = g_arch_instruction_get_operand(iter, 0); + reg = g_dec_context_convert_register(ctx, operand); result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(result)); diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index 9c4a2c2..3227184 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -87,6 +87,9 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *); /* Initialise une instance d'opérande de registre Dalvik. */ static void g_dalvik_register_operand_init(GDalvikRegisterOperand *); +/* Compare un opérande avec un autre. */ +static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); + /* Ajoute du texte simple à un fichier ouvert en écriture. */ static void g_dalvik_register_operand_add_text(const GDalvikRegisterOperand *, GRenderingOptions *, MainRendering, FILE *); @@ -325,13 +328,18 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) { - GContentExporter *parent; /* Instance parente */ + GContentExporter *parent; /* Instance parente #1 */ + GArchOperand *arch; /* Instance parente #2 */ parent = G_CONTENT_EXPORTER(operand); parent->add_text = (add_text_fc)g_dalvik_register_operand_add_text; parent->export_buffer = (export_buffer_fc)g_dalvik_register_operand_to_buffer; + arch = G_ARCH_OPERAND(operand); + + arch->compare = (operand_compare_fc)g_dalvik_register_operand_compare; + } @@ -400,6 +408,26 @@ GArchOperand *g_dalvik_register_operand_new(const bin_t *data, off_t *pos, off_t /****************************************************************************** * * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *a, const GDalvikRegisterOperand *b) +{ + return g_dalvik_register_compare(a->reg, b->reg); + +} + + +/****************************************************************************** +* * * Paramètres : operand = opérande à transcrire. * * options = options de rendu. * * rendering = support effectif final des lignes de code. * diff --git a/src/arch/dalvik/register.c b/src/arch/dalvik/register.c index fc7757d..dd5a512 100644 --- a/src/arch/dalvik/register.c +++ b/src/arch/dalvik/register.c @@ -134,6 +134,35 @@ GDalvikRegister *g_dalvik_register_new(uint16_t index) } +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un registre avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b) +{ + /* FIXME : GCC (Debian 4.4.5-4) trouble ? */ + + if (a == NULL) + printf("Alerte :: %hd & %hd\n", a->index, b->index); + + /* + printf("Compare :: %p & %p\n", a, b); + printf("Compare :: %hd & %hd\n", a->index, b->index); + */ + + return (a->index == b->index); + +} + /****************************************************************************** * * diff --git a/src/arch/dalvik/register.h b/src/arch/dalvik/register.h index 5ac5617..7767a9b 100644 --- a/src/arch/dalvik/register.h +++ b/src/arch/dalvik/register.h @@ -54,6 +54,9 @@ GType g_dalvik_register_get_type(void); /* Crée une réprésentation de registre Dalvik. */ GDalvikRegister *g_dalvik_register_new(uint16_t); +/* Compare un registre avec un autre. */ +bool g_dalvik_register_compare(const GDalvikRegister *, const GDalvikRegister *); + /* Indique si le registre correspond à ebp ou similaire. */ bool g_dalvik_register_is_base_pointer(const GDalvikRegister *); diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index f21b995..51f392b 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -30,17 +30,22 @@ +/* Compare un opérande avec un autre. */ +typedef bool (* operand_compare_fc) (const GArchOperand *, const GArchOperand *); + /* Traduit un opérande en version humainement lisible. */ typedef char * (* get_operand_text_fc) (const GArchOperand *, const GExeFormat *, AsmSyntax); /* Traduit un opérande en version humainement lisible. */ typedef void (* operand_print_fc) (const GArchOperand *, GBufferLine *, AsmSyntax); + /* Définition générique d'un opérande d'architecture (instance) */ struct _GArchOperand { GContentExporter parent; /* A laisser en premier */ + operand_compare_fc compare; /* Comparaison d'opérandes */ get_operand_text_fc get_text; /* Texte humain équivalent */ operand_print_fc print; /* Texte humain équivalent */ diff --git a/src/arch/operand.c b/src/arch/operand.c index 16fc073..f3aecb6 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -117,3 +117,30 @@ void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line, AsmSyn return operand->print(operand, line, syntax); } + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b) +{ + bool result; /* Bilan à faire remonter */ + + result = (G_OBJECT_TYPE(G_OBJECT(a)) == G_OBJECT_TYPE(G_OBJECT(b))); + + if (result) + result = a->compare(a, b); + + return result; + +} diff --git a/src/arch/operand.h b/src/arch/operand.h index 3745a80..d22235e 100644 --- a/src/arch/operand.h +++ b/src/arch/operand.h @@ -55,6 +55,9 @@ char *g_arch_operand_get_text(const GArchOperand *, const GExeFormat *, AsmSynta /* Traduit un opérande en version humainement lisible. */ void g_arch_operand_print(const GArchOperand *, GBufferLine *, AsmSyntax); +/* Compare un opérande avec un autre. */ +bool g_arch_operand_compare(const GArchOperand *, const GArchOperand *); + #endif /* _ARCH_OPERAND_H */ |