diff --git a/libr/asm/asm.c b/libr/asm/asm.c index b35dfa9894..aa95de63bc 100644 --- a/libr/asm/asm.c +++ b/libr/asm/asm.c @@ -143,6 +143,7 @@ R_API RAsm *r_asm_new() { if (!a) { return NULL; } + a->dataalign = 1; a->bits = R_SYS_BITS; a->syntax = R_ASM_SYNTAX_INTEL; a->plugins = r_list_newf ((RListFree)plugin_free); diff --git a/libr/asm/p/asm_dalvik.c b/libr/asm/p/asm_dalvik.c index a4ab9997d5..cde2640739 100644 --- a/libr/asm/p/asm_dalvik.c +++ b/libr/asm/p/asm_dalvik.c @@ -15,6 +15,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) { char str[1024], *strasm; ut64 offset; const char *flag_str; + a->dataalign = 2; op->buf_asm[0] = 0; if (buf[0] == 0x00) { /* nop */ @@ -54,7 +55,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) { snprintf (op->buf_asm, sizeof (op->buf_asm), "fill-array-data-payload %d, %d", elem_width, array_size); - payload = 2 * ((array_size * elem_width+1)/2); + payload = array_size * elem_width; } size = 8; len = 0; diff --git a/libr/core/disasm.c b/libr/core/disasm.c index ec40c8fc07..aa143dab5d 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -2592,9 +2592,13 @@ static void ds_print_asmop_payload(RDisasmState *ds, const ut8 *buf) { if (ds->asmop.payload != 0) { r_cons_printf ("\n; .. payload of %d bytes", ds->asmop.payload); if (ds->showpayloads) { + int mod = ds->asmop.payload % ds->core->assembler->dataalign; int x; for (x = 0; x < ds->asmop.payload; ++x) { - r_cons_printf ("\n 0x%x", buf[ds->oplen + x]); + r_cons_printf ("\n 0x%02x", buf[ds->oplen + x]); + } + for (x = 0; x < mod; ++x) { + r_cons_printf ("\n 0x%02x ; alignment", buf[ds->oplen + ds->asmop.payload + x]); } } } @@ -3786,7 +3790,7 @@ toro: if (inc < 1) { inc = 1; } - inc += ds->asmop.payload; + inc += ds->asmop.payload + (ds->asmop.payload % ds->core->assembler->dataalign); } R_FREE (nbuf); r_cons_break_pop (); @@ -4258,8 +4262,8 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte } r_cons_printf ("}"); - i += oplen + asmop.payload; // bytes - k += oplen + asmop.payload; // delta from addr + i += oplen + asmop.payload + (ds->asmop.payload % ds->core->assembler->dataalign); // bytes + k += oplen + asmop.payload + (ds->asmop.payload % ds->core->assembler->dataalign); // delta from addr j++; // instructions line++; diff --git a/libr/include/r_asm.h b/libr/include/r_asm.h index ef83a152e3..91994feaad 100644 --- a/libr/include/r_asm.h +++ b/libr/include/r_asm.h @@ -111,6 +111,7 @@ typedef struct r_asm_t { char *features; int invhex; // invalid instructions displayed in hex int pcalign; + int dataalign; } RAsm; typedef int (*RAsmModifyCallback)(RAsm *a, ut8 *buf, int field, ut64 val);