Search
lxdream.org :: lxdream/src/x86dasm/x86dasm.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/x86dasm/x86dasm.c
changeset 429:e581b90c3fb3
prev376:8c7587af5a5d
next480:d28c2992f5ee
author nkeynes
date Mon Oct 08 11:52:13 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Fix compilation warnings
file annotate diff log raw
1.1 --- a/src/x86dasm/x86dasm.c Wed Sep 12 09:16:47 2007 +0000
1.2 +++ b/src/x86dasm/x86dasm.c Mon Oct 08 11:52:13 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: x86dasm.c,v 1.3 2007-09-12 09:16:47 nkeynes Exp $
1.6 + * $Id: x86dasm.c,v 1.4 2007-10-08 11:48:10 nkeynes Exp $
1.7 *
1.8 * Wrapper around i386-dis to supply the same behaviour as the other
1.9 * disassembly functions.
1.10 @@ -31,9 +31,7 @@
1.11 &sh4r.pc };
1.12
1.13 static int x86_disasm_output( void *data, const char *format, ... );
1.14 -static int x86_read_memory( bfd_vma memaddr, bfd_byte *buffer, unsigned int length,
1.15 - struct disassemble_info *info );
1.16 -static int x86_print_address( bfd_vma memaddr, struct disassemble_info *info );
1.17 +static void x86_print_address( bfd_vma memaddr, struct disassemble_info *info );
1.18
1.19 static struct disassemble_info x86_disasm_info;
1.20
1.21 @@ -54,7 +52,7 @@
1.22 }
1.23 }
1.24
1.25 -void x86_disasm_init(char *buf, uint32_t vma, int buflen)
1.26 +void x86_disasm_init(unsigned char *buf, uint32_t vma, int buflen)
1.27 {
1.28 init_disassemble_info( &x86_disasm_info, NULL, x86_disasm_output );
1.29 x86_disasm_info.arch = bfd_arch_i386;
1.30 @@ -76,21 +74,20 @@
1.31 {
1.32 int i;
1.33 for( i=0; i<x86_num_symbols; i++ ) {
1.34 - if( x86_symtab[i].ptr == (void *)memaddr ) {
1.35 + if( x86_symtab[i].ptr == (void *)(uint32_t)memaddr ) {
1.36 return x86_symtab[i].name;
1.37 }
1.38 }
1.39 return NULL;
1.40 }
1.41
1.42 -static int x86_print_address( bfd_vma memaddr, struct disassemble_info *info )
1.43 +static void x86_print_address( bfd_vma memaddr, struct disassemble_info *info )
1.44 {
1.45 const char *sym = x86_find_symbol(memaddr, info);
1.46 info->fprintf_func( info->stream, "%08X", memaddr );
1.47 if( sym != NULL ) {
1.48 info->fprintf_func( info->stream, " <%s>", sym );
1.49 }
1.50 - return 0;
1.51 }
1.52
1.53 uint32_t x86_disasm_instruction( uint32_t pc, char *buf, int len, char *opcode )
1.54 @@ -101,7 +98,7 @@
1.55 buf[0] = 0;
1.56 count = print_insn_i386_att( pc, &x86_disasm_info );
1.57 if( count != 0 ) {
1.58 - char tmp[count];
1.59 + unsigned char tmp[count];
1.60 x86_disasm_info.read_memory_func( pc, tmp, count, &x86_disasm_info );
1.61 for( i=0; i<count; i++ ) {
1.62 sprintf( opcode, "%02X ", ((unsigned int)tmp[i])&0xFF );
.