X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fhost_dasm.c;h=66a83ea9ff95548c5f173b1593a977d9ffbae1e3;hb=21082d0b2b9910727770674cef9b68b9e97a3155;hp=cd2db694cca386b6a9df57740f3bd0cc8193010c;hpb=e8fc349e7136741eeb504eaefacf3cb333ea9397;p=libpicofe.git diff --git a/linux/host_dasm.c b/linux/host_dasm.c index cd2db69..66a83ea 100644 --- a/linux/host_dasm.c +++ b/linux/host_dasm.c @@ -1,3 +1,14 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2009-2010 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * - MAME license. + * See the COPYING file in the top-level directory. + */ + #include #include #include @@ -11,15 +22,23 @@ extern char **g_argv; static struct disassemble_info di; -#ifdef ARM +#ifdef __arm__ #define print_insn_func print_insn_little_arm #define BFD_ARCH bfd_arch_arm -#define BFD_MACH bfd_mach_arm_4T -#else +#define BFD_MACH bfd_mach_arm_unknown +#define DASM_OPTS "reg-names-std" +#elif defined(__x86_64__) || defined(__i386__) #define print_insn_func print_insn_i386_intel #define BFD_ARCH bfd_arch_i386 +#ifdef __x86_64__ +#define BFD_MACH bfd_mach_x86_64_intel_syntax +#else #define BFD_MACH bfd_mach_i386_i386_intel_syntax #endif +#define DASM_OPTS NULL +#else +#error "missing arch support" +#endif /* symbols */ static asymbol **symbols; @@ -121,7 +140,7 @@ static int dis_asm_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int len, struct disassemble_info *info) { - memcpy(myaddr, (void *)(int)memaddr, len); + memcpy(myaddr, (void *)(long)memaddr, len); return 0; } @@ -129,7 +148,7 @@ static void dis_asm_memory_error(int status, bfd_vma memaddr, struct disassemble_info *info) { - fprintf(stderr, "memory_error %p\n", (void *)(int)memaddr); + fprintf(stderr, "memory_error %p\n", (void *)(long)memaddr); } static void @@ -170,6 +189,7 @@ static void host_dasm_init(void) di.arch = BFD_ARCH; di.mach = BFD_MACH; di.endian = BFD_ENDIAN_LITTLE; + di.disassembler_options = DASM_OPTS; disassemble_init_for_target(&di); init_done = 1; } @@ -188,7 +208,7 @@ void host_dasm(void *addr, int len) if (name != NULL) printf("%s:\n", name); - printf(" %p ", (void *)(long)vma); + printf(" %08lx ", (long)vma); vma += print_insn_func(vma, &di); printf("\n"); }