MIPS: Fix handling of long-range spare jumps.
This commit is contained in:
@@ -314,21 +314,21 @@ void lj_mcode_abort(jit_State *J)
|
||||
/* Set/reset protection to allow patching of MCode areas. */
|
||||
MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish)
|
||||
{
|
||||
#if LUAJIT_SECURITY_MCODE == 0
|
||||
UNUSED(J); UNUSED(ptr); UNUSED(finish);
|
||||
return NULL;
|
||||
#else
|
||||
if (finish) {
|
||||
#if LUAJIT_SECURITY_MCODE
|
||||
if (J->mcarea == ptr)
|
||||
mcode_protect(J, MCPROT_RUN);
|
||||
else if (LJ_UNLIKELY(mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN)))
|
||||
mcode_protfail(J);
|
||||
#endif
|
||||
return NULL;
|
||||
} else {
|
||||
MCode *mc = J->mcarea;
|
||||
/* Try current area first to use the protection cache. */
|
||||
if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) {
|
||||
#if LUAJIT_SECURITY_MCODE
|
||||
mcode_protect(J, MCPROT_GEN);
|
||||
#endif
|
||||
return mc;
|
||||
}
|
||||
/* Otherwise search through the list of MCode areas. */
|
||||
@@ -336,13 +336,14 @@ MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish)
|
||||
mc = ((MCLink *)mc)->next;
|
||||
lj_assertJ(mc != NULL, "broken MCode area chain");
|
||||
if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) {
|
||||
#if LUAJIT_SECURITY_MCODE
|
||||
if (LJ_UNLIKELY(mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN)))
|
||||
mcode_protfail(J);
|
||||
#endif
|
||||
return mc;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Limit of MCode reservation reached. */
|
||||
|
||||
Reference in New Issue
Block a user