7 #include <capstone/capstone.h>
8 #include "../arch/arm/asm-arm.h"
9 #include "../arch/arm/arm_it.h"
24 if (!insn || !insn->detail) {
27 for (
i = 0;
i < insn->detail->groups_count;
i++) {
28 int id = insn->detail->groups[
i];
44 if (!strstr(
a->features,
name)) {
89 bool disp_hash =
a->immdisp;
94 bool thumb =
a->bits == 16;
101 ctx->obits =
a->bits;
105 if (strstr(
a->cpu,
"cortex")) {
109 if (strstr(
a->cpu,
"v8")) {
114 if (
a->features &&
a->bits != 64) {
115 if (strstr(
a->features,
"v8")) {
142 if (n < 1 || insn->
size < 1) {
149 if (
a->features && *
a->features) {
151 op->size = insn->size;
155 if (
op && !
op->size) {
156 op->size = insn->size;
165 cc_name(insn->detail->arm.cc));
169 char *buf_asm =
sdb_fmt(
"%s%s%s",
171 insn->op_str[0] ?
" " :
"",
200 if (
a->bits != 32 &&
a->bits != 16) {
201 RZ_LOG_ERROR(
"assembler: arm: cannot assemble instruction due invalid 'asm.bits' value (accepted only 16 or 32 bits).\n");
210 const int o = opcode >> 16;
211 opsize = o > 0 ? 4 : 2;
219 }
else if (opsize == 2) {
300 .desc =
"Capstone ARM disassembler",
301 .cpus =
"v8,cortex,arm1176,cortexA72,cortexA8",
302 .platforms =
"bcm2835,omap3430",
306 .bits = 16 | 32 | 64,
315 "crypto,databarrier,divide,fparmv8,multpro,neon,t2extractpack,"
316 "thumb2dsp,trustzone,v4t,v5t,v5te,v6,v6t2,v7,v8,vfp2,vfp3,vfp4,"
317 "arm,mclass,notmclass,thumb,thumb1only,thumb2,prev8,fpvmlx,"
318 "mulops,crc,dpvfp,v6m"
322 #ifndef RZ_PLUGIN_INCORE
RZ_API void rz_arm_it_context_fini(RzArmITContext *ctx)
RZ_API void rz_arm_it_context_init(RzArmITContext *ctx)
RZ_API void rz_arm_it_update_nonblock(RzArmITContext *ctx, cs_insn *insn)
RZ_API bool rz_arm_it_apply_cond(RzArmITContext *ctx, cs_insn *insn)
RZ_API void rz_arm_it_update_block(RzArmITContext *ctx, cs_insn *insn)
ut32 armass_assemble(const char *str, ut64 off, int thumb)
static bool arm_init(void **user)
static const char * cc_name(arm_cc cc)
static bool check_features(RzAsm *a, cs_insn *insn)
bool arm64ass(const char *str, ut64 addr, ut32 *op)
struct arm_cs_context_t ArmCSContext
RZ_API RzLibStruct rizin_plugin
RzAsmPlugin rz_asm_plugin_arm_cs
static char * mnemonics(RzAsm *a, int id, bool json)
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
static bool arm_fini(void *user)
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
arm_cc
ARM condition code.
@ ARM_CC_GT
Greater than Greater than.
@ ARM_CC_LE
Less than or equal <, ==, or unordered.
@ ARM_CC_HI
Unsigned higher Greater than, or unordered.
@ ARM_CC_VC
No overflow Not unordered.
@ ARM_CC_LS
Unsigned lower or same Less than or equal.
@ ARM_CC_GE
Greater than or equal Greater than or equal.
@ ARM_CC_VS
Overflow Unordered.
@ ARM_CC_PL
Plus, positive or zero >, ==, or unordered.
@ ARM_CC_NE
Not equal Not equal, or unordered.
@ ARM_CC_LO
Carry clear Less than.
@ ARM_CC_LT
Less than Less than, or unordered.
@ ARM_CC_HS
Carry set >, ==, or unordered.
@ ARM_CC_MI
Minus, negative Less than.
@ CS_ARCH_ARM64
ARM-64, also called AArch64.
@ CS_ARCH_ARM
ARM architecture (including Thumb, Thumb-2)
@ CS_MODE_MCLASS
ARM's Cortex-M series.
@ CS_MODE_V8
ARMv8 A32 encodings for ARM.
@ CS_MODE_BIG_ENDIAN
big-endian mode
@ CS_MODE_THUMB
ARM's Thumb mode, including Thumb-2.
@ CS_MODE_LITTLE_ENDIAN
little-endian mode (default mode)
@ CS_OPT_DETAIL
Break down instruction structure into details.
@ CS_OPT_SYNTAX
Assembly output syntax.
@ CS_OPT_SYNTAX_NOREGNAME
Prints register name with only number (CS_OPT_SYNTAX)
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
@ CS_OPT_OFF
Turn OFF an option - default for CS_OPT_DETAIL, CS_OPT_SKIPDATA, CS_OPT_UNSIGNED.
@ CS_OPT_SYNTAX_DEFAULT
Default asm syntax (CS_OPT_SYNTAX).
CAPSTONE_EXPORT size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn **insn)
CAPSTONE_EXPORT const char *CAPSTONE_API cs_group_name(csh ud, unsigned int group)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
CAPSTONE_EXPORT const char *CAPSTONE_API cs_insn_name(csh ud, unsigned int insn)
CAPSTONE_EXPORT void CAPSTONE_API cs_free(cs_insn *insn, size_t count)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close(csh *handle)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
RZ_API char * sdb_fmt(const char *fmt,...)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static bool is_thumb(RzBinFile *bf)
#define rz_return_val_if_fail(expr, val)
static void rz_write_le32(void *dest, ut32 val)
static void rz_write_le16(void *dest, ut16 val)
static void rz_write_be16(void *dest, ut16 val)
static void rz_write_be32(void *dest, ut32 val)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API int rz_str_replace_char(char *s, int a, int b)
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API bool rz_strbuf_setbin(RzStrBuf *sb, const ut8 *s, size_t len)
#define RZ_SYS_ENDIAN_BIG
#define RZ_SYS_ENDIAN_LITTLE
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()