mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-01 17:40:34 +00:00
Better MIPS32BE ELF relocs, add Rx regs in mips.cs and add scr.wheelnkey, nN defaults to flag now
This commit is contained in:
parent
3c1a4eb040
commit
100df3bb32
@ -852,6 +852,8 @@ static int set_reg_profile(RAnal *anal) {
|
||||
"=A1 a1\n"
|
||||
"=A2 a2\n"
|
||||
"=A3 a3\n"
|
||||
"=R0 v0\n"
|
||||
"=R1 v1\n"
|
||||
"gpr zero .32 0 0\n"
|
||||
"gpr at .32 4 0\n"
|
||||
"gpr v0 .32 8 0\n"
|
||||
|
@ -536,8 +536,17 @@ static ut64 get_import_addr(struct Elf_(r_bin_elf_obj_t) *bin, int sym) {
|
||||
{
|
||||
RBinElfSection *s = get_section_by_name(bin, ".rela.plt");
|
||||
if (s) {
|
||||
ut8 buf[1024];
|
||||
const ut8 *base;
|
||||
plt_addr = s->rva + s->size;
|
||||
plt_addr += 108;
|
||||
len = r_buf_read_at (bin->b, s->offset + s->size, buf, sizeof (buf));
|
||||
len = sizeof (buf); //
|
||||
base = r_mem_mem_aligned (buf, sizeof (buf), (const ut8*)"\x3c\x0f\x00", 3, 4);
|
||||
if (base) {
|
||||
plt_addr += (int)(size_t)(base - buf);
|
||||
} else {
|
||||
plt_addr += 108 + 8; // HARDCODED HACK
|
||||
}
|
||||
plt_addr += k * 16;
|
||||
free (REL);
|
||||
return plt_addr;
|
||||
|
@ -1735,6 +1735,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
#else
|
||||
SETPREF("scr.responsive", "false", "Auto-adjust Visual depending on screen (e.g. unset asm.bytes)");
|
||||
#endif
|
||||
SETPREF("scr.wheelnkey", "false", "Use sn/sp and scr.nkey on wheel instead of scroll");
|
||||
SETPREF("scr.wheel", "true", "Mouse wheel in Visual; temporaryly disable/reenable by right click/Enter)");
|
||||
SETPREF("scr.atport", "false", "V@ starts a background http server and spawns an r2 -C");
|
||||
SETI("scr.wheelspeed", 4, "Mouse wheel speed");
|
||||
@ -1749,7 +1750,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETCB("scr.interactive", "true", &cb_scrint, "Start in interactive mode");
|
||||
SETI("scr.feedback", 1, "Set visual feedback level (1=arrow on jump, 2=every key (useful for videos))");
|
||||
SETCB("scr.html", "false", &cb_scrhtml, "Disassembly uses HTML syntax");
|
||||
SETCB("scr.nkey", "fun", &cb_scrnkey, "Select the seek mode in visual");
|
||||
SETCB("scr.nkey", "flag", &cb_scrnkey, "Select the seek mode in visual");
|
||||
SETCB("scr.pager", "", &cb_pager, "Select pager program (when output overflows the window)");
|
||||
SETPREF("scr.pipecolor", "false", "Enable colors when using pipes");
|
||||
SETPREF("scr.promptfile", "false", "Show user prompt file (used by r2 -q)");
|
||||
|
@ -1357,25 +1357,29 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
if (core->print->cur_enabled) {
|
||||
cursor_nextrow (core, false);
|
||||
} else {
|
||||
int times = wheelspeed;
|
||||
if (times<1) times = 1;
|
||||
while (times--) {
|
||||
if (isDisasmPrint(core->printidx)) {
|
||||
RAnalFunction *f = NULL;
|
||||
if (true) {
|
||||
f = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
if (r_config_get_i (core->config, "scr.wheelnkey")) {
|
||||
r_core_cmd0 (core, "sn");
|
||||
} else {
|
||||
int times = wheelspeed;
|
||||
if (times<1) times = 1;
|
||||
while (times--) {
|
||||
if (isDisasmPrint(core->printidx)) {
|
||||
RAnalFunction *f = NULL;
|
||||
if (true) {
|
||||
f = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
}
|
||||
if (f && f->folded) {
|
||||
cols = core->offset - f->addr + f->size;
|
||||
} else {
|
||||
r_asm_set_pc (core->assembler, core->offset);
|
||||
cols = r_asm_disassemble (core->assembler,
|
||||
&op, core->block, 32);
|
||||
}
|
||||
if (cols<1) cols = op.size;
|
||||
if (cols<1) cols = 1;
|
||||
}
|
||||
if (f && f->folded) {
|
||||
cols = core->offset - f->addr + f->size;
|
||||
} else {
|
||||
r_asm_set_pc (core->assembler, core->offset);
|
||||
cols = r_asm_disassemble (core->assembler,
|
||||
&op, core->block, 32);
|
||||
}
|
||||
if (cols<1) cols = op.size;
|
||||
if (cols<1) cols = 1;
|
||||
r_core_seek (core, core->offset + cols, 1);
|
||||
}
|
||||
r_core_seek (core, core->offset + cols, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1394,21 +1398,25 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
if (core->print->cur_enabled) {
|
||||
cursor_prevrow (core, false);
|
||||
} else {
|
||||
int times = wheelspeed;
|
||||
if (times<1) times = 1;
|
||||
while (times--) {
|
||||
if (isDisasmPrint (core->printidx)) {
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
||||
if (f && f->folded) {
|
||||
cols = core->offset - f->addr; // + f->size;
|
||||
if (cols<1) {
|
||||
cols = 4;
|
||||
if (r_config_get_i (core->config, "scr.wheelnkey")) {
|
||||
r_core_cmd0(core, "sp");
|
||||
} else {
|
||||
int times = wheelspeed;
|
||||
if (times<1) times = 1;
|
||||
while (times--) {
|
||||
if (isDisasmPrint (core->printidx)) {
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
||||
if (f && f->folded) {
|
||||
cols = core->offset - f->addr; // + f->size;
|
||||
if (cols<1) {
|
||||
cols = 4;
|
||||
}
|
||||
} else {
|
||||
cols = prevopsz (core, core->offset);
|
||||
}
|
||||
} else {
|
||||
cols = prevopsz (core, core->offset);
|
||||
}
|
||||
r_core_seek (core, core->offset - cols, 1);
|
||||
}
|
||||
r_core_seek (core, core->offset - cols, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2008-2015 - pancake */
|
||||
/* radare - LGPL - Copyright 2008-2016 - pancake */
|
||||
|
||||
#ifndef R2_UTIL_H
|
||||
#define R2_UTIL_H
|
||||
@ -443,6 +443,7 @@ R_API void r_mem_copyloop (ut8 *dest, const ut8 *orig, int dsize, int osize);
|
||||
R_API void r_mem_copyendian (ut8 *dest, const ut8 *orig, int size, int endian);
|
||||
R_API int r_mem_cmp_mask (const ut8 *dest, const ut8 *orig, const ut8 *mask, int len);
|
||||
R_API const ut8 *r_mem_mem (const ut8 *haystack, int hlen, const ut8 *needle, int nlen);
|
||||
R_API const ut8 *r_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *needle, int nlen, int align);
|
||||
|
||||
#define r_num_abs(x) x>0?x:-x
|
||||
R_API void r_num_minmax_swap(ut64 *a, ut64 *b);
|
||||
|
@ -204,6 +204,22 @@ R_API const ut8 *r_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: rename to r_mem_mem and refactor all calls to this function
|
||||
R_API const ut8 *r_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *needle, int nlen, int align) {
|
||||
int i, until = hlen-nlen+1;
|
||||
if (align < 1) align = 1;
|
||||
if (hlen<1 || nlen<1)
|
||||
return NULL;
|
||||
if (align>1) {
|
||||
until -= (until % align);
|
||||
}
|
||||
for (i=0; i<until; i+=align) {
|
||||
if (!memcmp (haystack+i, needle, nlen))
|
||||
return haystack+i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: implement pack/unpack helpers use vararg or wtf?
|
||||
R_API int r_mem_pack() {
|
||||
// TODO: copy this from r_buf??
|
||||
|
Loading…
Reference in New Issue
Block a user