diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-08-25 21:03:25 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-08-25 21:03:25 (GMT) |
commit | 90a79bf4c2c21715e5ef9d8a370928d218c08784 (patch) | |
tree | 57afefc5caa098f4c34ac2d382d085f736245990 /src/arch/raw.c | |
parent | dd51bdbc51abec252ad5169d722a8b6faa53c1ac (diff) |
Loaded lots of ELF header information as symbols.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@393 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/raw.c')
-rw-r--r-- | src/arch/raw.c | 96 |
1 files changed, 95 insertions, 1 deletions
diff --git a/src/arch/raw.c b/src/arch/raw.c index 0d6ae4a..842c2b4 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -37,6 +37,8 @@ struct _GRawInstruction { GArchInstruction parent; /* A laisser en premier */ + bool is_padding; /* Bourrage à représenter ? */ + }; /* Définition générique d'une instruction d'architecture inconnue (classe) */ @@ -59,6 +61,9 @@ static void g_raw_instruction_dispose(GRawInstruction *); /* Procède à la libération totale de la mémoire. */ 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); + /* Fournit le nom humain de l'instruction manipulée. */ static const char *g_raw_instruction_get_keyword(const GRawInstruction *, AsmSyntax); @@ -97,6 +102,7 @@ static void g_raw_instruction_class_init(GRawInstructionClass *klass) instr = G_ARCH_INSTRUCTION_CLASS(klass); + instr->print = (print_instruction_fc)g_raw_instruction_print; instr->get_key = (get_instruction_keyword_fc)g_raw_instruction_get_keyword; } @@ -219,6 +225,54 @@ GArchInstruction *g_raw_instruction_new_array(const bin_t *data, MemoryDataSize /****************************************************************************** * * +* Paramètres : instr = instruction d'assemblage à représenter. * +* buffer = espace où placer ledit contenu. * +* syntax = type de représentation demandée. * +* * +* Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GBufferLine *g_raw_instruction_print(const GRawInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +{ + GBufferLine *result; /* Ligne de destination */ + GArchInstruction *base; /* Autre version de l'instance */ + const char *key; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ + + base = G_ARCH_INSTRUCTION(instr); + + if (!instr->is_padding) + result = G_ARCH_INSTRUCTION_CLASS(g_raw_instruction_parent_class)->print(base, buffer, msize, content, syntax); + + else + { + result = g_code_buffer_append_new_line(buffer, &base->address2); + + g_buffer_line_fill_for_instr(result, msize/* TODO ! */, msize, content, base->length, true); + + /* Instruction proprement dite */ + + key = g_arch_instruction_get_keyword(base, syntax); + klen = strlen(key); + + g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION); + + g_buffer_line_insert_text(result, BLC_ASSEMBLY, "...", 3, RTT_RAW); + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : instr = instruction à traiter. * * format = format du binaire manipulé. * * syntax = type de représentation demandée. * @@ -238,9 +292,49 @@ static const char *g_raw_instruction_get_keyword(const GRawInstruction *instr, A static char *defines[] = { "dn", "db", "dw", "dd", "dq" }; - operand = g_arch_instruction_get_operand(instr, 0); + operand = g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0); size = g_imm_operand_get_size(G_IMM_OPERAND(operand)); return defines[MDS_RANGE(size)]; } + + +/****************************************************************************** +* * +* Paramètres : instr = instruction à traiter. * +* is_padding = nouveau statut à associer au contenu. * +* * +* Description : Marque l'instruction comme ne contenant que du bourrage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_raw_instruction_mark_as_padding(GRawInstruction *instr, bool is_padding) +{ + instr->is_padding = is_padding; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction à traiter. * +* is_padding = nouveau statut à associer au contenu. * +* * +* Description : Indique si le contenu de l'instruction est du bourrage. * +* * +* Retour : Statut du contenu de l'instruction. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_raw_instruction_is_padding(const GRawInstruction *instr) +{ + return instr->is_padding; + +} |