diff options
Diffstat (limited to 'src/arch/instructions/raw.c')
-rw-r--r-- | src/arch/instructions/raw.c | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/src/arch/instructions/raw.c b/src/arch/instructions/raw.c index 481dd1c..6340e46 100644 --- a/src/arch/instructions/raw.c +++ b/src/arch/instructions/raw.c @@ -213,17 +213,17 @@ static void g_raw_instruction_finalize(GRawInstruction *instr) GArchInstruction *g_raw_instruction_new_from_value(const vmpa2t *addr, MemoryDataSize size, uint64_t value) { GArchInstruction *result; /* Instruction à retourner */ - GImmOperand *operand; /* Octet non décodé à afficher */ + GArchOperand *operand; /* Octet non décodé à afficher */ mrange_t range; /* Couverture de l'instruction */ result = g_object_new(G_TYPE_RAW_INSTRUCTION, NULL); - operand = G_IMM_OPERAND(g_imm_operand_new_from_value(size, value)); - if (operand == NULL) goto grinfv_error; + operand = g_imm_operand_new_from_value(size, value); + if (operand == NULL) goto error; - g_imm_operand_pad(operand, true); + g_arch_operand_set_flag(operand, IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING); - g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); + g_arch_instruction_attach_extra_operand(result, operand); switch (size) { @@ -249,7 +249,7 @@ GArchInstruction *g_raw_instruction_new_from_value(const vmpa2t *addr, MemoryDat default: assert(false); - goto grinfv_error; + goto error; break; } @@ -258,7 +258,7 @@ GArchInstruction *g_raw_instruction_new_from_value(const vmpa2t *addr, MemoryDat return result; - grinfv_error: + error: g_object_unref(G_OBJECT(result)); @@ -287,13 +287,15 @@ GArchInstruction *g_raw_instruction_new_uleb128(const GBinContent *content, vmpa uleb128_t value; /* Valeur uleb128 à représenter*/ phys_t diff; /* Couverture de la lecture */ MemoryDataSize leb_size; /* Taille de la valeur */ - GImmOperand *operand; /* Octet non décodé à afficher */ + GArchOperand *operand; /* Octet non décodé à afficher */ mrange_t range; /* Couverture de l'instruction */ + result = NULL; + copy_vmpa(&start, addr); if (!g_binary_content_read_uleb128(content, addr, &value)) - goto grinu_error; + goto error; diff = compute_vmpa_diff(&start, addr); @@ -305,16 +307,18 @@ GArchInstruction *g_raw_instruction_new_uleb128(const GBinContent *content, vmpa init_mrange(&range, &start, diff); g_arch_instruction_set_range(result, &range); - operand = G_IMM_OPERAND(g_imm_operand_new_from_value(leb_size, (uint64_t)value)); - if (operand == NULL) goto grinu_error; + operand = g_imm_operand_new_from_value(leb_size, (uint64_t)value); + if (operand == NULL) goto error; - g_imm_operand_pad(operand, true); + g_arch_operand_set_flag(operand, IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING); - g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); + g_arch_instruction_attach_extra_operand(result, operand); return result; - grinu_error: + error: + + g_clear_object(&result); return NULL; @@ -341,13 +345,15 @@ GArchInstruction *g_raw_instruction_new_sleb128(const GBinContent *content, vmpa uleb128_t value; /* Valeur uleb128 à représenter*/ phys_t diff; /* Couverture de la lecture */ MemoryDataSize leb_size; /* Taille de la valeur */ - GImmOperand *operand; /* Octet non décodé à afficher */ + GArchOperand *operand; /* Octet non décodé à afficher */ mrange_t range; /* Couverture de l'instruction */ + result = NULL; + copy_vmpa(&start, addr); if (!g_binary_content_read_uleb128(content, addr, &value)) - goto grins_error; + goto error; diff = compute_vmpa_diff(&start, addr); @@ -359,16 +365,18 @@ GArchInstruction *g_raw_instruction_new_sleb128(const GBinContent *content, vmpa init_mrange(&range, &start, diff); g_arch_instruction_set_range(result, &range); - operand = G_IMM_OPERAND(g_imm_operand_new_from_value(leb_size, (uint64_t)value)); - if (operand == NULL) goto grins_error; + operand = g_imm_operand_new_from_value(leb_size, (uint64_t)value); + if (operand == NULL) goto error; - g_imm_operand_pad(operand, true); + g_arch_operand_set_flag(operand, IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING); - g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); + g_arch_instruction_attach_extra_operand(result, operand); return result; - grins_error: + error: + + g_clear_object(&result); return NULL; @@ -396,7 +404,7 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory GArchInstruction *result; /* Instruction à retourner */ vmpa2t old; /* Sauvegarde de la position */ size_t i; /* Boucle de parcours */ - GImmOperand *operand; /* Octet non décodé à afficher */ + GArchOperand *operand; /* Octet non décodé à afficher */ mrange_t range; /* Couverture de l'instruction */ /* Par soucis de cohérence */ @@ -408,12 +416,12 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory for (i = 0; i < count; i++) { - operand = G_IMM_OPERAND(g_imm_operand_new_from_data(size, content, addr, endian)); - if (operand == NULL) goto grina_error; + operand = g_imm_operand_new_from_data(size, content, addr, endian); + if (operand == NULL) goto error; - g_imm_operand_pad(operand, true); + g_arch_operand_set_flag(operand, IOF_ZERO_PADDING_BY_DEFAULT | IOF_ZERO_PADDING); - g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); + g_arch_instruction_attach_extra_operand(result, operand); } @@ -423,7 +431,7 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory return result; - grina_error: + error: g_object_unref(G_OBJECT(result)); |