Quick fix for macOS syscalls

This commit is contained in:
sivaramaaa 2017-11-27 00:41:53 +05:30 committed by radare
parent 805cc944b8
commit d1b1fcf701
2 changed files with 10 additions and 3 deletions

View File

@ -1572,7 +1572,8 @@ static void do_esil_search(RCore *core, struct search_parameters *param, const c
#define SUMARRAY(arr, size, res) do (res) += (arr)[--(size)]; while ((size))
static inline bool isnonlinear(int optype) {
return (optype == R_ANAL_OP_TYPE_CALL || optype == R_ANAL_OP_TYPE_JMP || optype == R_ANAL_OP_TYPE_CJMP);
return (optype == R_ANAL_OP_TYPE_CALL || optype == R_ANAL_OP_TYPE_JMP || optype == R_ANAL_OP_TYPE_CJMP ||
optype == R_ANAL_OP_TYPE_RET);
}
static int emulateSyscallPrelude(RCore *core, ut64 at, ut64 curpc) {
@ -1670,7 +1671,7 @@ static void do_syscall_search(RCore *core, struct search_parameters *param) {
ret = r_anal_op (core->anal, &aop, at, buf + i, bsize - i);
curpos = idx++ % (MAXINSTR + 1);
previnstr[curpos] = ret; // This array holds prev n instr size + cur instr size
if ((aop.type == R_ANAL_OP_TYPE_SWI) && ret) {
if ((aop.type == R_ANAL_OP_TYPE_SWI) && ret && (aop.val > 10)) {
// This for calculating no of bytes to be subtracted , to get n instr above syscall
int nbytes = 0;
int nb_opcodes = MAXINSTR;

View File

@ -57,6 +57,8 @@ R_API bool r_syscall_setup(RSyscall *s, const char *arch, const char *os, int bi
s->regs = fastcall_mips;
} else if (!strcmp (arch,"avr")) {
s->sysport = sysport_avr;
} else if (!strcmp (os,"osx")) {
os = "darwin";
} else if (!strcmp (arch,"sh")) {
s->regs = fastcall_sh;
} else if (!strcmp (arch, "arm")) {
@ -182,7 +184,11 @@ R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) {
}
ret = sdb_const_get (s->db, key, 0);
if (!ret) {
return NULL;
key = sdb_fmt (0, "0x%02x.0x%02x", swi, num); // Workaround until Syscall SDB is fixed
ret = sdb_const_get (s->db, key, 0);
if (!ret) {
return NULL;
}
}
ret2 = sdb_const_get (s->db, ret, 0);
if (!ret2) {