summaryrefslogtreecommitdiff
path: root/src/arch/raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/raw.c')
-rw-r--r--src/arch/raw.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/arch/raw.c b/src/arch/raw.c
index b84d9f7..da9ee88 100644
--- a/src/arch/raw.c
+++ b/src/arch/raw.c
@@ -267,17 +267,32 @@ GArchInstruction *g_raw_instruction_new_uleb128(const GBinContent *content, vmpa
GArchInstruction *result; /* Instruction à retourner */
vmpa2t start; /* Départ original de lecture */
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 */
+ mrange_t range; /* Couverture de l'instruction */
copy_vmpa(&start, addr);
if (!g_binary_content_read_uleb128(content, addr, &value))
goto grinu_error;
- leb_size = MDS_FROM_BYTES(compute_vmpa_diff(&start, addr));
+ diff = compute_vmpa_diff(&start, addr);
+
+ leb_size = MDS_FROM_BYTES(diff);
assert(leb_size != MDS_UNDEFINED);
- result = g_raw_instruction_new_from_value(&start, leb_size, (uint64_t)value);
+ result = g_object_new(G_TYPE_RAW_INSTRUCTION, NULL);
+
+ 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;
+
+ g_imm_operand_pad(&operand, true, NULL);
+
+ g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand));
return result;
@@ -305,22 +320,37 @@ GArchInstruction *g_raw_instruction_new_sleb128(const GBinContent *content, vmpa
{
GArchInstruction *result; /* Instruction à retourner */
vmpa2t start; /* Départ original de lecture */
- leb128_t value; /* Valeur sleb128 à représenter*/
+ 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 */
+ mrange_t range; /* Couverture de l'instruction */
copy_vmpa(&start, addr);
- if (!g_binary_content_read_leb128(content, addr, &value))
- goto grinu_error;
+ if (!g_binary_content_read_uleb128(content, addr, &value))
+ goto grins_error;
- leb_size = MDS_FROM_BYTES(compute_vmpa_diff(&start, addr));
- assert(leb_size != MDS_UNDEFINED);
+ diff = compute_vmpa_diff(&start, addr);
+
+ leb_size = MDS_FROM_BYTES(diff) | MDS_SIGN;
+ assert(leb_size != MDS_SIGN);
- result = g_raw_instruction_new_from_value(&start, leb_size, (uint64_t)value);
+ result = g_object_new(G_TYPE_RAW_INSTRUCTION, NULL);
+
+ 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;
+
+ g_imm_operand_pad(&operand, true, NULL);
+
+ g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand));
return result;
- grinu_error:
+ grins_error:
return NULL;