diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-11-10 01:28:23 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-11-10 01:28:23 (GMT) |
commit | 12b4201890b4b2eefffaa6615b4b3076253dff6f (patch) | |
tree | 3756393810dc392658de2e05fc2589cbd119b2a8 /src/arch | |
parent | 7c7109c1a8aaedea40af4b96d4b81d6ba4496226 (diff) |
Shown/hidden virtual addresses / binary code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@41 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/instruction-int.h | 3 | ||||
-rw-r--r-- | src/arch/instruction.c | 21 | ||||
-rw-r--r-- | src/arch/instruction.h | 2 | ||||
-rw-r--r-- | src/arch/processor.c | 4 | ||||
-rw-r--r-- | src/arch/processor.h | 2 |
5 files changed, 30 insertions, 2 deletions
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index 895c29f..32c8c8c 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -65,6 +65,9 @@ struct _asm_instr uint64_t vaddress; /* Adresse virtuelle associée */ + off_t offset; /* Position physique de départ */ + off_t length; /* Taille de l'instruction */ + AsmInstrType type; /* Type d'instruction */ asm_operand **operands; /* Liste des opérandes */ diff --git a/src/arch/instruction.c b/src/arch/instruction.c index ada3d58..a03ced4 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -66,3 +66,24 @@ asm_instr *create_db_instruction(const uint8_t *data, off_t *pos, off_t len) } + +/****************************************************************************** +* * +* Paramètres : instr = instruction quelconque à traiter. * +* offset = position physique dans le code binaire / NULL. [OUT]* +* length = taille de l'instruction ou NULL. [OUT] * +* * +* Description : Indique la position et/ou la taille d'une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void get_asm_instr_offset_and_length(const asm_instr *instr, off_t *offset, off_t *length) +{ + if (offset != NULL) *offset = instr->offset; + if (length != NULL) *length = instr->length; + +} diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 19cc6ab..6af865b 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -38,6 +38,8 @@ typedef struct _asm_instr asm_instr; /* Crée une instruction de type 'db' à partir de données. */ asm_instr *create_db_instruction(const uint8_t *, off_t *, off_t); +/* Indique la position et/ou la taille d'une instruction. */ +void get_asm_instr_offset_and_length(const asm_instr *, off_t *, off_t *); diff --git a/src/arch/processor.c b/src/arch/processor.c index 17f88b3..71cdfba 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -52,7 +52,7 @@ * * ******************************************************************************/ -asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, off_t *pos, off_t len, uint64_t offset) +asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, off_t *pos, off_t len, off_t off, uint64_t offset) { asm_instr *result; /* Représentation à renvoyer */ @@ -79,6 +79,8 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of result->vaddress = offset; + result->offset = off + old_pos; + result->length = *pos - old_pos; return result; diff --git a/src/arch/processor.h b/src/arch/processor.h index 287a761..7fc1023 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -40,7 +40,7 @@ typedef struct _asm_processor asm_processor; /* Décode une instruction dans un flux de données. */ -asm_instr *decode_instruction(const asm_processor *, const uint8_t *, off_t *, off_t, uint64_t); +asm_instr *decode_instruction(const asm_processor *, const uint8_t *, off_t *, off_t, off_t, uint64_t); /* Traduit une instruction en version humainement lisible. */ void print_hinstruction(const asm_processor *, const exe_format *, const asm_instr *, char *, size_t, AsmSyntax); |