diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2017-05-14 19:19:11 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2017-05-14 19:19:11 (GMT) | 
| commit | cb36603eb37330ab6c956095c1ce175acb751e03 (patch) | |
| tree | e20d2e60c8947fddd34db543e41fa4287fc0db29 | |
| parent | 198ba09ef74a02a727ac3e679edfa328b2508152 (diff) | |
Begun to clean the symbol interface.
| -rw-r--r-- | ChangeLog | 24 | ||||
| -rw-r--r-- | plugins/pychrysa/format/symbol.c | 208 | ||||
| -rw-r--r-- | plugins/stackvars/stackvars.c | 3 | ||||
| -rw-r--r-- | src/analysis/decomp/decompiler.c | 3 | ||||
| -rw-r--r-- | src/analysis/disass/output.c | 32 | ||||
| -rw-r--r-- | src/analysis/routine.c | 50 | ||||
| -rw-r--r-- | src/analysis/routine.h | 6 | ||||
| -rw-r--r-- | src/format/Makefile.am | 1 | ||||
| -rw-r--r-- | src/format/symbol-int.h | 60 | ||||
| -rw-r--r-- | src/format/symbol.c | 202 | ||||
| -rw-r--r-- | src/format/symbol.h | 54 | 
11 files changed, 104 insertions, 539 deletions
@@ -1,5 +1,29 @@  17-05-14  Cyrille Bagard <nocbos@gmail.com> +	* plugins/pychrysa/format/symbol.c: +	Delete access to the removed features. + +	* plugins/stackvars/stackvars.c: +	* src/analysis/decomp/decompiler.c: +	* src/analysis/disass/output.c: +	Update code. + +	* src/analysis/routine.c: +	* src/analysis/routine.h: +	Make routines inherit from symbols. + +	* src/format/Makefile.am: +	Add the 'symbol-int.h' file to libformat_la_SOURCES. + +	* src/format/symbol-int.h: +	New entries: allow to inherit from the symbol object. + +	* src/format/symbol.c: +	* src/format/symbol.h: +	Begin to clean the symbol interface. + +17-05-14  Cyrille Bagard <nocbos@gmail.com> +  	* configure.ac:  	Add the new Makefile from the 'plugins/readmc' directory. diff --git a/plugins/pychrysa/format/symbol.c b/plugins/pychrysa/format/symbol.c index 75f226a..008aeb3 100644 --- a/plugins/pychrysa/format/symbol.c +++ b/plugins/pychrysa/format/symbol.c @@ -48,15 +48,9 @@ static PyObject *py_binary_symbol_richcompare(PyObject *, PyObject *, int);  /* Définit un autre nom pour le symbole. */  static PyObject *py_binary_symbol_set_alt_label(PyObject *, PyObject *); -/* Raffine la définition de l'emplacement d'un symbole. */ -static PyObject *py_binary_symbol_fix_range(PyObject *, PyObject *); -  /* Attache la routine associée au symbole. */  static PyObject *py_binary_symbol_attach_routine(PyObject *, PyObject *); -/* Attache l'instruction associée au symbole. */ -static PyObject *py_binary_symbol_attach_instruction(PyObject *, PyObject *); -  /* Fournit le type du symbole. */  static PyObject *py_binary_symbol_get_target_type(PyObject *, void *); @@ -69,15 +63,6 @@ static PyObject *py_binary_symbol_get_range(PyObject *, void *);  /* Fournit l'éventuelle routine associée au symbole. */  static PyObject *py_binary_symbol_get_routine(PyObject *, void *); -/* Fournit l'éventuelle instruction associée au symbole. */ -static PyObject *py_binary_symbol_get_instruction(PyObject *, void *); - -/* Fournit l'éventuel commentaire associé au symbole. */ -static PyObject *py_binary_symbol_get_comment(PyObject *, void *); - -/* Ajoute un commentaire facultatif au symbole. */ -static int py_binary_symbol_set_comment(PyObject *, PyObject *, void *); -  /* Définit les constantes pour les symboles binaires. */  static bool py_binary_symbol_define_constants(PyTypeObject *); @@ -204,39 +189,6 @@ static PyObject *py_binary_symbol_set_alt_label(PyObject *self, PyObject *args)  *  Paramètres  : self = classe représentant un binaire.                       *  *                args = arguments fournis à l'appel.                          *  *                                                                             * -*  Description : Raffine la définition de l'emplacement d'un symbole.         * -*                                                                             * -*  Retour      : None.                                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_binary_symbol_fix_range(PyObject *self, PyObject *args) -{ -    PyObject *py_vmpa;                      /* Localisation version Python */ -    int ret;                                /* Bilan de lecture des args.  */ -    GBinSymbol *symbol;                     /* Elément à consulter         */ - -    ret = PyArg_ParseTuple(args, "O", &py_vmpa); -    if (!ret) return NULL; - -    ret = PyObject_IsInstance(py_vmpa, (PyObject *)get_python_vmpa_type()); -    if (!ret) return NULL; - -    symbol = G_BIN_SYMBOL(pygobject_get(self)); -    g_binary_symbol_fix_range(symbol, get_internal_vmpa(py_vmpa)); - -    Py_RETURN_NONE; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = classe représentant un binaire.                       * -*                args = arguments fournis à l'appel.                          * -*                                                                             *  *  Description : Attache la routine associée au symbole.                      *  *                                                                             *  *  Retour      : None.                                                        * @@ -270,42 +222,6 @@ static PyObject *py_binary_symbol_attach_routine(PyObject *self, PyObject *args)  /******************************************************************************  *                                                                             * -*  Paramètres  : self = classe représentant un binaire.                       * -*                args = arguments fournis à l'appel.                          * -*                                                                             * -*  Description : Attache l'instruction associée au symbole.                   * -*                                                                             * -*  Retour      : None.                                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_binary_symbol_attach_instruction(PyObject *self, PyObject *args) -{ -    PyObject *py_instr;                     /* Instruction version Python  */ -    int ret;                                /* Bilan de lecture des args.  */ -    GBinSymbol *symbol;                     /* Elément à consulter         */ -    GArchInstruction *instr;                /* Instruction à attacher      */ - -    ret = PyArg_ParseTuple(args, "O", &py_instr); -    if (!ret) return NULL; - -    ret = PyObject_IsInstance(py_instr, (PyObject *)get_python_arch_instruction_type()); -    if (!ret) return NULL; - -    symbol = G_BIN_SYMBOL(pygobject_get(self)); -    instr = G_ARCH_INSTRUCTION(pygobject_get(py_instr)); - -    g_binary_symbol_attach_instruction(symbol, instr); - -    Py_RETURN_NONE; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : self    = objet Python concerné par l'appel.                 *  *                closure = non utilisé ici.                                   *  *                                                                             * @@ -427,112 +343,6 @@ static PyObject *py_binary_symbol_get_routine(PyObject *self, void *closure)  } - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self    = objet Python concerné par l'appel.                 * -*                closure = non utilisé ici.                                   * -*                                                                             * -*  Description : Fournit l'éventuelle instruction associée au symbole.        * -*                                                                             * -*  Retour      : Instance en place ou None si aucune.                         * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_binary_symbol_get_instruction(PyObject *self, void *closure) -{ -    PyObject *result;                       /* Valeur à retourner          */ -    GBinSymbol *symbol;                     /* Elément à consulter         */ -    GArchInstruction *instr;                /* Routine attachée            */ - -    symbol = G_BIN_SYMBOL(pygobject_get(self)); -    instr = g_binary_symbol_get_instruction(symbol); - -    result = pygobject_new(G_OBJECT(instr)); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self    = objet Python concerné par l'appel.                 * -*                closure = non utilisé ici.                                   * -*                                                                             * -*  Description : Fournit l'éventuel commentaire associé au symbole.           * -*                                                                             * -*  Retour      : Instance Python du commentaire GLib ou None si aucun.        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_binary_symbol_get_comment(PyObject *self, void *closure) -{ -    PyObject *result;                       /* Valeur à retourner          */ -    GBinSymbol *symbol;                     /* Elément à consulter         */ -    GDbComment *comment;                    /* Commentaire à associé       */ - -    symbol = G_BIN_SYMBOL(pygobject_get(self)); -    comment = g_binary_symbol_get_comment(symbol); - -    if (comment != NULL) -        result = pygobject_new(G_OBJECT(comment)); -    else -    { -        result = Py_None; -        Py_INCREF(result); -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self    = objet Python concerné par l'appel.                 * -*                value   = valeur fournie à intégrer ou prendre en compte.    * -*                closure = non utilisé ici.                                   * -*                                                                             * -*  Description : Ajoute un commentaire facultatif au symbole.                 * -*                                                                             * -*  Retour      : Bilan de l'opération pour Python.                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static int py_binary_symbol_set_comment(PyObject *self, PyObject *value, void *closure) -{ -    GBinSymbol *symbol;                     /* Elément à consulter         */ -    int ret;                                /* Bilan de lecture des args.  */ -    GDbComment *comment;                    /* Commentaire à associer      */ - -    symbol = G_BIN_SYMBOL(pygobject_get(self)); - -    if (value == Py_None) -        g_binary_symbol_set_comment(symbol, NULL); - -    else -    { -        ret = PyObject_IsInstance(value, (PyObject *)get_python_db_comment_type()); -        if (!ret) return -1; - -        comment = G_DB_COMMENT(pygobject_get(value)); - -        g_binary_symbol_set_comment(symbol, comment); - -    } - -    return 0; - -} - -  /******************************************************************************  *                                                                             *  *  Paramètres  : obj_type = type dont le dictionnaire est à compléter.        * @@ -586,20 +396,10 @@ PyTypeObject *get_python_binary_symbol_type(void)              "set_alt_label($self, alt, /)\n--\n\nSet an alternative label for the symbol."          },          { -            "fix_range", py_binary_symbol_fix_range, -            METH_VARARGS, -            "fix_range($self, range, /)\n--\n\nRefine the location of the current symbol." -        }, -        {              "attach_routine", py_binary_symbol_attach_routine,              METH_VARARGS,              "attach_routine($self, instr, /)\n--\n\nAttach a provided routine to the current symbol."          }, -        { -            "attach_instruction", py_binary_symbol_attach_instruction, -            METH_VARARGS, -            "attach_instruction($self, instr, /)\n--\n\nAttach a provided instruction to the current symbol." -        },          { NULL }      }; @@ -620,14 +420,6 @@ PyTypeObject *get_python_binary_symbol_type(void)              "routine", py_binary_symbol_get_routine, NULL,              "Potential routine attached to the symbol.", NULL          }, -        { -            "instruction", py_binary_symbol_get_instruction, NULL, -            "Potential instruction attached to the symbol.", NULL -        }, -        { -            "comment", py_binary_symbol_get_comment, py_binary_symbol_set_comment, -            "Optional comment linked to the symbol.", NULL -        },          { NULL }      }; diff --git a/plugins/stackvars/stackvars.c b/plugins/stackvars/stackvars.c index 4e07035..ce9d539 100644 --- a/plugins/stackvars/stackvars.c +++ b/plugins/stackvars/stackvars.c @@ -110,7 +110,8 @@ G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginActio      lines = g_loaded_binary_get_lines(binary);      format = g_loaded_binary_get_format(binary); -    routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); +    routines = NULL;//g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); +    routines_count = 0; //      for (i = 0; i < routines_count; i++)          result |= replace_stack_vars_in_routine(routines[i], lines); diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c index 0caf4e4..5b2d231 100644 --- a/src/analysis/decomp/decompiler.c +++ b/src/analysis/decomp/decompiler.c @@ -152,7 +152,8 @@ static void prepare_all_routines_for_decomp(const GLoadedBinary *binary, const c      proc = NULL;//get_arch_processor_from_format(G_EXE_FORMAT(format)); -    routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &count); +    routines = NULL; //g_binary_format_get_routines(G_BIN_FORMAT(format), &count); +    count = 0; diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c index 421cfb6..40cd12b 100644 --- a/src/analysis/disass/output.c +++ b/src/analysis/disass/output.c @@ -89,8 +89,6 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,      BufferLineFlags flags;                  /* Propriétés pour la ligne    */      //mrange_t range;                         /* Couverture sans surface     */ -    GDbComment *_comment;                    /* Commentaire à ajouter       */ - @@ -288,33 +286,21 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,              if (g_binary_symbol_get_target_type(symbols[sym_index]) == STP_ENTRY_POINT)                  flags |= BLF_ENTRYPOINT; -            /* Début d'un groupe bien cohérent avec les alignements ? */ - -            if (g_binary_symbol_is_block_start(symbols[sym_index])) -                flags |= BLF_WIDTH_MANAGER; - -        } - -        g_buffer_cache_append(cache, G_LINE_GENERATOR(instr), flags); - +            /** +             * Début d'un groupe bien cohérent avec les alignements ? +             * +             * On décide que, à partir du moment où il y a un symbole, il y a +             * là le début d'un nouveau bloc avec sa propre nouvelle gestion +             * des largeurs, quelque soit le type du symbole en question ! +             */ - -        ////////////////////////////////// -        if (compared == 0) -        { -            /* Commentaire ? */ - -            _comment = g_binary_symbol_get_comment(symbols[sym_index]); - -            if (_comment != NULL) -                g_db_item_apply(G_DB_ITEM(_comment), binary); +            flags |= BLF_WIDTH_MANAGER;              sym_index++;          } -        /////////////////////////////////////// - +        g_buffer_cache_append(cache, G_LINE_GENERATOR(instr), flags);          /* Commentaire en bout de ligne ? */ diff --git a/src/analysis/routine.c b/src/analysis/routine.c index 583e151..c916c66 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -36,13 +36,14 @@  #include "../arch/raw.h"  #include "../common/extstr.h"  #include "../core/params.h" +#include "../format/symbol-int.h"  /* Représentation générique de routine (instance) */  struct _GBinRoutine  { -    GObject parent;                         /* A laisser en premier        */ +    GBinSymbol parent;                      /* A laisser en premier        */      mrange_t range;                         /* Couverture mémoire          */ @@ -64,7 +65,6 @@ struct _GBinRoutine      GBinVariable **locals;                  /* Variables locales du code   */      size_t locals_count;                    /* Nombre de variables locales */ -    GArchInstruction *instr;                /* Instructions natives        */      GBlockList *blocks;                     /* Blocs basiques d'instruct°  */      //GDecInstruction *dinstr;                /* Instructions décompilées    */ @@ -74,7 +74,7 @@ struct _GBinRoutine  /* Représentation générique de routine (classe) */  struct _GBinRoutineClass  { -    GObjectClass parent;                    /* A laisser en premier        */ +    GBinSymbolClass parent;                 /* A laisser en premier        */  }; @@ -91,7 +91,7 @@ static void g_binary_routine_reset_declarator(GBinRoutine *, bool);  /* Indique le type définit pour une représentation de routine. */ -G_DEFINE_TYPE(GBinRoutine, g_bin_routine, G_TYPE_OBJECT); +G_DEFINE_TYPE(GBinRoutine, g_bin_routine, G_TYPE_BIN_SYMBOL);  /****************************************************************************** @@ -808,48 +808,6 @@ size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *routine, si  *                                                                             *  *  Paramètres  : routine = routine à consulter.                               *  *                                                                             * -*  Description : Fournit les instructions natives correspondantes.            * -*                                                                             * -*  Retour      : Ensemble d'instructions décompilées ou NULL.                 * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GArchInstruction *g_binary_routine_get_instructions(const GBinRoutine *routine) -{ -    return routine->instr; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : routine = routine à mettre à jour.                           * -*                instr   = série d'instructions à conserver.                  * -*                                                                             * -*  Description : Définit les instructions natives de la routine.              * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_binary_routine_set_instructions(GBinRoutine *routine, GArchInstruction *instr) -{ -    if (routine->instr != NULL) -        g_object_unref(G_OBJECT(routine->instr)); - -    routine->instr = instr; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : routine = routine à consulter.                               * -*                                                                             *  *  Description : Fournit les blocs basiques de la routine.                    *  *                                                                             *  *  Retour      : Ensemble de blocs déterminés via les instructions.           * diff --git a/src/analysis/routine.h b/src/analysis/routine.h index e880118..b040c6c 100644 --- a/src/analysis/routine.h +++ b/src/analysis/routine.h @@ -158,12 +158,6 @@ void g_binary_routine_register_if_needed(GBinRoutine *, size_t, bool);  /* Donne l'indice d'une variable dans la liste d'une routine. */  size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *, size_t, bool); -/* Fournit les instructions natives correspondantes. */ -GArchInstruction *g_binary_routine_get_instructions(const GBinRoutine *); - -/* Définit les instructions natives de la routine. */ -void g_binary_routine_set_instructions(GBinRoutine *, GArchInstruction *); -  /* Fournit les blocs basiques de la routine. */  GBlockList *g_binary_routine_get_basic_blocks(const GBinRoutine *); diff --git a/src/format/Makefile.am b/src/format/Makefile.am index 2fef6c6..3501dda 100644 --- a/src/format/Makefile.am +++ b/src/format/Makefile.am @@ -10,6 +10,7 @@ libformat_la_SOURCES =					\  	format.h format.c					\  	preload-int.h						\  	preload.h preload.c					\ +	symbol-int.h						\  	symbol.h symbol.c  libformat_la_LIBADD =					\ diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h new file mode 100644 index 0000000..4a79a65 --- /dev/null +++ b/src/format/symbol-int.h @@ -0,0 +1,60 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * symbol-int.h - prototypes pour la définition interne des symboles dans un binaire + * + * Copyright (C) 2017 Cyrille Bagard + * + *  This file is part of Chrysalide. + * + *  Chrysalide is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  Chrysalide is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _FORMAT_SYMBOL_INT_H +#define _FORMAT_SYMBOL_INT_H + + +#include "symbol.h" + + + +/* Symbole d'exécutable (instance) */ +struct _GBinSymbol +{ +    GObject parent;                         /* A laisser en premier        */ + +    SymbolType type;                        /* Type du symbole             */ + +    char *alt;                              /* Nom alternatif              */ + +    union +    { +        GArchInstruction *instr;            /* Instruction correspondante  */ +        GBinRoutine *routine;               /* Compléments pour fonction   */ + +    } extra; + +}; + +/* Symbole d'exécutable (classe) */ +struct _GBinSymbolClass +{ +    GObjectClass parent;                    /* A laisser en premier        */ + +}; + + + + +#endif  /* _FORMAT_SYMBOL_INT_H */ diff --git a/src/format/symbol.c b/src/format/symbol.c index 16e54ef..2611a40 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -28,6 +28,7 @@  #include <string.h> +#include "symbol-int.h"  #include "../glibext/linegen-int.h" @@ -35,35 +36,6 @@  /* --------------------- FONCTIONNALITES BASIQUES POUR SYMBOLES --------------------- */ -/* Symbole d'exécutable (instance) */ -struct _GBinSymbol -{ -    GObject parent;                         /* A laisser en premier        */ - -    SymbolType type;                        /* Type du symbole             */ - -    bool block_start;                       /* Début d'un bloc ?           */ -    char *alt;                              /* Nom alternatif              */ - -    union -    { -        GArchInstruction *instr;            /* Instruction correspondante  */ -        GBinRoutine *routine;               /* Compléments pour fonction   */ - -    } extra; - -    GDbComment *comment;                    /* Eventuel commentaire lié    */ - -}; - -/* Symbole d'exécutable (classe) */ -struct _GBinSymbolClass -{ -    GObjectClass parent;                    /* A laisser en premier        */ - -}; - -  /* Initialise la classe des symboles d'exécutables. */  static void g_binary_symbol_class_init(GBinSymbolClass *); @@ -334,65 +306,6 @@ SymbolType g_binary_symbol_get_target_type(const GBinSymbol *symbol)  /******************************************************************************  *                                                                             * -*  Paramètres  : symbol = symbole à venir compléter.                          * -*                start  = indication quant à la nature du symbole.            * -*                                                                             * -*  Description : Définit si un symbole est susceptible de démarrer un bloc.   * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_binary_symbol_define_as_block_start(GBinSymbol *symbol, bool start) -{ -    symbol->block_start = start; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : symbol = symbole à venir consulter.                          * -*                                                                             * -*  Description : Indique si un symbole est susceptible de démarrer un bloc.   * -*                                                                             * -*  Retour      : Capacité de rassemblement du symbole.                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_binary_symbol_is_block_start(GBinSymbol *symbol) -{ -    bool result;                            /* Statut à retourner          */ - -    switch (g_binary_symbol_get_target_type(symbol)) -    { -        case STP_ROUTINE: -        case STP_OBJECT: -        case STP_ENTRY_POINT: -        case STP_STRING: -        case STP_RO_STRING: -            result = true; -            break; - -        default: -            result = false; -            break; - -    } - -    result |= symbol->block_start; - -    return result; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : symbol = symbole à venir consulter.                          *  *                                                                             *  *  Description : Fournit un étiquette pour viser un symbole.                  * @@ -459,66 +372,6 @@ void g_binary_symbol_set_alt_label(GBinSymbol *symbol, const char *alt)  /******************************************************************************  *                                                                             * -*  Paramètres  : symbol = symbole à venir mettre à jour.                      * -*                full   = adresse dont la définition est complète.            * -*                                                                             * -*  Description : Raffine la définition de l'emplacement d'un symbole.         * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_binary_symbol_fix_range(GBinSymbol *symbol, const vmpa2t *full) -{ -    GArchInstruction *instr;                /* Instruction associée        */ -    mrange_t range;                         /* Plage à manipuler           */ -    GBinRoutine *routine;                   /* Routine associée            */ - -    switch (symbol->type) -    { -        case STP_DATA: -        case STP_RO_STRING: - -            instr = g_binary_symbol_get_instruction(symbol); - -            copy_mrange(&range, g_arch_instruction_get_range(instr)); - -            assert(cmp_vmpa(get_mrange_addr(&range), full) == 0); - -            copy_vmpa(get_mrange_addr(&range), full); - -            g_arch_instruction_set_range(instr, &range); - -            break; - -        case STP_ROUTINE: -        case STP_ENTRY_POINT: -        case STP_CODE_LABEL: - -            routine = g_binary_symbol_get_routine(symbol); - -            copy_mrange(&range, g_binary_routine_get_range(routine)); - -            assert(cmp_vmpa(get_mrange_addr(&range), full) == 0); - -            copy_vmpa(get_mrange_addr(&range), full); - -            g_binary_routine_set_range(routine, &range); - -            break; - -        default: -            break; - -    } - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : symbol = symbole à venir consulter.                          *  *                                                                             *  *  Description : Fournit l'emplacement où se situe un symbole.                * @@ -675,59 +528,6 @@ GArchInstruction *g_binary_symbol_get_instruction(const GBinSymbol *symbol)  } -/****************************************************************************** -*                                                                             * -*  Paramètres  : symbol  = symbole à venir manipuler.                         * -*                comment = commentaire construit à propos du symbole.         * -*                                                                             * -*  Description : Ajoute un commentaire facultatif au symbole.                 * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_binary_symbol_set_comment(GBinSymbol *symbol, GDbComment *comment) -{ -#ifndef NDEBUG -    const vmpa2t *saddr;                    /* Adresse du symbole          */ -    const vmpa2t *caddr;                    /* Adresse du commentaire      */ -#endif - -#ifndef NDEBUG - -    saddr = get_mrange_addr(g_binary_symbol_get_range(symbol)); -    caddr = g_db_comment_get_address(comment); - -    assert(cmp_vmpa(saddr, caddr) == 0); - -#endif - -    symbol->comment = comment; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : symbol = symbole à venir consulter.                          * -*                                                                             * -*  Description : Fournit l'éventuel commentaire associé au symbole.           * -*                                                                             * -*  Retour      : Instance GLib en place ou NULL si aucune.                    * -*                                                                             * -*  Remarques   : Il n'y a pas de transfert de propriété ici !                 * -*                                                                             * -******************************************************************************/ - -GDbComment *g_binary_symbol_get_comment(const GBinSymbol *symbol) -{ -    return symbol->comment; - -} - -  /* ---------------------------------------------------------------------------------- */  /*                          OFFRE DE CAPACITES DE GENERATION                          */ diff --git a/src/format/symbol.h b/src/format/symbol.h index 694a9ee..0d40529 100644 --- a/src/format/symbol.h +++ b/src/format/symbol.h @@ -89,21 +89,12 @@ int g_binary_symbol_cmp_with_vmpa(const GBinSymbol *, const vmpa2t *);  /* Fournit le type du symbole. */  SymbolType g_binary_symbol_get_target_type(const GBinSymbol *); -/* Définit si un symbole est susceptible de démarrer un bloc. */ -void g_binary_symbol_define_as_block_start(GBinSymbol *, bool); - -/* Indique si un symbole est susceptible de démarrer un bloc. */ -bool g_binary_symbol_is_block_start(GBinSymbol *); -  /* Fournit un étiquette pour viser un symbole. */  const char *g_binary_symbol_get_label(const GBinSymbol *);  /* Définit un autre nom pour le symbole. */  void g_binary_symbol_set_alt_label(GBinSymbol *, const char *); -/* Raffine la définition de l'emplacement d'un symbole. */ -void g_binary_symbol_fix_range(GBinSymbol *, const vmpa2t *); -  /* Fournit l'emplacement où se situe un symbole. */  const mrange_t *g_binary_symbol_get_range(const GBinSymbol *); @@ -122,56 +113,13 @@ GBinRoutine *g_binary_symbol_get_routine(const GBinSymbol *);  /* Fournit l'éventuelle instruction associée au symbole. */  GArchInstruction *g_binary_symbol_get_instruction(const GBinSymbol *); -/* Ajoute un commentaire facultatif au symbole. */ -void g_binary_symbol_set_comment(GBinSymbol *, GDbComment *); - -/* Fournit l'éventuel commentaire associé au symbole. */ -GDbComment *g_binary_symbol_get_comment(const GBinSymbol *); -  /**   * Confort pour l'ajout de symboles basés sur des formats.   */ -#define SET_IMM_DISPLAY(_ins, _op, _idx, _dsp)                                      \ -    do                                                                              \ -    {                                                                               \ -        GImmOperand *_imm;                                                          \ -        _imm = G_IMM_OPERAND(g_arch_instruction_get_operand(_ins, _idx));           \ -        g_imm_operand_set_default_display(&_imm, _dsp, G_SHARE_CONTAINER(_ins));    \ -        _op = G_ARCH_OPERAND(_imm);                                                 \ -    }                                                                               \ -    while (0) - -#define ADD_RAW_AS_SYM(_fmt, _sym, _ins, _cmt, _txt)                        \ -    ({                                                                      \ -        bool __result;                                                      \ -        const vmpa2t *__addr;                                               \ -        __addr = get_mrange_addr(g_arch_instruction_get_range(_ins));       \ -        _cmt = g_db_comment_new_inlined(__addr, BLF_HAS_CODE, false);       \ -        g_db_comment_add_static_text(_cmt, strdup(_txt)); /* ! */           \ -        g_db_item_set_volatile(G_DB_ITEM(_cmt), true);                      \ -        _sym = g_binary_symbol_new(STP_DATA);                               \ -        g_binary_symbol_attach_instruction(_sym, _ins);                     \ -        g_binary_symbol_set_comment(_sym, _cmt);                            \ -        __result = g_binary_format_add_symbol(G_BIN_FORMAT(_fmt), _sym);    \ -        __result;                                                           \ -    }) -#define ADD_RAW_AS_SYM_CST(_fmt, _sym, _ins, _cmt, _txt)                    \ -    ({                                                                      \ -        bool __result;                                                      \ -        const vmpa2t *__addr;                                               \ -        __addr = get_mrange_addr(g_arch_instruction_get_range(_ins));       \ -        _cmt = g_db_comment_new_inlined(__addr, BLF_HAS_CODE, false);       \ -        g_db_comment_add_static_text(_cmt, _txt);                           \ -        g_db_item_set_volatile(G_DB_ITEM(_cmt), true);                      \ -        _sym = g_binary_symbol_new(STP_DATA);                               \ -        g_binary_symbol_attach_instruction(_sym, _ins);                     \ -        g_binary_symbol_set_comment(_sym, _cmt);                            \ -        __result = g_binary_format_add_symbol(G_BIN_FORMAT(_fmt), _sym);    \ -        __result;                                                           \ -    }) +  #define ADD_STR_AS_SYM(_fmt, _sym, _ins)                                    \      ({                                                                      \  | 
