diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-05-28 17:37:46 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-05-28 17:37:46 (GMT) |
commit | 9f5ed46de568d3db882c939c8ca9d0117bff3369 (patch) | |
tree | 9d2090cd640e54379dc1b982e03dc284b2d23ae7 /plugins/arm/v7/operands/reglist.c | |
parent | 2fd186a84cba4f39f6f1bb8bd34d52b4e1d4f814 (diff) |
Relied on register objects as often as possible.
Diffstat (limited to 'plugins/arm/v7/operands/reglist.c')
-rw-r--r-- | plugins/arm/v7/operands/reglist.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/plugins/arm/v7/operands/reglist.c b/plugins/arm/v7/operands/reglist.c index 33a3fcd..0f87424 100644 --- a/plugins/arm/v7/operands/reglist.c +++ b/plugins/arm/v7/operands/reglist.c @@ -30,10 +30,11 @@ #include <arch/operand-int.h> #include <arch/register.h> +#include <arch/storage.h> #include <common/sort.h> -#include "../../register.h" +#include "../registers/basic.h" @@ -288,7 +289,7 @@ GArchOperand *g_armv7_reglist_operand_new(uint16_t selected) { GArmV7RegListOperand *result; /* Structure à retourner */ uint8_t i; /* Boucle de parcours */ - GArmV7Register *reg; /* Nouveau registre à intégrer */ + GArchRegister *reg; /* Nouveau registre à intégrer */ result = g_object_new(G_TYPE_ARMV7_REGLIST_OPERAND, NULL); @@ -296,8 +297,8 @@ GArchOperand *g_armv7_reglist_operand_new(uint16_t selected) { if ((selected & (1 << i)) == 0) continue; - reg = g_armv7_register_new(i); - g_armv7_reglist_add_register(result, reg); + reg = g_armv7_basic_register_new(i); + g_armv7_reglist_add_register(result, G_ARMV7_REGISTER(reg)); } @@ -403,9 +404,10 @@ static bool g_armv7_reglist_operand_unserialize(GArmV7RegListOperand *operand, G bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ size_t count; /* Quantité de registres */ + packed_buffer reg_pbuf; /* Tampon des données à écrire */ size_t i; /* Boucle de parcours */ - uint8_t index; /* Identifiant de registre */ - GArmV7Register *reg; /* Nouveau registre à intégrer */ + off64_t pos; /* Position dans le flux */ + GArchRegister *reg; /* Registre restauré */ parent = G_ARCH_OPERAND_CLASS(g_armv7_reglist_operand_parent_class); @@ -414,16 +416,30 @@ static bool g_armv7_reglist_operand_unserialize(GArmV7RegListOperand *operand, G if (result) result = extract_packed_buffer(pbuf, &count, sizeof(size_t), true); - for (i = 0; i < count && result; i++) + if (result) { - result = extract_packed_buffer(pbuf, &index, sizeof(uint8_t), false); + init_packed_buffer(®_pbuf); - if (result) + for (i = 0; i < count && result; i++) { - reg = g_armv7_register_new(index); - g_armv7_reglist_add_register(operand, reg); + result = extract_packed_buffer(pbuf, &pos, sizeof(off64_t), true); + + if (result) + result = g_asm_storage_load_register_data(storage, ®_pbuf, pos); + + if (result) + { + reg = g_arch_register_load(storage, ®_pbuf); + result = (reg != NULL); + } + + if (result) + g_armv7_reglist_add_register(operand, G_ARMV7_REGISTER(reg)); + } + exit_packed_buffer(®_pbuf); + } return result; @@ -450,7 +466,8 @@ static bool g_armv7_reglist_operand_serialize(const GArmV7RegListOperand *operan bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ size_t i; /* Boucle de parcours */ - uint8_t index; /* Identifiant de registre */ + off64_t pos; /* Position dans le flux */ + packed_buffer reg_pbuf; /* Tampon des données à écrire */ parent = G_ARCH_OPERAND_CLASS(g_armv7_reglist_operand_parent_class); @@ -459,11 +476,23 @@ static bool g_armv7_reglist_operand_serialize(const GArmV7RegListOperand *operan if (result) result = extend_packed_buffer(pbuf, &operand->count, sizeof(size_t), true); - for (i = 0; i < operand->count && result; i++) + if (result) { - index = g_arm_register_get_index(G_ARM_REGISTER(operand->registers[i])); + init_packed_buffer(®_pbuf); + + for (i = 0; i < operand->count && result; i++) + { + result = g_arch_register_store(G_ARCH_REGISTER(operand->registers[i]), storage, ®_pbuf); + + if (result) + result = g_asm_storage_store_register_data(storage, ®_pbuf, &pos); + + if (result) + result = extend_packed_buffer(pbuf, &pos, sizeof(off64_t), true); + + } - result = extend_packed_buffer(pbuf, &index, sizeof(uint8_t), false); + exit_packed_buffer(®_pbuf); } |