diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/analysis/storage/storage.h | 8 | ||||
| -rw-r--r-- | src/arch/instruction.c | 374 | ||||
| -rw-r--r-- | src/arch/instruction.h | 15 | ||||
| -rw-r--r-- | src/arch/operand-int.h | 13 | ||||
| -rw-r--r-- | src/arch/operand.c | 138 | ||||
| -rw-r--r-- | src/arch/operand.h | 7 | ||||
| -rw-r--r-- | src/arch/operands/feeder-int.h | 14 | ||||
| -rw-r--r-- | src/arch/operands/feeder.c | 76 | ||||
| -rw-r--r-- | src/arch/operands/feeder.h | 9 | ||||
| -rw-r--r-- | src/arch/operands/immediate.c | 65 | ||||
| -rw-r--r-- | src/arch/operands/known.c | 73 | ||||
| -rw-r--r-- | src/arch/operands/proxy.c | 126 | ||||
| -rw-r--r-- | src/arch/operands/register.c | 158 | ||||
| -rw-r--r-- | src/arch/operands/target.c | 57 | ||||
| -rw-r--r-- | src/arch/register-int.h | 2 | ||||
| -rw-r--r-- | src/arch/register.c | 1 | ||||
| -rw-r--r-- | src/arch/storage.c | 4 | ||||
| -rw-r--r-- | src/format/strsym.c | 4 | ||||
| -rw-r--r-- | src/format/symbol-int.h | 10 | ||||
| -rw-r--r-- | src/format/symbol.c | 158 | 
20 files changed, 539 insertions, 773 deletions
diff --git a/src/analysis/storage/storage.h b/src/analysis/storage/storage.h index 43860af..0d35d78 100644 --- a/src/analysis/storage/storage.h +++ b/src/analysis/storage/storage.h @@ -55,6 +55,14 @@ GType g_object_storage_get_type(void);  /* Crée le support d'une conservation d'objets en place. */  GObjectStorage *g_object_storage_new(const char *); +#define get_storage_linked_format(s)                            \ +    ({                                                          \ +        void*__result;                                          \ +        __result = g_object_get_data(G_OBJECT(s), "format");    \ +        g_object_ref(G_OBJECT(__result));                       \ +        __result;                                               \ +    }) +  /* Charge le support d'une conservation d'objets en place. */  GObjectStorage *g_object_storage_load(packed_buffer_t *); diff --git a/src/arch/instruction.c b/src/arch/instruction.c index c4354d4..4de16d6 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -75,17 +75,6 @@ bool g_arch_instruction_store_destinations(GArchInstruction *, GObjectStorage *, -/* -------------------- CONSERVATION SUR DISQUE DES INSTRUCTIONS -------------------- */ - - -/* Charge une instruction depuis une mémoire tampon. */ -static bool g_arch_instruction_unserialize(GArchInstruction *, GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde une instruction dans une mémoire tampon. */ -static bool g_arch_instruction_serialize(GArchInstruction *, GAsmStorage *, packed_buffer_t *); - - -  /* ------------------------ OFFRE DE CAPACITES DE GENERATION ------------------------ */ @@ -155,9 +144,6 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass)      instr = G_ARCH_INSTRUCTION_CLASS(klass); -    instr->unserialize = (unserialize_instruction_fc)g_arch_instruction_unserialize; -    instr->serialize = (serialize_instruction_fc)g_arch_instruction_serialize; -      instr->print = (print_instruction_fc)_g_arch_instruction_print;      instr->load = (load_instruction_fc)_g_arch_instruction_load; @@ -1826,347 +1812,6 @@ const char *g_arch_instruction_get_description(const GArchInstruction *instr)  /* ---------------------------------------------------------------------------------- */ -/*                      CONSERVATION SUR DISQUE DES INSTRUCTIONS                      */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instr   = instruction d'assemblage à consulter.              * -*                storage = mécanisme de sauvegarde à manipuler.               * -*                format  = format binaire chargé associé à l'architecture.    * -*                pbuf    = zone tampon à remplir.                             * -*                                                                             * -*  Description : Charge une instruction depuis une mémoire tampon.            * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_arch_instruction_unserialize(GArchInstruction *instr, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) -{ -    bool result;                            /* Bilan à retourner           */ -    packed_buffer_t op_pbuf;                /* Tampon des données à écrire */ -    size_t count;                           /* Nombre d'éléments à traiter */ -    size_t i;                               /* Boucle de parcours          */ -    off64_t pos;                            /* Position dans le flux       */ -    GArchOperand *op;                       /* Opérande à traiter          */ -    instr_link_t link;                      /* Lien vers une instruction   */ -    packed_buffer_t ins_pbuf;               /* Tampon des données à écrire */ -    instr_extra_data_t *extra;              /* Données insérées à consulter*/ - -    result = unpack_mrange(&instr->range, pbuf); - -    if (result) -    { -        init_packed_buffer(&op_pbuf); - -        result = extract_packed_buffer(pbuf, &count, sizeof(size_t), true); - -        for (i = 0; i < count && result; i++) -        { -            result = extract_packed_buffer(pbuf, &pos, sizeof(off64_t), true); - -            if (result) -                result = g_asm_storage_load_operand_data(storage, &op_pbuf, pos); - -            if (result) -            { -                op = g_arch_operand_load(storage, format, &op_pbuf); -                result = (op != NULL); -            } - -            if (result) -                g_arch_instruction_attach_extra_operand(instr, op); - -        } - -        exit_packed_buffer(&op_pbuf); - -    } - -    bool unserialize_link(instr_link_t *lk) -    { -        bool status;                        /* Bilan d'une conservation    */ -        phys_t lk_phys;                     /* Position physique courante  */ - -        status = extract_packed_buffer(pbuf, &lk_phys, sizeof(phys_t), true); - -        if (status) -        { -            lk->linked = g_asm_storage_get_instruction_at(storage, format, lk_phys, &ins_pbuf); -            status = (lk->linked != NULL); -        } - -        if (status) -        { -            status = extract_packed_buffer(pbuf, &lk->type, sizeof(InstructionLinkType), true); - -            if (!status) -                g_object_unref(G_OBJECT(lk->linked)); - -        } - -        return status; - -    } - -    if (result) -    { -        init_packed_buffer(&ins_pbuf); - -        result = extract_packed_buffer(pbuf, &count, sizeof(size_t), true); - -        for (i = 0; i < count && result; i++) -        { -            result = unserialize_link(&link); - -            if (result) -            { -                g_arch_instruction_link_with(instr, link.linked, link.type); -                g_object_unref(G_OBJECT(link.linked)); -            } - -        } - -        exit_packed_buffer(&ins_pbuf); - -    } - -    if (result) -    { -        extra = GET_ARCH_INSTR_EXTRA(instr); - -        LOCK_GOBJECT_EXTRA(extra); - -        result = extract_packed_buffer(pbuf, &extra->uid, sizeof(itid_t), true); - -        if (result) -            result = extract_packed_buffer(pbuf, &extra->flags, sizeof(ArchInstrFlag), true); - -        UNLOCK_GOBJECT_EXTRA(extra); - -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : storage = mécanisme de sauvegarde à manipuler.               * -*                format  = format binaire chargé associé à l'architecture.    * -*                pbuf    = zone tampon à remplir.                             * -*                                                                             * -*  Description : Charge une instruction depuis une mémoire tampon.            * -*                                                                             * -*  Retour      : Instruction d'assemblage constitué ou NULL en cas d'échec.   * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GArchInstruction *g_arch_instruction_load__old(GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) -{ -    GArchInstruction *result;               /* Instance à retourner        */ -    bool status;                            /* Bilan du chargement         */ - -    result = G_ARCH_INSTRUCTION(g_asm_storage_create_object(storage, pbuf)); - -    if (result != NULL) -    { -        status = G_ARCH_INSTRUCTION_GET_CLASS(result)->unserialize(result, storage, format, pbuf); - -        if (!status) -        { -            g_object_unref(G_OBJECT(result)); -            result = NULL; -        } - -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instr   = instruction d'assemblage à consulter.              * -*                storage = mécanisme de sauvegarde à manipuler.               * -*                pbuf    = zone tampon à remplir.                             * -*                                                                             * -*  Description : Sauvegarde une instruction dans une mémoire tampon.          * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_arch_instruction_serialize(GArchInstruction *instr, GAsmStorage *storage, packed_buffer_t *pbuf) -{ -    bool result;                            /* Bilan à retourner           */ -    packed_buffer_t op_pbuf;                /* Tampon des données à écrire */ -    size_t count;                           /* Nombre d'éléments à traiter */ -    size_t i;                               /* Boucle de parcours          */ -    GArchOperand *op;                       /* Opérande à traiter          */ -    off64_t pos;                            /* Position dans le flux       */ -    size_t kept;                            /* Nombre de liens conservés   */ -    const instr_link_t *link;               /* Lien vers une instruction   */ -    instr_extra_data_t *extra;              /* Données insérées à consulter*/ - -    result = pack_mrange(&instr->range, pbuf); - -    if (result) -    { -        init_packed_buffer(&op_pbuf); - -        g_arch_instruction_lock_operands(instr); - -        count = _g_arch_instruction_count_operands(instr); - -        result = extend_packed_buffer(pbuf, &count, sizeof(size_t), true); - -        for (i = 0; i < count && result; i++) -        { -            op = _g_arch_instruction_get_operand(instr, i); - -            result = g_arch_operand_store(op, storage, &op_pbuf); - -            if (result) -                result = g_asm_storage_store_operand_data(storage, &op_pbuf, &pos); - -            if (result) -                result = extend_packed_buffer(pbuf, &pos, sizeof(off64_t), true); - -            g_object_unref(G_OBJECT(op)); - -        } - -        g_arch_instruction_unlock_operands(instr); - -        exit_packed_buffer(&op_pbuf); - -    } - -    bool serialize_link(const instr_link_t *lk) -    { -        bool status;                        /* Bilan d'une conservation    */ -        const mrange_t *range;              /* Emplacement d'une instruct° */ -        phys_t lk_phys;                     /* Position physique courante  */ - -        if (lk->type == ILT_REF) -            status = true; - -        else -        { -            range = g_arch_instruction_get_range(lk->linked); - -            lk_phys = get_phy_addr(get_mrange_addr(range)); - -            status = extend_packed_buffer(pbuf, &lk_phys, sizeof(phys_t), true); - -            if (status) -                status = extend_packed_buffer(pbuf, &lk->type, sizeof(InstructionLinkType), true); - -        } - -        return status; - -    } - -    if (result) -    { -        g_arch_instruction_lock_dest(instr); - -        count = g_arch_instruction_count_destinations(instr); - -        /** -         * Le type de lien ILT_REF n'est mis en place que lors de la création -         * d'opérandes de type G_TYPE_TARGET_OPERAND, et sera donc remis en place -         * dynamiquement lors de la restauration de ces derniers. -         */ - -        kept = 0; - -        for (i = 0; i < count && result; i++) -        { -            link = g_arch_instruction_get_destination(instr, i); - -            if (link->type != ILT_REF) -                kept++; - -            unref_instr_link(link); - -        } - -        result = extend_packed_buffer(pbuf, &kept, sizeof(size_t), true); - -        for (i = 0; i < count && result; i++) -        { -            link = g_arch_instruction_get_destination(instr, i); -            result = serialize_link(link); -            unref_instr_link(link); -        } - -        g_arch_instruction_unlock_dest(instr); - -    } - -    if (result) -    { -        extra = GET_ARCH_INSTR_EXTRA(instr); - -        LOCK_GOBJECT_EXTRA(extra); - -        result = extend_packed_buffer(pbuf, &extra->uid, sizeof(itid_t), true); - -        if (result) -            result = extend_packed_buffer(pbuf, &extra->flags, sizeof(ArchInstrFlag), true); - -        UNLOCK_GOBJECT_EXTRA(extra); - -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instr   = instruction d'assemblage à consulter.              * -*                storage = mécanisme de sauvegarde à manipuler.               * -*                pbuf    = zone tampon à remplir.                             * -*                                                                             * -*  Description : Sauvegarde une instruction dans une mémoire tampon.          * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_arch_instruction_store__old(GArchInstruction *instr, GAsmStorage *storage, packed_buffer_t *pbuf) -{ -    bool result;                            /* Bilan à retourner           */ - -    result = g_asm_storage_store_object_gtype(storage, G_OBJECT(instr), pbuf); - -    if (result) -        result = G_ARCH_INSTRUCTION_GET_CLASS(instr)->serialize(instr, storage, pbuf); - -    return result; - -} - - - -/* ---------------------------------------------------------------------------------- */  /*                          OFFRE DE CAPACITES DE GENERATION                          */  /* ---------------------------------------------------------------------------------- */ @@ -2393,18 +2038,23 @@ static bool _g_arch_instruction_load(GArchInstruction *instr, GObjectStorage *st      LOCK_GOBJECT_EXTRA(extra);      result = unpack_uleb128(&value, pbuf); -    if (!result) goto exit; -    extra->uid = value; +    if (result) +        extra->uid = value; -    result = unpack_uleb128(&value, pbuf); -    if (!result) goto exit; +    if (result) +    { +        result = unpack_uleb128(&value, pbuf); -    extra->flags = value; +        if (result) +            extra->flags = value; + +    }      UNLOCK_GOBJECT_EXTRA(extra); -    result = unpack_mrange(&instr->range, pbuf); +    if (result) +        result = unpack_mrange(&instr->range, pbuf);      if (result)      { @@ -2425,8 +2075,6 @@ static bool _g_arch_instruction_load(GArchInstruction *instr, GObjectStorage *st      if (result)          result = g_arch_instruction_load_destinations(instr, storage, pbuf); - exit: -      return result;  } diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 683adfb..26eadc9 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -310,19 +310,4 @@ const char *g_arch_instruction_get_description(const GArchInstruction *); -/* -------------------- CONSERVATION SUR DISQUE DES INSTRUCTIONS -------------------- */ - - -/* Depuis "storage.h" : définition d'une conservation d'instructions d'assemblage (instance) */ -typedef struct _GAsmStorage GAsmStorage; - - -/* Charge une instruction depuis une mémoire tampon. */ -GArchInstruction *g_arch_instruction_load__old(GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde une instruction dans une mémoire tampon. */ -bool g_arch_instruction_store__old(GArchInstruction *, GAsmStorage *, packed_buffer_t *); - - -  #endif  /* _ARCH_INSTRUCTION_H */ diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index c348654..d2f43f1 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -26,6 +26,7 @@  #include "operand.h" +#include "../analysis/storage/storage.h"  #include "../glibext/objhole.h" @@ -54,11 +55,11 @@ typedef void (* operand_update_inners_fc) (GArchOperand *, GArchOperand **, size  /* Fournit l'empreinte d'un candidat à une centralisation. */  typedef guint (* operand_hash_fc) (const GArchOperand *, bool); -/* Charge un opérande depuis une mémoire tampon. */ -typedef bool (* unserialize_operand_fc) (GArchOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +typedef bool (* load_operand_fc) (GArchOperand *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un opérande dans une mémoire tampon. */ -typedef bool (* serialize_operand_fc) (const GArchOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +typedef bool (* store_operand_fc) (GArchOperand *, GObjectStorage *, packed_buffer_t *);  /* Informations glissées dans la structure GObject de GArchOperand */ @@ -113,8 +114,8 @@ struct _GArchOperandClass      operand_update_inners_fc update_inner;  /* Mise à jour des éléments    */      operand_hash_fc hash;                   /* Prise d'empreinte           */ -    unserialize_operand_fc unserialize;     /* Chargement depuis un tampon */ -    serialize_operand_fc serialize;         /* Conservation dans un tampon */ +    load_operand_fc load;                   /* Chargement depuis un tampon */ +    store_operand_fc store;                 /* Conservation dans un tampon */  }; diff --git a/src/arch/operand.c b/src/arch/operand.c index 944c34e..e95f24e 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -31,6 +31,7 @@  #include "operand-int.h"  #include "storage.h" +#include "../analysis/storage/serialize-int.h"  #include "../common/fnv1a.h"  #include "../common/sort.h"  #include "../core/logs.h" @@ -48,7 +49,10 @@ static void g_arch_operand_class_init(GArchOperandClass *);  static void g_arch_operand_init(GArchOperand *);  /* Procède à l'initialisation de l'interface de singleton. */ -static void g_arch_operand_singleton_interface_init(GSingletonCandidateInterface *); +static void g_arch_operand_singleton_init(GSingletonCandidateInterface *); + +/* Procède à l'initialisation de l'interface de sérialisation. */ +static void g_arch_operand_serializable_init(GSerializableObjectInterface *);  /* Supprime toutes les références externes. */  static void g_arch_operand_dispose(GArchOperand *); @@ -87,14 +91,20 @@ static bool g_arch_operand_is_read_only(GArchOperand *); -/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ +/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */ + + +/* Charge un contenu depuis une mémoire tampon. */ +static bool _g_arch_operand_load(GArchOperand *, GObjectStorage *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_arch_operand_load(GArchOperand *, GObjectStorage *, packed_buffer_t *); -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_arch_operand_unserialize(GArchOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool _g_arch_operand_store(GArchOperand *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_arch_operand_serialize(const GArchOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_arch_operand_store(GArchOperand *, GObjectStorage *, packed_buffer_t *); @@ -105,7 +115,8 @@ static bool g_arch_operand_serialize(const GArchOperand *, GAsmStorage *, packed  /* Indique le type défini pour un opérande d'architecture. */  G_DEFINE_TYPE_WITH_CODE(GArchOperand, g_arch_operand, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_SINGLETON_CANDIDATE, g_arch_operand_singleton_interface_init)); +                        G_IMPLEMENT_INTERFACE(G_TYPE_SINGLETON_CANDIDATE, g_arch_operand_singleton_init) +                        G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_arch_operand_serializable_init));  /****************************************************************************** @@ -136,8 +147,8 @@ static void g_arch_operand_class_init(GArchOperandClass *klass)      operand->hash = _g_arch_operand_hash; -    operand->unserialize = (unserialize_operand_fc)g_arch_operand_unserialize; -    operand->serialize = (serialize_operand_fc)g_arch_operand_serialize; +    operand->load = (load_operand_fc)_g_arch_operand_load; +    operand->store = (store_operand_fc)_g_arch_operand_store;  } @@ -177,7 +188,7 @@ static void g_arch_operand_init(GArchOperand *operand)  *                                                                             *  ******************************************************************************/ -static void g_arch_operand_singleton_interface_init(GSingletonCandidateInterface *iface) +static void g_arch_operand_singleton_init(GSingletonCandidateInterface *iface)  {      iface->list_inner = (list_inner_instances_fc)g_arch_operand_list_inner_instances;      iface->update_inner = (update_inner_instances_fc)g_arch_operand_update_inner_instances; @@ -193,6 +204,26 @@ static void g_arch_operand_singleton_interface_init(GSingletonCandidateInterface  /******************************************************************************  *                                                                             * +*  Paramètres  : iface = interface GLib à initialiser.                        * +*                                                                             * +*  Description : Procède à l'initialisation de l'interface de sérialisation.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_arch_operand_serializable_init(GSerializableObjectInterface *iface) +{ +    iface->load = (load_serializable_object_cb)g_arch_operand_load; +    iface->store = (store_serializable_object_cb)g_arch_operand_store; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : operand = instance d'objet GLib à traiter.                   *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -746,18 +777,17 @@ static bool g_arch_operand_is_read_only(GArchOperand *operand)  /* ---------------------------------------------------------------------------------- */ -/*                       TRANSPOSITIONS VIA CACHE DES OPERANDES                       */ +/*                      CONSERVATION ET RECHARGEMENT DES DONNEES                      */  /* ---------------------------------------------------------------------------------- */  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -765,11 +795,22 @@ static bool g_arch_operand_is_read_only(GArchOperand *operand)  *                                                                             *  ******************************************************************************/ -static bool g_arch_operand_unserialize(GArchOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool _g_arch_operand_load(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */ +    operand_extra_data_t *extra;            /* Données insérées à consulter*/ +    uleb128_t value;                        /* Valeur ULEB128 à charger    */ + +    extra = GET_ARCH_OP_EXTRA(operand); -    result = true; +    LOCK_GOBJECT_EXTRA(extra); + +    result = unpack_uleb128(&value, pbuf); + +    if (result) +        extra->flags = value; + +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -778,36 +819,26 @@ static bool g_arch_operand_unserialize(GArchOperand *operand, GAsmStorage *stora  /******************************************************************************  *                                                                             * -*  Paramètres  : 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      : Opérande d'assemblage constitué ou NULL en cas d'échec.      * +*  Retour      : Bilan de l'opération.                                        *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -GArchOperand *g_arch_operand_load(GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_arch_operand_load(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  { -    GArchOperand *result;                   /* Instance à retourner        */ -    bool status;                            /* Bilan du chargement         */ - -    result = G_ARCH_OPERAND(g_asm_storage_create_object(storage, pbuf)); - -    if (result != NULL) -    { -        status = G_ARCH_OPERAND_GET_CLASS(result)->unserialize(result, storage, format, pbuf); +    bool result;                            /* Bilan à retourner           */ +    GArchOperandClass *class;               /* Classe à activer            */ -        if (!status) -        { -            g_object_unref(G_OBJECT(result)); -            result = NULL; -        } +    class = G_ARCH_OPERAND_GET_CLASS(operand); -    } +    result = class->load(operand, storage, pbuf);      return result; @@ -816,11 +847,11 @@ GArchOperand *g_arch_operand_load(GAsmStorage *storage, GBinFormat *format, pack  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -828,11 +859,18 @@ GArchOperand *g_arch_operand_load(GAsmStorage *storage, GBinFormat *format, pack  *                                                                             *  ******************************************************************************/ -static bool g_arch_operand_serialize(const GArchOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool _g_arch_operand_store(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */ +    operand_extra_data_t *extra;            /* Données insérées à consulter*/ -    result = true; +    extra = GET_ARCH_OP_EXTRA(operand); + +    LOCK_GOBJECT_EXTRA(extra); + +    result = pack_uleb128((uleb128_t []){ extra->flags }, pbuf); + +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -841,11 +879,11 @@ static bool g_arch_operand_serialize(const GArchOperand *operand, GAsmStorage *s  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = instruction 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.                                        *  *                                                                             * @@ -853,14 +891,14 @@ static bool g_arch_operand_serialize(const GArchOperand *operand, GAsmStorage *s  *                                                                             *  ******************************************************************************/ -bool g_arch_operand_store(const GArchOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_arch_operand_store(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */ +    GArchOperandClass *class;               /* Classe à activer            */ -    result = g_asm_storage_store_object_gtype(storage, G_OBJECT(operand), pbuf); +    class = G_ARCH_OPERAND_GET_CLASS(operand); -    if (result) -        result = G_ARCH_OPERAND_GET_CLASS(operand)->serialize(operand, storage, pbuf); +    result = class->store(operand, storage, pbuf);      return result; diff --git a/src/arch/operand.h b/src/arch/operand.h index f8d2536..a93e898 100644 --- a/src/arch/operand.h +++ b/src/arch/operand.h @@ -112,12 +112,5 @@ ArchOperandFlag g_arch_operand_get_flags(const GArchOperand *);  typedef struct _GAsmStorage GAsmStorage; -/* Charge un opérande depuis une mémoire tampon. */ -GArchOperand *g_arch_operand_load(GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un opérande dans une mémoire tampon. */ -bool g_arch_operand_store(const GArchOperand *, GAsmStorage *, packed_buffer_t *); - -  #endif  /* _ARCH_OPERAND_H */ diff --git a/src/arch/operands/feeder-int.h b/src/arch/operands/feeder-int.h index 86bc98f..f2f2566 100644 --- a/src/arch/operands/feeder-int.h +++ b/src/arch/operands/feeder-int.h @@ -28,6 +28,9 @@  #include "feeder.h" +#include "../../analysis/storage/serialize-int.h" + +  /* Compare un fournisseur avec un autre. */  typedef int (* compare_proxy_operand_fc) (const GProxyFeeder *, const GProxyFeeder *); @@ -35,26 +38,17 @@ typedef int (* compare_proxy_operand_fc) (const GProxyFeeder *, const GProxyFeed  /* Traduit un fournisseur en version humainement lisible. */  typedef void (* print_proxy_feeder_fc) (const GProxyFeeder *, GBufferLine *); -/* Charge un fournisseur depuis une mémoire tampon. */ -typedef bool (* unserialize_proxy_feeder_fc) (GProxyFeeder *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un fournisseur dans une mémoire tampon. */ -typedef bool (* serialize_proxy_feeder_fc) (const GProxyFeeder *, packed_buffer_t *); -  /* Fournisseur d'élément non architectural (interface) */  struct _GProxyFeederIface  { -    GTypeInterface base_iface;              /* A laisser en premier        */ +    GSerializableObjectInterface base_iface;/* A laisser en premier        */      compare_proxy_operand_fc compare;       /* Comparaison entre éléments  */      print_proxy_feeder_fc print;            /* Affichage sur une ligne     */ -    unserialize_proxy_feeder_fc unserialize;/* Restauration de l'élément   */ -    serialize_proxy_feeder_fc serialize;    /* Sauvegarder de l'élément    */ -  }; diff --git a/src/arch/operands/feeder.c b/src/arch/operands/feeder.c index f34475c..af23fea 100644 --- a/src/arch/operands/feeder.c +++ b/src/arch/operands/feeder.c @@ -28,13 +28,32 @@ +/* -------------------- DEFINITION DE L'INTERFACE DE FOURNISSEUR -------------------- */ + +  /* Procède à l'initialisation de l'interface de rassemblement. */  static void g_proxy_feeder_default_init(GProxyFeederInterface *); +/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */ + + +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_proxy_feeder_load(GProxyFeeder *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_proxy_feeder_store(GProxyFeeder *, GObjectStorage *, packed_buffer_t *); + + + +/* ---------------------------------------------------------------------------------- */ +/*                      DEFINITION DE L'INTERFACE DE FOURNISSEUR                      */ +/* ---------------------------------------------------------------------------------- */ + +  /* Détermine le type d'une interface pour la Fourniture d'éléments non architecturaux. */ -G_DEFINE_INTERFACE(GProxyFeeder, g_proxy_feeder, G_TYPE_OBJECT) +G_DEFINE_INTERFACE(GProxyFeeder, g_proxy_feeder, G_TYPE_SERIALIZABLE_OBJECT)  /****************************************************************************** @@ -104,58 +123,3 @@ void g_proxy_feeder_print(const GProxyFeeder *feeder, GBufferLine *line)      iface->print(feeder, line);  } - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : feeder = fournisseur à constituer.                           * -*                format = format binaire chargé associé à l'architecture.     * -*                pbuf   = zone tampon à remplir.                              * -*                                                                             * -*  Description : Charge un fournisseur depuis une mémoire tampon.             * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_proxy_feeder_unserialize(GProxyFeeder *feeder, GBinFormat *format, packed_buffer_t *pbuf) -{ -    bool result;                            /* Bilan à retourner           */ -    GProxyFeederIface *iface;               /* Interface utilisée          */ - -    iface = G_PROXY_FEEDER_GET_IFACE(feeder); - -    result = iface->unserialize(feeder, format, pbuf); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : feeder = fournisseur à consulter.                            * -*                pbuf   = zone tampon à remplir.                              * -*                                                                             * -*  Description : Sauvegarde un fournisseur dans une mémoire tampon.           * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_proxy_feeder_serialize(const GProxyFeeder *feeder, packed_buffer_t *pbuf) -{ -    bool result;                            /* Bilan à retourner           */ -    GProxyFeederIface *iface;               /* Interface utilisée          */ - -    iface = G_PROXY_FEEDER_GET_IFACE(feeder); - -    result = iface->serialize(feeder, pbuf); - -    return result; - -} diff --git a/src/arch/operands/feeder.h b/src/arch/operands/feeder.h index 2d8559e..685323b 100644 --- a/src/arch/operands/feeder.h +++ b/src/arch/operands/feeder.h @@ -26,11 +26,8 @@  #include <glib-object.h> -#include <stdbool.h> -#include "../../common/packed.h" -#include "../../format/format.h"  #include "../../glibext/bufferline.h" @@ -59,12 +56,6 @@ int g_proxy_feeder_compare(const GProxyFeeder *, const GProxyFeeder *);  /* Traduit un fournisseur en version humainement lisible. */  void g_proxy_feeder_print(const GProxyFeeder *, GBufferLine *); -/* Charge un fournisseur depuis une mémoire tampon. */ -bool g_proxy_feeder_unserialize(GProxyFeeder *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un fournisseur dans une mémoire tampon. */ -bool g_proxy_feeder_serialize(const GProxyFeeder *, packed_buffer_t *); -  #endif  /* _ARCH_OPERANDS_FEEDER_H */ 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;  } diff --git a/src/arch/operands/known.c b/src/arch/operands/known.c index bf16674..a4b3844 100644 --- a/src/arch/operands/known.c +++ b/src/arch/operands/known.c @@ -31,6 +31,7 @@  #include "immediate-int.h"  #include "rename-int.h" +#include "../../analysis/db/misc/rlestr.h"  #include "../../core/logs.h"  #include "../../gtkext/gtkblockdisplay.h" @@ -85,11 +86,11 @@ static void g_known_imm_operand_print(const GKnownImmOperand *, GBufferLine *);  /* Fournit l'empreinte d'un candidat à une centralisation. */  static guint g_known_imm_operand_hash(const GKnownImmOperand *, bool); -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_known_imm_operand_unserialize(GKnownImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_known_imm_operand_load(GKnownImmOperand *, GObjectStorage *, packed_buffer_t *); -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_known_imm_operand_serialize(const GKnownImmOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_known_imm_operand_store(GKnownImmOperand *, GObjectStorage *, packed_buffer_t *); @@ -139,8 +140,8 @@ static void g_known_imm_operand_class_init(GKnownImmOperandClass *klass)      operand->hash = (operand_hash_fc)g_known_imm_operand_hash; -    operand->unserialize = (unserialize_operand_fc)g_known_imm_operand_unserialize; -    operand->serialize = (serialize_operand_fc)g_known_imm_operand_serialize; +    operand->load = (load_operand_fc)g_known_imm_operand_load; +    operand->store = (store_operand_fc)g_known_imm_operand_store;  } @@ -386,12 +387,11 @@ static guint g_known_imm_operand_hash(const GKnownImmOperand *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.                                        *  *                                                                             * @@ -399,27 +399,30 @@ static guint g_known_imm_operand_hash(const GKnownImmOperand *operand, bool lock  *                                                                             *  ******************************************************************************/ -static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_known_imm_operand_load(GKnownImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      GArchOperandClass *parent;              /* Classe parente à consulter  */ -    unsigned short len;                     /* Taille du contenu alternatif*/ +    rle_string str;                         /* Chaîne à charger            */      parent = G_ARCH_OPERAND_CLASS(g_known_imm_operand_parent_class); -    result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); +    result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);      if (result) -        result = extract_packed_buffer(pbuf, &len, sizeof(unsigned short), true); +    { +        setup_empty_rle_string(&str); -    if (result) -        result = (len > 0); +        result = unpack_rle_string(&str, pbuf); -    if (result) -    { -        operand->alt_text = malloc(len); +        if (result) +        { +            if (get_rle_string(&str) != NULL) +                operand->alt_text = strdup(get_rle_string(&str)); -        result = extract_packed_buffer(pbuf, operand->alt_text, len, false); +            exit_rle_string(&str); + +        }      } @@ -430,11 +433,11 @@ static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStora  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -442,33 +445,23 @@ static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStora  *                                                                             *  ******************************************************************************/ -static bool g_known_imm_operand_serialize(const GKnownImmOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_known_imm_operand_store(GKnownImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      GArchOperandClass *parent;              /* Classe parente à consulter  */ -    size_t len;                             /* Taille du contenu alternatif*/ +    rle_string str;                         /* Chaîne à conserver          */      parent = G_ARCH_OPERAND_CLASS(g_known_imm_operand_parent_class); -    result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); +    result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);      if (result)      { -        len = strlen(operand->alt_text) + 1; -        assert(len > 1); - -        if (len > (2 << (sizeof(unsigned short) * 8 - 1))) -        { -            log_variadic_message(LMT_ERROR, "Alternative text too long: '%s' (%zu bytes)", -                                 operand->alt_text, len); -            result = false; -        } +        init_static_rle_string(&str, operand->alt_text); -        else -            result = extend_packed_buffer(pbuf, (unsigned short []) { len }, sizeof(unsigned short), true); +        result = pack_rle_string(&str, pbuf); -        if (result) -            result = extend_packed_buffer(pbuf, operand->alt_text, len, false); +        exit_rle_string(&str);      } diff --git a/src/arch/operands/proxy.c b/src/arch/operands/proxy.c index 992c481..91690a7 100644 --- a/src/arch/operands/proxy.c +++ b/src/arch/operands/proxy.c @@ -43,6 +43,11 @@ static void g_proxy_operand_dispose(GProxyOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_proxy_operand_finalize(GProxyOperand *); + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + +  /* Compare un opérande avec un autre. */  static int g_proxy_operand_compare(const GProxyOperand *, const GProxyOperand *, bool); @@ -52,16 +57,11 @@ static void g_proxy_operand_print(const GProxyOperand *, GBufferLine *);  /* Fournit l'empreinte d'un candidat à une centralisation. */  static guint g_proxy_operand_hash(const GProxyOperand *, bool); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_proxy_operand_load(GProxyOperand *, GObjectStorage *, packed_buffer_t *); - -/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ - - -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_proxy_operand_unserialize(GProxyOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_proxy_operand_serialize(const GProxyOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_proxy_operand_store(GProxyOperand *, GObjectStorage *, packed_buffer_t *); @@ -103,8 +103,8 @@ static void g_proxy_operand_class_init(GProxyOperandClass *klass)      operand->hash = (operand_hash_fc)g_proxy_operand_hash; -    operand->unserialize = (unserialize_operand_fc)g_proxy_operand_unserialize; -    operand->serialize = (serialize_operand_fc)g_proxy_operand_serialize; +    operand->load = (load_operand_fc)g_proxy_operand_load; +    operand->store = (store_operand_fc)g_proxy_operand_store;  } @@ -195,6 +195,37 @@ GArchOperand *g_proxy_operand_new(GProxyFeeder *feeder)  /******************************************************************************  *                                                                             * +*  Paramètres  : operand = opérande à consulter.                              * +*                                                                             * +*  Description : Fournit le fournisseur représenté par l'opérande.            * +*                                                                             * +*  Retour      : Fournisseur associé à l'opérande.                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand) +{ +    GProxyFeeder *result;                   /* Instance à retourner        */ + +    result = operand->feeder; + +    g_object_ref(G_OBJECT(result)); + +    return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/*                       IMPLEMENTATION DES FONCTIONS DE CLASSE                       */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : a    = premier opérande à consulter.                         *  *                b    = second opérande à consulter.                          *  *                lock = précise le besoin en verrouillage.                    * @@ -301,43 +332,11 @@ static guint g_proxy_operand_hash(const GProxyOperand *operand, bool lock)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = opérande à consulter.                              * +*  Paramètres  : operand = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                *  *                                                                             * -*  Description : Fournit le fournisseur représenté par l'opérande.            * -*                                                                             * -*  Retour      : Fournisseur associé à l'opérande.                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand) -{ -    GProxyFeeder *result;                   /* Instance à retourner        */ - -    result = operand->feeder; - -    g_object_ref(G_OBJECT(result)); - -    return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/*                       TRANSPOSITIONS VIA CACHE DES OPERANDES                       */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  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.                             * -*                                                                             * -*  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.                                        *  *                                                                             * @@ -345,17 +344,26 @@ GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand)  *                                                                             *  ******************************************************************************/ -static bool g_proxy_operand_unserialize(GProxyOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_proxy_operand_load(GProxyOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      GArchOperandClass *parent;              /* Classe parente à consulter  */ +    GSerializableObject *feeder;            /* Fournisseur manipulé        */      parent = G_ARCH_OPERAND_CLASS(g_proxy_operand_parent_class); -    result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); +    result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);      if (result) -        result = g_proxy_feeder_unserialize(operand->feeder, format, pbuf); +    { +        feeder = g_object_storage_unpack_object(storage, "operands", pbuf); + +        result = (feeder != NULL); + +        if (result) +            operand->feeder = G_PROXY_FEEDER(feeder); + +    }      return result; @@ -364,11 +372,11 @@ static bool g_proxy_operand_unserialize(GProxyOperand *operand, GAsmStorage *sto  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -376,17 +384,21 @@ static bool g_proxy_operand_unserialize(GProxyOperand *operand, GAsmStorage *sto  *                                                                             *  ******************************************************************************/ -static bool g_proxy_operand_serialize(const GProxyOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_proxy_operand_store(GProxyOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */ -    GArchOperandClass *parent;              /* Classe parente à consulter  */ +    GArchOperandClass *parent;              /* Classe parente à consulter  */  +    GSerializableObject *feeder;            /* Fournisseur manipulé        */      parent = G_ARCH_OPERAND_CLASS(g_proxy_operand_parent_class); -    result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); +    result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);      if (result) -        result = g_proxy_feeder_serialize(operand->feeder, pbuf); +    { +        feeder = G_SERIALIZABLE_OBJECT(operand->feeder); +        result = g_object_storage_pack_object(storage, "operands", feeder, pbuf); +    }      return result; diff --git a/src/arch/operands/register.c b/src/arch/operands/register.c index 8cfe39f..4615a99 100644 --- a/src/arch/operands/register.c +++ b/src/arch/operands/register.c @@ -47,30 +47,25 @@ static void g_register_operand_dispose(GRegisterOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_register_operand_finalize(GRegisterOperand *); -/* Compare un opérande avec un autre. */ -static int g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *, bool); -/* Traduit un opérande en version humainement lisible. */ -static void g_register_operand_print(const GRegisterOperand *, GBufferLine *); +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ -/* ------------------------ CONTROLE DU VOLUME DES INSTANCES ------------------------ */ +/* Compare un opérande avec un autre. */ +static int g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *, bool); +/* Traduit un opérande en version humainement lisible. */ +static void g_register_operand_print(const GRegisterOperand *, GBufferLine *);  /* Fournit l'empreinte d'un candidat à une centralisation. */  static guint g_register_operand_hash(const GRegisterOperand *, bool); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_register_operand_load(GRegisterOperand *, GObjectStorage *, packed_buffer_t *); - -/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ - - -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_register_operand_unserialize(GRegisterOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_register_operand_serialize(const GRegisterOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_register_operand_store(GRegisterOperand *, GObjectStorage *, packed_buffer_t *); @@ -113,8 +108,8 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass)      operand->hash = (operand_hash_fc)g_register_operand_hash; -    operand->unserialize = (unserialize_operand_fc)g_register_operand_unserialize; -    operand->serialize = (serialize_operand_fc)g_register_operand_serialize; +    operand->load = (load_operand_fc)g_register_operand_load; +    operand->store = (store_operand_fc)g_register_operand_store;  } @@ -180,6 +175,37 @@ static void g_register_operand_finalize(GRegisterOperand *operand)  /******************************************************************************  *                                                                             * +*  Paramètres  : operand = opérande représentant un registre.                 * +*                                                                             * +*  Description : Fournit le registre associé à l'opérande.                    * +*                                                                             * +*  Retour      : Représentation interne du registre.                          * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand) +{ +    GArchRegister *result;                  /* Instance à retourner        */ + +    result = operand->reg; + +    g_object_ref(G_OBJECT(result)); + +    return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/*                       IMPLEMENTATION DES FONCTIONS DE CLASSE                       */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : a    = premier opérande à consulter.                         *  *                b    = second opérande à consulter.                          *  *                lock = précise le besoin en verrouillage.                    * @@ -232,37 +258,6 @@ static void g_register_operand_print(const GRegisterOperand *operand, GBufferLin  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = opérande représentant un registre.                 * -*                                                                             * -*  Description : Fournit le registre associé à l'opérande.                    * -*                                                                             * -*  Retour      : Représentation interne du registre.                          * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand) -{ -    GArchRegister *result;                  /* Instance à retourner        */ - -    result = operand->reg; - -    g_object_ref(G_OBJECT(result)); - -    return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/*                          CONTROLE DU VOLUME DES INSTANCES                          */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : operand = objet dont l'instance se veut unique.              *  *                lock    = précise le besoin en verrouillage.                 *  *                                                                             * @@ -294,20 +289,13 @@ static guint g_register_operand_hash(const GRegisterOperand *operand, bool lock)  } - -/* ---------------------------------------------------------------------------------- */ -/*                       TRANSPOSITIONS VIA CACHE DES OPERANDES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -315,37 +303,24 @@ static guint g_register_operand_hash(const GRegisterOperand *operand, bool lock)  *                                                                             *  ******************************************************************************/ -static bool g_register_operand_unserialize(GRegisterOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_register_operand_load(GRegisterOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      GArchOperandClass *parent;              /* Classe parente à consulter  */ -    off64_t pos;                            /* Position dans le flux       */ -    packed_buffer_t reg_pbuf;               /* Tampon des données à écrire */ -    GArchRegister *reg;                     /* Registre restauré           */ +    GSerializableObject *reg;               /* Registre manipulé           */      parent = G_ARCH_OPERAND_CLASS(g_register_operand_parent_class); -    result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); - -    if (result) -        result = extract_packed_buffer(pbuf, &pos, sizeof(off64_t), true); +    result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);      if (result)      { -        init_packed_buffer(®_pbuf); +        reg = g_object_storage_unpack_object(storage, "registers", pbuf); -        result = g_asm_storage_load_register_data(storage, ®_pbuf, pos); +        result = (reg != NULL);          if (result) -        { -            reg = NULL;//g_arch_register_load(storage, ®_pbuf); -            result = (reg != NULL); -        } - -        if (result) -            operand->reg = reg; - -        exit_packed_buffer(®_pbuf); +            operand->reg = G_ARCH_REGISTER(reg);      } @@ -356,11 +331,11 @@ static bool g_register_operand_unserialize(GRegisterOperand *operand, GAsmStorag  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -368,31 +343,20 @@ static bool g_register_operand_unserialize(GRegisterOperand *operand, GAsmStorag  *                                                                             *  ******************************************************************************/ -static bool g_register_operand_serialize(const GRegisterOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_register_operand_store(GRegisterOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */ -    GArchOperandClass *parent;              /* Classe parente à consulter  */ -    off64_t pos;                            /* Position dans le flux       */ -    packed_buffer_t reg_pbuf;               /* Tampon des données à écrire */ +    GArchOperandClass *parent;              /* Classe parente à consulter  */  +    GSerializableObject *reg;               /* Registre manipulé           */      parent = G_ARCH_OPERAND_CLASS(g_register_operand_parent_class); -    result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); +    result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);      if (result)      { -        init_packed_buffer(®_pbuf); - -        result = false;//g_arch_register_store(operand->reg, 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); - -        exit_packed_buffer(®_pbuf); - +        reg = G_SERIALIZABLE_OBJECT(operand->reg); +        result = g_object_storage_pack_object(storage, "registers", reg, pbuf);      }      return result; diff --git a/src/arch/operands/target.c b/src/arch/operands/target.c index 6450834..068d060 100644 --- a/src/arch/operands/target.c +++ b/src/arch/operands/target.c @@ -45,6 +45,9 @@ +/* ------------------------- POINTAGE D'UN SYMBOLE EXISTANT ------------------------- */ + +  /* Initialise la classe des opérandes ciblant des symboles. */  static void g_target_operand_class_init(GTargetOperandClass *); @@ -60,6 +63,11 @@ static void g_target_operand_dispose(GTargetOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_target_operand_finalize(GTargetOperand *); + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + +  /* Compare un opérande avec un autre. */  static int g_target_operand_compare(const GTargetOperand *, const GTargetOperand *, bool); @@ -72,16 +80,11 @@ static char *g_target_operand_build_tooltip(const GTargetOperand *, const GLoade  /* Fournit l'empreinte d'un candidat à une centralisation. */  static guint g_target_operand_hash(const GTargetOperand *, bool); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_target_operand_load(GTargetOperand *, GObjectStorage *, packed_buffer_t *); - -/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ - - -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_target_operand_unserialize(GTargetOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_target_operand_serialize(const GTargetOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_target_operand_store(GTargetOperand *, GObjectStorage *, packed_buffer_t *); @@ -93,6 +96,11 @@ static bool g_target_operand_get_addr(const GTargetOperand *, const vmpa2t *, GB +/* ---------------------------------------------------------------------------------- */ +/*                           POINTAGE D'UN SYMBOLE EXISTANT                           */ +/* ---------------------------------------------------------------------------------- */ + +  /* Indique le type défini pour un opérande de valeur numérique. */  G_DEFINE_TYPE_WITH_CODE(GTargetOperand, g_target_operand, G_TYPE_ARCH_OPERAND,                          G_IMPLEMENT_INTERFACE(G_TYPE_TARGETABLE_OPERAND, g_target_operand_targetable_interface_init)); @@ -128,8 +136,8 @@ static void g_target_operand_class_init(GTargetOperandClass *klass)      operand->hash = (operand_hash_fc)g_target_operand_hash; -    operand->unserialize = (unserialize_operand_fc)g_target_operand_unserialize; -    operand->serialize = (serialize_operand_fc)g_target_operand_serialize; +    operand->load = (load_operand_fc)g_target_operand_load; +    operand->store = (store_operand_fc)g_target_operand_store;  } @@ -636,20 +644,13 @@ static guint g_target_operand_hash(const GTargetOperand *operand, bool lock)  } - -/* ---------------------------------------------------------------------------------- */ -/*                       TRANSPOSITIONS VIA CACHE DES OPERANDES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -657,7 +658,7 @@ static guint g_target_operand_hash(const GTargetOperand *operand, bool lock)  *                                                                             *  ******************************************************************************/ -static bool g_target_operand_unserialize(GTargetOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_target_operand_load(GTargetOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */ @@ -684,11 +685,11 @@ static bool g_target_operand_unserialize(GTargetOperand *operand, GAsmStorage *s  /******************************************************************************  *                                                                             * -*  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.                                        *  *                                                                             * @@ -696,7 +697,7 @@ static bool g_target_operand_unserialize(GTargetOperand *operand, GAsmStorage *s  *                                                                             *  ******************************************************************************/ -static bool g_target_operand_serialize(const GTargetOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_target_operand_store(GTargetOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      MemoryDataSize size;                    /* Taille retenue              */ @@ -714,7 +715,7 @@ static bool g_target_operand_serialize(const GTargetOperand *operand, GAsmStorag      else          original = g_imm_operand_new_from_value(size, get_phy_addr(&operand->addr)); -    result = g_arch_operand_store(original, storage, pbuf); +    result = g_object_storage_pack_object(storage, "operands", G_SERIALIZABLE_OBJECT(original), pbuf);      g_object_unref(G_OBJECT(original)); diff --git a/src/arch/register-int.h b/src/arch/register-int.h index 4bff491..f0b9af9 100644 --- a/src/arch/register-int.h +++ b/src/arch/register-int.h @@ -26,7 +26,7 @@  #include "register.h" -#include "../analysis/storage/storage.h" +#include "../analysis/storage/serialize-int.h" diff --git a/src/arch/register.c b/src/arch/register.c index 112492c..f487419 100644 --- a/src/arch/register.c +++ b/src/arch/register.c @@ -25,7 +25,6 @@  #include "register-int.h" -#include "../analysis/storage/serialize-int.h" diff --git a/src/arch/storage.c b/src/arch/storage.c index d552ae3..73521df 100644 --- a/src/arch/storage.c +++ b/src/arch/storage.c @@ -486,7 +486,7 @@ static void g_ins_caching_process_store(GInsCaching *caching, GtkStatusStack *st          instr = g_arch_processor_get_instruction(proc, i); -        caching->status = g_arch_instruction_store__old(instr, storage, &pbuf); +        caching->status = false;//g_arch_instruction_store__old(instr, storage, &pbuf);          if (caching->status)              caching->status = g_asm_storage_store_instruction_data(storage, &pbuf, &pos); @@ -1544,7 +1544,7 @@ GArchInstruction *g_asm_storage_get_instruction_at(GAsmStorage *storage, GBinFor                  status = g_asm_storage_load_instruction_data(storage, pbuf, target);              if (status) -                storage->collected[index] = g_arch_instruction_load__old(storage, format, pbuf); +                storage->collected[index] = NULL;//g_arch_instruction_load__old(storage, format, pbuf);              if (storage->collected[index] != NULL)              { diff --git a/src/format/strsym.c b/src/format/strsym.c index d5b9157..d585434 100644 --- a/src/format/strsym.c +++ b/src/format/strsym.c @@ -182,8 +182,8 @@ static void g_string_symbol_feeder_interface_init(GProxyFeederInterface *iface)      iface->print = (print_proxy_feeder_fc)g_string_symbol_print; -    iface->unserialize = (unserialize_proxy_feeder_fc)g_string_symbol_unserialize; -    iface->serialize = (serialize_proxy_feeder_fc)g_string_symbol_serialize; +    //iface->unserialize = (unserialize_proxy_feeder_fc)g_string_symbol_unserialize; +    //iface->serialize = (serialize_proxy_feeder_fc)g_string_symbol_serialize;  } diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h index 7f5807c..7f8bb7f 100644 --- a/src/format/symbol-int.h +++ b/src/format/symbol-int.h @@ -26,6 +26,7 @@  #include "symbol.h" +#include "../analysis/storage/serialize-int.h"  #include "../glibext/objhole.h" @@ -33,6 +34,12 @@  /* Fournit une étiquette pour viser un symbole. */  typedef char * (* get_symbol_label_fc) (const GBinSymbol *); +/* Charge un contenu depuis une mémoire tampon. */ +typedef bool (* load_symbol_fc) (GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +typedef bool (* store_symbol_fc) (GBinSymbol *, GObjectStorage *, packed_buffer_t *); +  /* Informations glissées dans la structure GObject de GBinSymbol */  typedef struct _sym_extra_data_t @@ -86,6 +93,9 @@ struct _GBinSymbolClass      get_symbol_label_fc get_label;          /* Obtention d'une étiquette   */ +    load_symbol_fc load;                    /* Chargement depuis un tampon */ +    store_symbol_fc store;                  /* Conservation dans un tampon */ +  }; diff --git a/src/format/symbol.c b/src/format/symbol.c index d3d5285..2cd4f87 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -48,6 +48,9 @@ static void g_binary_symbol_init(GBinSymbol *);  /* Procède à l'initialisation de l'interface de génération. */  static void g_binary_symbol_interface_init(GLineGeneratorInterface *); +/* Procède à l'initialisation de l'interface de sérialisation. */ +static void g_binary_symbol_serializable_init(GSerializableObjectInterface *); +  /* Supprime toutes les références externes. */  static void g_binary_symbol_dispose(GBinSymbol *); @@ -76,6 +79,23 @@ static void g_binary_symbol_print(GBinSymbol *, GBufferLine *, size_t, size_t, c +/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */ + + +/* Charge un contenu depuis une mémoire tampon. */ +static bool _g_binary_symbol_load(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_binary_symbol_load(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool _g_binary_symbol_store(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_binary_symbol_store(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + + +  /* ---------------------------------------------------------------------------------- */  /*                       FONCTIONNALITES BASIQUES POUR SYMBOLES                       */  /* ---------------------------------------------------------------------------------- */ @@ -83,7 +103,8 @@ static void g_binary_symbol_print(GBinSymbol *, GBufferLine *, size_t, size_t, c  /* Indique le type défini pour un symbole d'exécutable. */  G_DEFINE_TYPE_WITH_CODE(GBinSymbol, g_binary_symbol, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_binary_symbol_interface_init)); +                        G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_binary_symbol_interface_init) +                        G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_binary_symbol_serializable_init));  /****************************************************************************** @@ -107,6 +128,9 @@ static void g_binary_symbol_class_init(GBinSymbolClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_binary_symbol_dispose;      object->finalize = (GObjectFinalizeFunc)g_binary_symbol_finalize; +    klass->load = (load_symbol_fc)_g_binary_symbol_load; +    klass->store = (store_symbol_fc)_g_binary_symbol_store; +  } @@ -162,6 +186,26 @@ static void g_binary_symbol_interface_init(GLineGeneratorInterface *iface)  /******************************************************************************  *                                                                             * +*  Paramètres  : iface = interface GLib à initialiser.                        * +*                                                                             * +*  Description : Procède à l'initialisation de l'interface de sérialisation.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_binary_symbol_serializable_init(GSerializableObjectInterface *iface) +{ +    iface->load = (load_serializable_object_cb)g_binary_symbol_load; +    iface->store = (store_serializable_object_cb)g_binary_symbol_store; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : symbol = instance d'objet GLib à traiter.                    *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -871,3 +915,115 @@ static void g_binary_symbol_print(GBinSymbol *symbol, GBufferLine *line, size_t      }  } + + + +/* ---------------------------------------------------------------------------------- */ +/*                      CONSERVATION ET RECHARGEMENT DES DONNEES                      */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un contenu depuis une mémoire tampon.                 * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool _g_binary_symbol_load(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ + +    result = true; + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un contenu depuis une mémoire tampon.                 * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_symbol_load(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GBinSymbolClass *class;              /* Classe à activer            */ + +    class = G_BIN_SYMBOL_GET_CLASS(symbol); + +    result = class->load(symbol, storage, pbuf); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un contenu dans une mémoire tampon.               * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool _g_binary_symbol_store(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ + +    result = true; + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un contenu dans une mémoire tampon.               * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_symbol_store(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GBinSymbolClass *class;              /* Classe à activer            */ + +    class = G_BIN_SYMBOL_GET_CLASS(symbol); + +    result = class->store(symbol, storage, pbuf); + +    return result; + +}  | 
