From: notaz Date: Wed, 13 Jan 2016 23:24:35 +0000 (+0200) Subject: use more precise self crash check X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c888740e36d8ec83c68f35c5f14b8f698db7a2b;p=ginge.git use more precise self crash check --- diff --git a/loader/emu.c b/loader/emu.c index 6ddbb4a..8234a14 100644 --- a/loader/emu.c +++ b/loader/emu.c @@ -916,13 +916,18 @@ static void init_linkpage(void) static void segv_sigaction(int num, siginfo_t *info, void *ctx) { + extern char _init, _end; struct ucontext *context = ctx; u32 *regs = (u32 *)&context->uc_mcontext.arm_r0; u32 *pc = (u32 *)regs[15]; + u32 self_start, self_end; struct op_context *op_ctx; int i, lp_size; - if (((regs[15] ^ (u32)&segv_sigaction) & 0xff000000) == 0 || // PC is in our segment or + self_start = (u32)&_init & ~0xfff; + self_end = (u32)&_end; + + if ((self_start <= regs[15] && regs[15] <= self_end) || // PC is in our segment or (((regs[15] ^ (u32)g_linkpage) & ~(LINKPAGE_ALLOC - 1)) == 0) || // .. in linkpage ((long)info->si_addr & 0xffe00000) != 0x7f000000) // faulting not where expected {