radare2/libr/asm/p/asm_arm_winedbg.c
Damien Zammit af0a865d9f WIP - Totally remove host endianness dependence
- Adds endian aware functions
- Removes references to host endian
- Uses binary detected endianness else tries LE and restricts by RAsmPlugin
- Fixes gdb debugger endianness when debugging BE qemu gdbserver

Signed-off-by: Damien Zammit <damien@zamaudio.com>
2016-05-04 23:42:17 +10:00

47 lines
1.2 KiB
C

/* radare - LGPL - Copyright 2009-2014 - nibble */
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <r_types.h>
#include <r_util.h>
#include <r_lib.h>
#include <r_asm.h>
#include "../arch/arm/winedbg/be_arm.h"
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
ut8 buf2[4];
struct winedbg_arm_insn *arminsn = arm_new();
arm_set_pc (arminsn, a->pc);
arm_set_thumb (arminsn, a->bits == 16);
if (a->big_endian && a->bits == 32) {
r_mem_swapendian (buf2, buf, 4);
arm_set_input_buffer (arminsn, buf2);
} else {
arm_set_input_buffer (arminsn, buf);
}
op->size = arm_disasm_one_insn (arminsn);
strncpy (op->buf_asm, winedbg_arm_insn_asm (arminsn), R_ASM_BUFSIZE-1);
strncpy (op->buf_hex, winedbg_arm_insn_hex (arminsn), R_ASM_BUFSIZE-1);
arm_free (arminsn);
return op->size;
}
RAsmPlugin r_asm_plugin_arm_winedbg = {
.name = "arm.winedbg",
.arch = "arm",
.bits = 16|32,
.endian = R_SYS_ENDIAN_LITTLE | R_SYS_ENDIAN_BIG,
.desc = "WineDBG's ARM disassembler",
.disassemble = &disassemble,
.license = "LGPL2"
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_arm_winedbg,
.version = R2_VERSION
};
#endif