summaryrefslogtreecommitdiff
path: root/src/arch/x86
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86')
-rw-r--r--src/arch/x86/processor.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/arch/x86/processor.c b/src/arch/x86/processor.c
index 4326294..7243064 100644
--- a/src/arch/x86/processor.c
+++ b/src/arch/x86/processor.c
@@ -106,7 +106,7 @@ void x86_register_instructions(asm_x86_processor *);
asm_instr *x86_fetch_instruction(const asm_x86_processor *, const uint8_t *, off_t *, off_t, uint64_t);
/* Traduit une instruction en version humainement lisible. */
-void x86_print_instruction(const asm_x86_processor *, const asm_x86_instr *, char *, size_t, AsmSyntax);
+void x86_print_instruction(const asm_x86_processor *, const exe_format *, const asm_x86_instr *, char *, size_t, AsmSyntax);
@@ -356,6 +356,7 @@ asm_instr *x86_fetch_instruction(const asm_x86_processor *proc, const uint8_t *d
/******************************************************************************
* *
* Paramètres : proc = architecture visée par la procédure. *
+* format = format du binaire manipulé. *
* instr = instruction à traiter. *
* buffer = tampon de sortie mis à disposition. [OUT] *
* len = taille de ce tampon. *
@@ -369,10 +370,14 @@ asm_instr *x86_fetch_instruction(const asm_x86_processor *proc, const uint8_t *d
* *
******************************************************************************/
-void x86_print_instruction(const asm_x86_processor *proc, const asm_x86_instr *instr, char *buffer, size_t len, AsmSyntax syntax)
+void x86_print_instruction(const asm_x86_processor *proc, const exe_format *format, const asm_x86_instr *instr, char *buffer, size_t len, AsmSyntax syntax)
{
size_t i; /* Boucle de parcours */
- char opbuffer[3][64]; /* Tampon pour les textes */
+ char opbuffer[3][256]; /* Tampon pour les textes */
+ char *label; /* Etiquette de symbole */
+ SymbolType symtype; /* Type de symbole */
+ uint64_t offset; /* Décallage final constaté */
+ size_t oplen; /* Taille de description */
/* Impression des opérandes */
@@ -380,18 +385,33 @@ void x86_print_instruction(const asm_x86_processor *proc, const asm_x86_instr *i
switch (ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i])->type)
{
case AOT_NONE:
- print_db_operand(ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i]), opbuffer[i], 64, syntax);
+ print_db_operand(ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i]), opbuffer[i], 256, syntax);
break;
case AOT_IMM:
- print_imm_operand(ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i]), opbuffer[i], 64, syntax);
+ print_imm_operand(ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i]), opbuffer[i], 256, syntax);
+
+ offset = ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i])->value.val32; /* FIXME !!! */
+
+ if (ASM_OPERAND(ASM_INSTRUCTION(instr)->operands[i])->size == proc->operand_size
+ && resolve_exe_symbol(format, &label, &symtype, &offset))
+ {
+ oplen = strlen(opbuffer[i]);
+
+ if (offset == 0) snprintf(&opbuffer[i][oplen], 256 - oplen, " <%s>", label);
+ else snprintf(&opbuffer[i][oplen], 256 - oplen, " <%s+0x%llx>", label, offset);
+
+ free(label);
+
+ }
+
break;
case AOT_REG:
- x86_print_reg_operand(ASM_INSTRUCTION(instr)->operands[i], opbuffer[i], 64, syntax);
+ x86_print_reg_operand(ASM_INSTRUCTION(instr)->operands[i], opbuffer[i], 256, syntax);
break;
case AOT_MEM:
break;
case AOT_MOFFS:
- x86_print_moffs_operand(ASM_INSTRUCTION(instr)->operands[i], opbuffer[i], 64, syntax);
+ x86_print_moffs_operand(ASM_INSTRUCTION(instr)->operands[i], opbuffer[i], 256, syntax);
break;
}