diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2013-01-20 13:10:06 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2013-01-20 13:10:06 (GMT) | 
| commit | 37fd2f1329c56078bc8a8b2fc955aa001c109c01 (patch) | |
| tree | 71bcce9a3eaf6b7569d1f1d3e057752ae517ebde /src/arch/dalvik | |
| parent | a9bbd894bd25f7c2bb72fb7d4064b19377d90c6d (diff) | |
Took care of shared allocations between blocks when converting registers.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@326 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik')
| -rw-r--r-- | src/arch/dalvik/context.c | 73 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/aget.c | 9 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/aput.c | 9 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/arithm.c | 23 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/array.c | 7 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/const.c | 10 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/if.c | 16 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/iget.c | 7 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/invoke.c | 17 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/iput.c | 7 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/move.c | 19 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/new.c | 5 | ||||
| -rw-r--r-- | src/arch/dalvik/decomp/ret.c | 5 | ||||
| -rw-r--r-- | src/arch/dalvik/register.c | 23 | 
14 files changed, 187 insertions, 43 deletions
diff --git a/src/arch/dalvik/context.c b/src/arch/dalvik/context.c index e80ead3..7918467 100644 --- a/src/arch/dalvik/context.c +++ b/src/arch/dalvik/context.c @@ -123,8 +123,11 @@ static void g_dalvik_dcontext_finalize(GDalvikDContext *);  /* Duplique un contexte de compilation. */  static GDalvikDContext *g_dalvik_dcontext_dup(GDalvikDContext *); +/* Propage un registre alloué et attendu par la suite. */ +static void g_dalvik_context_spread_allocated_shared_reg(GDalvikDContext *, GDalvikRegister *, GDecInstruction *); +  /* Convertit un registre machine en un pseudo-registre. */ -static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *, GDalvikRegisterOperand *, bool); +static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *, GDalvikRegisterOperand *, bool, vmpa_t); @@ -335,6 +338,7 @@ static void g_dalvik_dcontext_init(GDalvikDContext *ctx)      parent = G_DEC_CONTEXT(ctx);      parent->dup = (dup_dec_context_fc)g_dalvik_dcontext_dup; +    parent->spread = (spread_reg_fc)g_dalvik_context_spread_allocated_shared_reg;      parent->convert_reg = (convert_register_fc)g_dalvik_dcontext_convert_register;  } @@ -443,9 +447,46 @@ static GDalvikDContext *g_dalvik_dcontext_dup(GDalvikDContext *orig)  /******************************************************************************  *                                                                             * +*  Paramètres  : parent = instance à éventuellement compléter.                * +*                child  = instance à venir consulter.                         * +*                                                                             * +*  Description : Propage un registre alloué et attendu par la suite.          * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_context_spread_allocated_shared_reg(GDalvikDContext *ctx, GDalvikRegister *reg, GDecInstruction *dinstr) +{ +    GDexFormat *format;                     /* Recherche de méthode        */ +    GBinRoutine *routine;                   /* Objet des recherches        */ +    GDexMethod *method;                     /* Méthode décompilée          */ +    uint16_t index;                         /* Identifiant du registre     */ +    DexVariableIndex info;                  /* Nature du registre          */ + +    format = G_DEX_FORMAT(G_DEC_CONTEXT(ctx)->format); +    routine = G_DEC_CONTEXT(ctx)->routine; + +    method = g_dex_format_find_method_by_address(format, g_binary_routine_get_address(routine)); + +    index = g_dalvik_register_get_index(reg); +    info = g_dex_method_get_variable(method, index); + +    g_object_ref(G_OBJECT(dinstr)); +    g_hash_table_insert(ctx->locals, GUINT_TO_POINTER(DVI_INDEX(info)), dinstr); +    ctx->locals_count++; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : ctx     = instance à consulter, voire mettre à jour.         *  *                operand = opérande représentant un registre quelconque.      *  *                assign  = précise le sort prochain du registre.              * +*                addr    = adresse de l'instruction décompilée.               *  *                                                                             *  *  Description : Convertit un registre machine en un pseudo-registre.         *  *                                                                             * @@ -455,7 +496,7 @@ static GDalvikDContext *g_dalvik_dcontext_dup(GDalvikDContext *orig)  *                                                                             *  ******************************************************************************/ -static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx, GDalvikRegisterOperand *operand, bool assign) +static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx, GDalvikRegisterOperand *operand, bool assign, vmpa_t addr)  {      GDecInstruction *result;                /* Instance à retourner        */      GDexFormat *format;                     /* Recherche de méthode        */ @@ -522,17 +563,37 @@ static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx,      {          found = g_hash_table_lookup(ctx->locals, GUINT_TO_POINTER(DVI_INDEX(info))); -        if (/*!assign && */found != NULL) +        if (!assign && found != NULL)          {              g_object_ref(G_OBJECT(found));              result = G_DEC_INSTRUCTION(found);          }          else          { -            result = g_pseudo_register_new(); -            g_pseudo_register_set_basename(G_PSEUDO_REGISTER(result), "var"); -            g_pseudo_register_set_index(G_PSEUDO_REGISTER(result), ctx->locals_count); +            /* +            if (!assign) +            { +                printf("bug"); +                exit(0); +            } +            */ + +            result = g_dec_context_get_awaited_alloc(G_DEC_CONTEXT(ctx), G_ARCH_REGISTER(reg), addr); + +            if (result == NULL) +            { +                result = g_pseudo_register_new(); +                g_pseudo_register_set_basename(G_PSEUDO_REGISTER(result), "var"); +                g_pseudo_register_set_index(G_PSEUDO_REGISTER(result), ctx->locals_count); + +                g_dec_context_notify_reg_alloc(G_DEC_CONTEXT(ctx), G_ARCH_REGISTER(reg), +                                               result, addr); + +            } +            else +                g_object_ref(G_OBJECT(result)); +            g_object_ref(G_OBJECT(result));              g_hash_table_insert(ctx->locals, GUINT_TO_POINTER(DVI_INDEX(info)), result);              ctx->locals_count++; diff --git a/src/arch/dalvik/decomp/aget.c b/src/arch/dalvik/decomp/aget.c index 0fa66eb..4ca012b 100644 --- a/src/arch/dalvik/decomp/aget.c +++ b/src/arch/dalvik/decomp/aget.c @@ -45,20 +45,23 @@  GDecInstruction *dalvik_decomp_instr_aget(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *array;                 /* Tableau accédé              */      GDecInstruction *index;                 /* Indice de cellule considérée*/      GDecInstruction *content;               /* Contenu de cellule visé     */      GDecInstruction *access;                /* Représentation de l'accès   */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    array = g_dec_context_convert_register(ctx, operand, false); +    array = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2); -    index = g_dec_context_convert_register(ctx, operand, false); +    index = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 0); -    content = g_dec_context_convert_register(ctx, operand, true); +    content = g_dec_context_convert_register(ctx, operand, true, addr);      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/decomp/aput.c b/src/arch/dalvik/decomp/aput.c index 41bd89f..8d648e4 100644 --- a/src/arch/dalvik/decomp/aput.c +++ b/src/arch/dalvik/decomp/aput.c @@ -45,20 +45,23 @@  GDecInstruction *dalvik_decomp_instr_aput(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *content;               /* Contenu de cellule visé     */      GDecInstruction *array;                 /* Tableau accédé              */      GDecInstruction *index;                 /* Indice de cellule considérée*/      GDecInstruction *access;                /* Représentation de l'accès   */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    content = g_dec_context_convert_register(ctx, operand, false); +    content = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 1); -    array = g_dec_context_convert_register(ctx, operand, false); +    array = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2); -    index = g_dec_context_convert_register(ctx, operand, false); +    index = g_dec_context_convert_register(ctx, operand, false, addr);      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/decomp/arithm.c b/src/arch/dalvik/decomp/arithm.c index a217adf..464694f 100644 --- a/src/arch/dalvik/decomp/arithm.c +++ b/src/arch/dalvik/decomp/arithm.c @@ -48,6 +48,7 @@ GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecC  {      GDecInstruction *result;                /* Instruction à retourner     */      ArithmOperationType type;               /* Type d'opération menée      */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *op1;                   /* Premier opérande utilisé    */      GDecInstruction *op2;                   /* Second opérande utilisé     */ @@ -85,14 +86,16 @@ GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecC              break;      } +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    op1 = g_dec_context_convert_register(ctx, operand, false); +    op1 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2); -    op2 = g_dec_context_convert_register(ctx, operand, false); +    op2 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2));      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); @@ -119,6 +122,7 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr,  {      GDecInstruction *result;                /* Instruction à retourner     */      ArithmOperationType type;               /* Type d'opération menée      */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *op1;                   /* Premier opérande utilisé    */      GDecInstruction *dest;                  /* Enregistrement du résultat  */ @@ -153,11 +157,13 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr,              break;      } +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    op1 = g_dec_context_convert_register(ctx, operand, false); +    op1 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      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)); @@ -184,6 +190,7 @@ GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, G  {      GDecInstruction *result;                /* Instruction à retourner     */      ArithmOperationType type;               /* Type d'opération menée      */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *op1;                   /* Premier opérande utilisé    */      GDecInstruction *op2;                   /* Second opérande utilisé     */ @@ -225,14 +232,16 @@ GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, G              break;      } +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    op1 = g_dec_context_convert_register(ctx, operand, false); +    op1 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2);      op2 = g_imm_expression_new(G_IMM_OPERAND(operand));      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2));      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); diff --git a/src/arch/dalvik/decomp/array.c b/src/arch/dalvik/decomp/array.c index 3422461..217cab3 100644 --- a/src/arch/dalvik/decomp/array.c +++ b/src/arch/dalvik/decomp/array.c @@ -45,17 +45,20 @@  GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *reg;                   /* Pseudo-registre redéfini    */      GDecInstruction *len;                   /* Enregistrement de taille    */      GDecInstruction *dest;                  /* Destination de la création  */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    reg = g_dec_context_convert_register(ctx, operand, false); +    reg = g_dec_context_convert_register(ctx, operand, false, addr);      len = g_dalvik_alength_new(G_DEC_EXPRESSION(reg));      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(len)); diff --git a/src/arch/dalvik/decomp/const.c b/src/arch/dalvik/decomp/const.c index 98133ac..a451b55 100644 --- a/src/arch/dalvik/decomp/const.c +++ b/src/arch/dalvik/decomp/const.c @@ -47,12 +47,15 @@  GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *reg;                   /* Pseudo-registre redéfini    */      GDecInstruction *imm;                   /* Valeur immédiate décompilée */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    reg = g_dec_context_convert_register(ctx, operand, true); +    reg = g_dec_context_convert_register(ctx, operand, true, addr);      operand = g_arch_instruction_get_operand(instr, 1);      imm = g_imm_expression_new(G_IMM_OPERAND(operand)); @@ -80,14 +83,17 @@ GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecCo  GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *reg;                   /* Pseudo-registre redéfini    */      uint32_t index;                         /* Indice de la chaîne         */      const char *value;                      /* Chaîne de caractères        */      GDecInstruction *str;                   /* Chaîne décompilée           */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    reg = g_dec_context_convert_register(ctx, operand, true); +    reg = g_dec_context_convert_register(ctx, operand, true, addr);      operand = g_arch_instruction_get_operand(instr, 1);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); diff --git a/src/arch/dalvik/decomp/if.c b/src/arch/dalvik/decomp/if.c index b274ead..6a156ec 100644 --- a/src/arch/dalvik/decomp/if.c +++ b/src/arch/dalvik/decomp/if.c @@ -47,6 +47,7 @@ GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecConte  {      GDecInstruction *result;                /* Instruction à retourner     */      CompSignType sign;                      /* Type d'opération menée      */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *op1;                   /* Premier opérande utilisé    */      GDecInstruction *op2;                   /* Second opérande utilisé     */ @@ -78,14 +79,16 @@ GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecConte              break;      } +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    op1 = g_dec_context_convert_register(ctx, operand, false); +    op1 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 1); -    op2 = g_dec_context_convert_register(ctx, operand, false); +    op2 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2); -    jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand);*/ +    jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand, addr);*/      cond = g_cond_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2));      result = g_ite_instruction_new(G_DEC_EXPRESSION(cond), jmp, jmp); @@ -113,6 +116,7 @@ GDecInstruction *dalvik_decomp_instr_if_zero(const GArchInstruction *instr, GDec  {      GDecInstruction *result;                /* Instruction à retourner     */      CompSignType sign;                      /* Type d'opération menée      */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *op1;                   /* Premier opérande utilisé    */      GDecInstruction *op2;                   /* Second opérande utilisé     */ @@ -144,14 +148,16 @@ GDecInstruction *dalvik_decomp_instr_if_zero(const GArchInstruction *instr, GDec              break;      } +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    op1 = g_dec_context_convert_register(ctx, operand, false); +    op1 = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, (unsigned int)0);      op2 = g_imm_expression_new(operand);      operand = g_arch_instruction_get_operand(instr, 2); -    jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand);*/ +    jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand, addr);*/      cond = g_cond_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2));      result = g_ite_instruction_new(G_DEC_EXPRESSION(cond), jmp, jmp); diff --git a/src/arch/dalvik/decomp/iget.c b/src/arch/dalvik/decomp/iget.c index 5d1cf65..9cf603d 100644 --- a/src/arch/dalvik/decomp/iget.c +++ b/src/arch/dalvik/decomp/iget.c @@ -47,6 +47,7 @@  GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *src;                   /* Registre de l'object        */      uint32_t index;                         /* Indice dans la table        */ @@ -55,8 +56,10 @@ GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecCon      GDecInstruction *dest;                  /* Registre de destination     */      GDecInstruction *access;                /* Représentation de l'accès   */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    src = g_dec_context_convert_register(ctx, operand, false); +    src = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); @@ -66,7 +69,7 @@ GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecCon      g_pseudo_register_set_variable(G_PSEUDO_REGISTER(field), var);      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      access = g_access_expression_new(G_DEC_EXPRESSION(src), G_DEC_EXPRESSION(field));      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(access)); diff --git a/src/arch/dalvik/decomp/invoke.c b/src/arch/dalvik/decomp/invoke.c index 7337ccc..4b2f20f 100644 --- a/src/arch/dalvik/decomp/invoke.c +++ b/src/arch/dalvik/decomp/invoke.c @@ -62,6 +62,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *instr      const char *name;                       /* Chaîne à afficher           */      GDecInstruction *src;                   /* Source de l'assignation     */      GDecInstruction *dest;                  /* Destination de l'assignat°  */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      size_t i;                               /* Boucle de parcours #2       */      GArchOperand *arg;                      /* Argument brut de l'appel    */      GDecInstruction *reg;                   /* Argument converti           */ @@ -123,10 +124,12 @@ GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *instr      operand = g_arch_instruction_get_operand(instr, 0);      count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand)); +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      for (i = 1; i < count; i++)      {          arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), i); -        reg = g_dec_context_convert_register(ctx, arg, false); +        reg = g_dec_context_convert_register(ctx, arg, false, addr);          g_routine_call_add_arg(G_ROUTINE_CALL(result), reg); @@ -158,6 +161,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_static(const GArchInstruction *instr      uint32_t index;                         /* Indice de l'élément visé    */      GBinRoutine *routine;                   /* Routine visée par l'appel   */      GDecInstruction *call;                  /* Représentation de l'appel   */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      size_t i;                               /* Boucle de parcours #2       */      GArchOperand *arg;                      /* Argument brut de l'appel    */      GDecInstruction *reg;                   /* Argument converti           */ @@ -181,10 +185,12 @@ GDecInstruction *dalvik_decomp_instr_invoke_static(const GArchInstruction *instr      operand = g_arch_instruction_get_operand(instr, 0);      count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand)); +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      for (i = 0; i < count; i++)      {          arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), i); -        reg = g_dec_context_convert_register(ctx, arg, false); +        reg = g_dec_context_convert_register(ctx, arg, false, addr);          g_routine_call_add_arg(G_ROUTINE_CALL(call), reg); @@ -216,6 +222,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst      uint32_t index;                         /* Indice de l'élément visé    */      GBinRoutine *routine;                   /* Routine visée par l'appel   */      GDecInstruction *call;                  /* Représentation de l'appel   */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      size_t i;                               /* Boucle de parcours #2       */      GArchOperand *arg;                      /* Argument brut de l'appel    */      GDecInstruction *reg;                   /* Argument converti           */ @@ -239,10 +246,12 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst      operand = g_arch_instruction_get_operand(instr, 0);      count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand)); +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      for (i = 1; i < count; i++)      {          arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), i); -        reg = g_dec_context_convert_register(ctx, arg, false); +        reg = g_dec_context_convert_register(ctx, arg, false, addr);          g_routine_call_add_arg(G_ROUTINE_CALL(call), reg); @@ -251,7 +260,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst      /* Appel depuis le propriétaire */      arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), 0); -    reg = g_dec_context_convert_register(ctx, arg, false); +    reg = g_dec_context_convert_register(ctx, arg, false, addr);      result = g_access_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(call)); diff --git a/src/arch/dalvik/decomp/iput.c b/src/arch/dalvik/decomp/iput.c index fedb00e..ed0830c 100644 --- a/src/arch/dalvik/decomp/iput.c +++ b/src/arch/dalvik/decomp/iput.c @@ -47,6 +47,7 @@  GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *dest;                  /* Registre de destination     */      GDecInstruction *src;                   /* Registre de l'object        */ @@ -55,11 +56,13 @@ GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *instr, GDecCon      GBinVariable *var;                      /* Variable / champ accédé     */      GDecInstruction *access;                /* Représentation de l'accès   */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    src = g_dec_context_convert_register(ctx, operand, false); +    src = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 1); -    dest = g_dec_context_convert_register(ctx, operand, false); +    dest = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 2);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); diff --git a/src/arch/dalvik/decomp/move.c b/src/arch/dalvik/decomp/move.c index 9165447..a502952 100644 --- a/src/arch/dalvik/decomp/move.c +++ b/src/arch/dalvik/decomp/move.c @@ -44,15 +44,18 @@  GDecInstruction *dalvik_decomp_instr_move(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *src;                   /* Registre de l'object        */      GDecInstruction *dest;                  /* Registre de destination     */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    src = g_dec_context_convert_register(ctx, operand, false); +    src = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(src)); @@ -77,15 +80,18 @@ GDecInstruction *dalvik_decomp_instr_move(const GArchInstruction *instr, GDecCon  GDecInstruction *dalvik_decomp_instr_move_object(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *src;                   /* Registre de l'object        */      GDecInstruction *dest;                  /* Registre de destination     */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1); -    src = g_dec_context_convert_register(ctx, operand, false); +    src = g_dec_context_convert_register(ctx, operand, false, addr);      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(src)); @@ -111,6 +117,7 @@ GDecInstruction *dalvik_decomp_instr_move_result(const GArchInstruction *instr,  {      GDecInstruction *result;                /* Instruction à retourner     */      GDecInstruction *list;                  /* Instructions décompilées    */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *last;                  /* Instruction précédante      */      GDecInstruction *dest;                  /* Registre de destination     */ @@ -122,8 +129,10 @@ GDecInstruction *dalvik_decomp_instr_move_result(const GArchInstruction *instr,      g_dec_instruction_delete(&list, last);      g_dec_context_set_decomp_instrs(ctx, list); +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(last)); diff --git a/src/arch/dalvik/decomp/new.c b/src/arch/dalvik/decomp/new.c index 75dc259..e30feb2 100644 --- a/src/arch/dalvik/decomp/new.c +++ b/src/arch/dalvik/decomp/new.c @@ -46,6 +46,7 @@  GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      uint32_t index;                         /* Indice dans la table        */      GDataType *type;                        /* Type concerné par l'opérat° */ @@ -53,6 +54,8 @@ GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr,      GDecInstruction *call;                  /* Appel au constructeur       */      GDecInstruction *dest;                  /* Registre de destination     */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 1);      index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));      type = get_type_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); @@ -61,7 +64,7 @@ GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr,      call = g_routine_call_new(constructor);      operand = g_arch_instruction_get_operand(instr, 0); -    dest = g_dec_context_convert_register(ctx, operand, true); +    dest = g_dec_context_convert_register(ctx, operand, true, addr);      result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(call)); diff --git a/src/arch/dalvik/decomp/ret.c b/src/arch/dalvik/decomp/ret.c index b7c5414..47179f3 100644 --- a/src/arch/dalvik/decomp/ret.c +++ b/src/arch/dalvik/decomp/ret.c @@ -44,11 +44,14 @@  GDecInstruction *dalvik_decomp_instr_return(const GArchInstruction *instr, GDecContext *ctx)  {      GDecInstruction *result;                /* Instruction à retourner     */ +    vmpa_t addr;                            /* Adresse de l'instruction    */      GArchOperand *operand;                  /* Opérande de l'instruction   */      GDecInstruction *reg;                   /* Pseudo-registre redéfini    */ +    g_arch_instruction_get_location(instr, NULL, NULL, &addr); +      operand = g_arch_instruction_get_operand(instr, 0); -    reg = g_dec_context_convert_register(ctx, operand, false); +    reg = g_dec_context_convert_register(ctx, operand, false, addr);      result = g_return_expression_new(G_DEC_EXPRESSION(reg)); diff --git a/src/arch/dalvik/register.c b/src/arch/dalvik/register.c index db4186a..4e91cd4 100644 --- a/src/arch/dalvik/register.c +++ b/src/arch/dalvik/register.c @@ -58,6 +58,9 @@ static void g_dalvik_register_class_init(GDalvikRegisterClass *);  /* Initialise une instance de registre Dalvik. */  static void g_dalvik_register_init(GDalvikRegister *); +/* Produit une empreinte à partir d'un registre. */ +static guint g_dalvik_register_hash(const GDalvikRegister *); +  /* Indique le type défini pour une représentation d'un registre Dalvik. */ @@ -100,6 +103,7 @@ static void g_dalvik_register_init(GDalvikRegister *reg)      base = G_ARCH_REGISTER(reg); +    base->hash = (reg_hash_fc)g_dalvik_register_hash;      base->compare = (reg_compare_fc)g_dalvik_register_compare;      base->print = (reg_print_fc)g_dalvik_register_print; @@ -152,6 +156,25 @@ uint16_t g_dalvik_register_get_index(const GDalvikRegister *reg)  /******************************************************************************  *                                                                             * +*  Paramètres  : reg = opérande à consulter pour le calcul.                   * +*                                                                             * +*  Description : Produit une empreinte à partir d'un registre.                * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static guint g_dalvik_register_hash(const GDalvikRegister *reg) +{ +    return reg->index; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             *  | 
