diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2015-07-24 18:43:55 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2015-07-24 18:43:55 (GMT) | 
| commit | 156d2e2f6beda2302552ac79678494d914fda05b (patch) | |
| tree | 021825960b7ac3315a336fc085a4f1d07c05df39 /src/arch | |
| parent | 21537636cd8318cf5a720211619ad3c3023b52e9 (diff) | |
Replaced all remaining raw accesses to binary contents with the GBinContent wrapper in binary formats.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@555 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/arm/v7/fetch.c | 21 | ||||
| -rw-r--r-- | src/arch/immediate.c | 4 | ||||
| -rw-r--r-- | src/arch/instruction-int.h | 4 | ||||
| -rw-r--r-- | src/arch/instruction.c | 21 | ||||
| -rw-r--r-- | src/arch/instruction.h | 2 | ||||
| -rw-r--r-- | src/arch/raw.c | 8 | 
6 files changed, 28 insertions, 32 deletions
| diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c index 246d136..73cec6d 100644 --- a/src/arch/arm/v7/fetch.c +++ b/src/arch/arm/v7/fetch.c @@ -373,9 +373,9 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst      bool ret;                               /* Bilan d'une récupération    */      off_t val_offset;                       /* Position de valeur à lire   */      vmpa2t sym_addr;                        /* Adresse de nouveau symbole  */ -    off_t length;                           /* Taille des données à lire   */ -    const bin_t *data;                      /* Données binaires à lire     */ +    GBinContent *content;                   /* Contenu binaire à relire    */      uint32_t target;                        /* Adresse virtuelle visée     */ +    vmpa2t pos;                             /* Tête de lecture de valeur   */      mrange_t sym_range;                     /* Espace du nouveau symbole   */      VMPA_BUFFER(loc);                       /* Adresse au format texte     */      size_t name_len;                        /* Taille de nomination finale */ @@ -441,22 +441,15 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst      /* Lecture de la valeur vers laquelle renvoyer */ -    data = g_binary_format_get_content(format, &length); +    content = g_binary_format_get_content(format); +    copy_vmpa(&pos, &sym_addr); -    printf(">>>>>>> @reading @ 0x%08x (0x%x)\n", (unsigned int)val_offset, offset); +    ret = g_binary_content_read_u32(content, &pos, SRE_LITTLE /* FIXME */, &target); +    g_object_unref(G_OBJECT(content)); - -    ret = read_u32(&target, data, &val_offset, length, SRE_LITTLE /* FIXME */);      if (!ret) return; - -    printf(">>>>>>> @got target :: 0x%08x\n", (unsigned int)target); - - - - -      /* Réalise l'intégration du symbole associé */      sym_instr = g_raw_instruction_new_from_value(&sym_addr, MDS_32_BITS_UNSIGNED, target); @@ -506,7 +499,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst      //g_imm_operand_set_value(G_IMM_OPERAND(sub_op), MDS_32_BITS_UNSIGNED, target); - +    /// FIXME ?!      if (target < 0x8000) return; diff --git a/src/arch/immediate.c b/src/arch/immediate.c index fc8e40d..c21239e 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -354,7 +354,7 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten              break;          case MDS_8_BITS_UNSIGNED: -            if (!g_binary_content_read_u8(content, addr, endian, &uval8)) +            if (!g_binary_content_read_u8(content, addr, &uval8))                  goto gionfd_error;              result->raw = uval8;              break; @@ -384,7 +384,7 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten              break;          case MDS_8_BITS_SIGNED: -            if (!g_binary_content_read_s8(content, addr, endian, &sval8)) +            if (!g_binary_content_read_s8(content, addr, &sval8))                  goto gionfd_error;              result->raw = sval8;              break; diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index bb45f72..6b2b5c7 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -36,7 +36,7 @@  typedef void (* get_instruction_rw_regs_fc) (const GArchInstruction *, GArchRegister ***, size_t *, GArchRegister ***, size_t *);  /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -typedef GBufferLine * (* print_instruction_fc) (const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +typedef GBufferLine * (* print_instruction_fc) (const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const GBinContent *, AsmSyntax);  /* Reconstruit le cache complet d'une désignation d'instruction. */  typedef void (* build_instruction_keyword_fc) (const GArchInstruction *, AsmSyntax); @@ -64,7 +64,7 @@ struct _GArchInstruction      vmpa2t address2;                         /* Position associée           */      off_t offset;                           /* Position physique de départ */ -    off_t length;                           /* Taille de l'instruction     */ +    //off_t length;                           /* Taille de l'instruction     */      vmpa_t address;                         /* Position associée           */ diff --git a/src/arch/instruction.c b/src/arch/instruction.c index d6bf183..d9d7693 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -52,7 +52,7 @@ static void g_arch_instruction_finalize(GArchInstruction *);  /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static GBufferLine *_g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +static GBufferLine *_g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const GBinContent *, AsmSyntax); @@ -317,7 +317,7 @@ const mrange_t *g_arch_instruction_get_range(const GArchInstruction *instr)  void g_arch_instruction_get_location(const GArchInstruction *instr, off_t *offset, off_t *length, vmpa_t *address)  {      if (offset != NULL) *offset = instr->offset; -    if (length != NULL) *length = instr->length; +    //if (length != NULL) *length = instr->length;      if (address != NULL) *address = instr->address; @@ -833,10 +833,11 @@ const char *g_arch_instruction_get_keyword(const GArchInstruction *instr, AsmSyn  /******************************************************************************  *                                                                             * -*  Paramètres  : instr  = instruction d'assemblage à représenter.             * -*                buffer = espace où placer ledit contenu.                     * -*                msize  = taille idéale des positions et adresses;            * -*                syntax = type de représentation demandée.                    * +*  Paramètres  : instr   = instruction d'assemblage à représenter.            * +*                buffer  = espace où placer ledit contenu.                    * +*                msize   = taille idéale des positions et adresses;           * +*                content = contenu binaire global à venir lire.               * +*                syntax  = type de représentation demandée.                   *  *                                                                             *  *  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  *  *                                                                             * @@ -846,7 +847,7 @@ const char *g_arch_instruction_get_keyword(const GArchInstruction *instr, AsmSyn  *                                                                             *  ******************************************************************************/ -static GBufferLine *_g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +static GBufferLine *_g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const GBinContent *content, AsmSyntax syntax)  {      GBufferLine *result;                    /* Ligne de destination        */      const char *key;                        /* Mot clef principal          */ @@ -857,8 +858,7 @@ static GBufferLine *_g_arch_instruction_print(const GArchInstruction *instr, GCo      g_buffer_line_add_flag(result, BLF_HAS_CODE); -    g_buffer_line_fill_for_instr(result, msize/* TODO ! */, msize, -                                 content, get_mrange_length(&instr->range), true); +    g_buffer_line_fill_for_instr(result, msize/* TODO ! */, msize, content, true);      /* Instruction proprement dite */ @@ -892,6 +892,7 @@ static GBufferLine *_g_arch_instruction_print(const GArchInstruction *instr, GCo  *  Paramètres  : instr  = instruction d'assemblage à représenter.             *  *                buffer = espace où placer ledit contenu.                     *  *                msize  = taille idéale des positions et adresses;            * +*                content = contenu binaire global à venir lire.               *  *                syntax = type de représentation demandée.                    *  *                                                                             *  *  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * @@ -902,7 +903,7 @@ static GBufferLine *_g_arch_instruction_print(const GArchInstruction *instr, GCo  *                                                                             *  ******************************************************************************/ -GBufferLine *g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +GBufferLine *g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const GBinContent *content, AsmSyntax syntax)  {      return G_ARCH_INSTRUCTION_GET_CLASS(instr)->print(instr, buffer, msize, content, syntax); diff --git a/src/arch/instruction.h b/src/arch/instruction.h index a4ea1b5..b3a272f 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -213,7 +213,7 @@ size_t g_arch_instruction_compute_group_index(GArchInstruction **, GArchInstruct  const char *g_arch_instruction_get_keyword(const GArchInstruction *, AsmSyntax);  /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -GBufferLine *g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +GBufferLine *g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const GBinContent *, AsmSyntax);  /* Décompile une instruction de façon générique. */  GDecInstruction *g_arch_instruction_decompile(const GArchInstruction *, GDecContext *); diff --git a/src/arch/raw.c b/src/arch/raw.c index cf990f0..41f46c1 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -69,7 +69,7 @@ static void g_raw_instruction_dispose(GRawInstruction *);  static void g_raw_instruction_finalize(GRawInstruction *);  /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static GBufferLine *g_raw_instruction_print(const GRawInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +static GBufferLine *g_raw_instruction_print(const GRawInstruction *, GCodeBuffer *, MemoryDataSize, const GBinContent *, AsmSyntax);  /* Reconstruit le cache complet d'une désignation d'instruction. */  static void g_raw_instruction_build_keyword(const GRawInstruction *, AsmSyntax); @@ -358,6 +358,8 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory  *                                                                             *  *  Paramètres  : instr  = instruction d'assemblage à représenter.             *  *                buffer = espace où placer ledit contenu.                     * +*                msize   = taille idéale des positions et adresses;           * +*                content = contenu binaire global à venir lire.               *  *                syntax = type de représentation demandée.                    *  *                                                                             *  *  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * @@ -368,7 +370,7 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory  *                                                                             *  ******************************************************************************/ -static GBufferLine *g_raw_instruction_print(const GRawInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +static GBufferLine *g_raw_instruction_print(const GRawInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const GBinContent *content, AsmSyntax syntax)  {      GBufferLine *result;                    /* Ligne de destination        */      GArchInstruction *base;                 /* Autre version de l'instance */ @@ -392,7 +394,7 @@ static GBufferLine *g_raw_instruction_print(const GRawInstruction *instr, GCodeB          g_buffer_line_add_flag(result, BLF_HAS_CODE); -        g_buffer_line_fill_for_instr(result, msize/* TODO ! */, msize, content, base->length, true); +        g_buffer_line_fill_mrange(result, msize/* TODO ! */, msize);          /* Instruction proprement dite */ | 
