diff options
Diffstat (limited to 'src/arch/operands/immediate.c')
-rw-r--r-- | src/arch/operands/immediate.c | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/src/arch/operands/immediate.c b/src/arch/operands/immediate.c index 00bfe99..0df8bbb 100644 --- a/src/arch/operands/immediate.c +++ b/src/arch/operands/immediate.c @@ -88,11 +88,11 @@ static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinar /* Fournit l'empreinte d'un candidat à une centralisation. */ static guint g_imm_operand_hash(const GImmOperand *, bool); -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_imm_operand_unserialize(GImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_imm_operand_load(GImmOperand *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_imm_operand_serialize(const GImmOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_imm_operand_store(GImmOperand *, GObjectStorage *, packed_buffer_t *); @@ -152,8 +152,8 @@ static void g_imm_operand_class_init(GImmOperandClass *klass) operand->hash = (operand_hash_fc)g_imm_operand_hash; - operand->unserialize = (unserialize_operand_fc)g_imm_operand_unserialize; - operand->serialize = (serialize_operand_fc)g_imm_operand_serialize; + operand->load = (load_operand_fc)g_imm_operand_load; + operand->store = (store_operand_fc)g_imm_operand_store; } @@ -1354,12 +1354,11 @@ static guint g_imm_operand_hash(const GImmOperand *operand, bool lock) /****************************************************************************** * * -* Paramètres : operand = opérande d'assemblage à constituer. * -* storage = mécanisme de sauvegarde à manipuler. * -* format = format binaire chargé associé à l'architecture. * -* pbuf = zone tampon à remplir. * +* Paramètres : operand = élément GLib à constuire. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à lire. * * * -* Description : Charge un opérande depuis une mémoire tampon. * +* Description : Charge un contenu depuis une mémoire tampon. * * * * Retour : Bilan de l'opération. * * * @@ -1367,19 +1366,17 @@ static guint g_imm_operand_hash(const GImmOperand *operand, bool lock) * * ******************************************************************************/ -static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_imm_operand_load(GImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ immop_extra_data_t *extra; /* Données insérées à modifier */ + uleb128_t value; /* Valeur ULEB128 à charger */ uint8_t val; /* Champ de bits manipulé */ parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class); - result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); - - if (result) - result = extract_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true); + result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf); if (result) { @@ -1387,24 +1384,36 @@ static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage LOCK_GOBJECT_EXTRA(extra); - result = extract_packed_buffer(pbuf, &extra->size, sizeof(MemoryDataSize), true); + result = unpack_uleb128(&value, pbuf); + + if (result) + extra->size = value; if (result) { result = extract_packed_buffer(pbuf, &val, sizeof(uint8_t), false); - extra->def_display = val; + + if (result) + extra->def_display = val; + } if (result) { result = extract_packed_buffer(pbuf, &val, sizeof(uint8_t), false); - extra->display = val; + + if (result) + extra->display = val; + } UNLOCK_GOBJECT_EXTRA(extra); } + if (result) + result = extract_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true); + return result; } @@ -1412,11 +1421,11 @@ static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage /****************************************************************************** * * -* Paramètres : operand = opérande d'assemblage à consulter. * -* storage = mécanisme de sauvegarde à manipuler. * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * * pbuf = zone tampon à remplir. * * * -* Description : Sauvegarde un opérande dans une mémoire tampon. * +* Description : Sauvegarde un contenu dans une mémoire tampon. * * * * Retour : Bilan de l'opération. * * * @@ -1424,7 +1433,7 @@ static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage * * ******************************************************************************/ -static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_imm_operand_store(GImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ @@ -1432,10 +1441,7 @@ static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *sto parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class); - result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); - - if (result) - result = extend_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true); + result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf); if (result) { @@ -1443,7 +1449,7 @@ static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *sto LOCK_GOBJECT_EXTRA(extra); - result = extend_packed_buffer(pbuf, &extra->size, sizeof(MemoryDataSize), true); + result = pack_uleb128((uleb128_t []){ extra->size }, pbuf); if (result) result = extend_packed_buffer(pbuf, (uint8_t []) { extra->def_display }, sizeof(uint8_t), false); @@ -1455,6 +1461,9 @@ static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *sto } + if (result) + result = extend_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true); + return result; } |