Пример #1
0
static int disassemble(struct r_asm_t *a, struct r_asm_op_t *op, const ut8 *buf, ut64 len) {
	static struct disassemble_info disasm_obj;
	if (len<4)
		return -1;
	buf_global = op->buf_asm;
	Offset = a->pc;
	memcpy (bytes, buf, 4); // TODO handle thumb

	/* prepare disassembler */
	memset (&disasm_obj, '\0', sizeof (struct disassemble_info));
	disasm_obj.disassembler_options=(a->bits==64)?"64":"";
	disasm_obj.buffer = bytes;
	disasm_obj.read_memory_func = &ppc_buffer_read_memory;
	disasm_obj.symbol_at_address_func = &symbol_at_address;
	disasm_obj.memory_error_func = &memory_error_func;
	disasm_obj.print_address_func = &print_address;
	disasm_obj.endian = !a->big_endian;
	disasm_obj.fprintf_func = &buf_fprintf;
	disasm_obj.stream = stdout;

	op->buf_asm[0]='\0';
	if (a->big_endian)
		op->inst_len = print_insn_big_powerpc((bfd_vma)Offset, &disasm_obj);
	else op->inst_len = print_insn_little_powerpc((bfd_vma)Offset, &disasm_obj);

	if (op->inst_len == -1)
		strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);

	return op->inst_len;
}
Пример #2
0
int j3::JeiModule::disassemble(unsigned int *addr)
{
  
  if (!initialised)
    {   
      INIT_DISASSEMBLE_INFO(info, stdout, fprintf);
      info.flavour=   bfd_target_elf_flavour;
      info.arch=    bfd_arch_powerpc;
      info.mach=    bfd_mach_ppc_750; // generic(ish) == PPC G3
      info.endian=    BFD_ENDIAN_BIG;
      info.buffer_length= 65536;
    }   
  info.buffer=     (bfd_byte *)addr;
  info.buffer_vma= (bfd_vma)(long)addr;
  return print_insn_big_powerpc((bfd_vma)(long)addr, &info);
  
}
Пример #3
0
u1 *disassinstr(u1 *code)
{
	if (!disass_initialized) {
		INIT_DISASSEMBLE_INFO(info, NULL, disass_printf);

		/* setting the struct members must be done after
		   INIT_DISASSEMBLE_INFO */

		info.read_memory_func = &disass_buffer_read_memory;

		disass_initialized = true;
	}

	printf("0x%016lx:   %08x    ", (s8) code, *((s4 *) code));

	print_insn_big_powerpc((bfd_vma) code, &info);

	printf("\n");

	return code + 4;
}