32x: drc: finish MAC, gen drc entry/exit (for statically alloced regs)
[libpicofe.git] / linux / host_dasm.c
index 38a7e47..d2d6d0a 100644 (file)
@@ -11,6 +11,16 @@ extern char **g_argv;
 
 static struct disassemble_info di;
 
+#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 print_insn_func print_insn_i386_intel
+#define BFD_ARCH bfd_arch_i386
+#define BFD_MACH bfd_mach_i386_i386_intel_syntax
+#endif
+
 /* symbols */
 static asymbol **symbols;
 static long symcount;
@@ -27,7 +37,7 @@ remove_useless_symbols (asymbol **symbols, long count)
     {
       asymbol *sym = *in_ptr++;
 
-      if (sym->name == NULL || sym->name[0] == '\0')
+      if (sym->name == NULL || sym->name[0] == '\0' || sym->name[0] == '$')
         continue;
       if (sym->flags & (BSF_DEBUGGING | BSF_SECTION_SYM))
         continue;
@@ -43,6 +53,7 @@ remove_useless_symbols (asymbol **symbols, long count)
 */
       *out_ptr++ = sym;
     }
+
   return out_ptr - symbols;
 }
 
@@ -133,6 +144,7 @@ static int insn_printf(void *f, const char *format, ...)
 
 static void host_dasm_init(void)
 {
+  bfd_init();
   slurp_symtab(g_argv[0]);
 
   init_disassemble_info(&di, NULL, insn_printf);
@@ -141,8 +153,8 @@ static void host_dasm_init(void)
   di.print_address_func = dis_asm_print_address;
 //  di.symbol_at_address_func = dis_asm_symbol_at_address;
   di.read_memory_func = dis_asm_read_memory;
-  di.arch = bfd_arch_i386;
-  di.mach = bfd_mach_i386_i386_intel_syntax;
+  di.arch = BFD_ARCH;
+  di.mach = BFD_MACH;
   di.endian = BFD_ENDIAN_LITTLE;
   disassemble_init_for_target(&di);
 }
@@ -159,8 +171,8 @@ void host_dasm(void *addr, int len)
 
   vma_end = vma + len;
   while (vma < vma_end) {
-    printf("  %p ", (void *)(long)vma);
-    vma += print_insn_i386_intel(vma, &di);
+    printf("      %p ", (void *)(long)vma);
+    vma += print_insn_func(vma, &di);
     printf("\n");
   }
 }