зеркало из https://github.com/mozilla/gecko-dev.git
Bug 557771 - Add support for alpha, hppa, ia64, mips, mipsel and s390 to TestPoisonArea. r=zackw,a=bsmedberg
This commit is contained in:
Родитель
540f2194fe
Коммит
5d20fb66fd
|
@ -156,6 +156,8 @@ typedef unsigned int uint32_t;
|
|||
|
||||
/* This program assumes that a whole number of return instructions fit into
|
||||
* 32 bits, and that 32-bit alignment is sufficient for a branch destination.
|
||||
* For architectures where this is not true, fiddling with RETURN_INSTR_TYPE
|
||||
* can be enough.
|
||||
*/
|
||||
|
||||
#if defined __i386__ || defined __x86_64__ || \
|
||||
|
@ -174,10 +176,40 @@ typedef unsigned int uint32_t;
|
|||
#elif defined __sparc || defined __sparcv9
|
||||
#define RETURN_INSTR 0x81c3e008 /* retl */
|
||||
|
||||
#elif defined __alpha
|
||||
#define RETURN_INSTR 0x6bfa8001 /* ret */
|
||||
|
||||
#elif defined __hppa
|
||||
#define RETURN_INSTR 0xe840c002 /* bv,n r0(rp) */
|
||||
|
||||
#elif defined __mips
|
||||
#define RETURN_INSTR 0x03e00008 /* jr ra */
|
||||
|
||||
#ifdef __MIPSEL
|
||||
/* On mipsel, jr ra needs to be followed by a nop.
|
||||
0x03e00008 as a 64 bits integer just does that */
|
||||
#define RETURN_INSTR_TYPE uint64_t
|
||||
#endif
|
||||
|
||||
#elif defined __s390__
|
||||
#define RETURN_INSTR 0x07fe0000 /* br %r14 */
|
||||
|
||||
#elif defined __ia64
|
||||
struct ia64_instr { uint32_t i[4]; };
|
||||
static const ia64_instr _return_instr =
|
||||
{{ 0x00000011, 0x00000001, 0x80000200, 0x00840008 }}; /* br.ret.sptk.many b0 */
|
||||
|
||||
#define RETURN_INSTR _return_instr
|
||||
#define RETURN_INSTR_TYPE ia64_instr
|
||||
|
||||
#else
|
||||
#error "Need return instruction for this architecture"
|
||||
#endif
|
||||
|
||||
#ifndef RETURN_INSTR_TYPE
|
||||
#define RETURN_INSTR_TYPE uint32_t
|
||||
#endif
|
||||
|
||||
// Miscellaneous Windows/Unix portability gumph
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -376,8 +408,8 @@ ReserveNegativeControl()
|
|||
}
|
||||
|
||||
// Fill the page with return instructions.
|
||||
uint32_t *p = (uint32_t *)result;
|
||||
uint32_t *limit = (uint32_t *)(((char *)result) + PAGESIZE);
|
||||
RETURN_INSTR_TYPE *p = (RETURN_INSTR_TYPE *)result;
|
||||
RETURN_INSTR_TYPE *limit = (RETURN_INSTR_TYPE *)(((char *)result) + PAGESIZE);
|
||||
while (p < limit)
|
||||
*p++ = RETURN_INSTR;
|
||||
|
||||
|
@ -394,6 +426,20 @@ ReserveNegativeControl()
|
|||
return (uintptr_t)result;
|
||||
}
|
||||
|
||||
static void
|
||||
JumpTo(uintptr_t opaddr)
|
||||
{
|
||||
#ifdef __ia64
|
||||
struct func_call {
|
||||
uintptr_t func;
|
||||
uintptr_t gp;
|
||||
} call = { opaddr, };
|
||||
((void (*)())&call)();
|
||||
#else
|
||||
((void (*)())opaddr)();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static BOOL
|
||||
IsBadExecPtr(uintptr_t ptr)
|
||||
|
@ -402,7 +448,7 @@ IsBadExecPtr(uintptr_t ptr)
|
|||
|
||||
#ifdef _MSC_VER
|
||||
__try {
|
||||
((void (*)())ptr)();
|
||||
JumpTo(ptr);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
ret = true;
|
||||
}
|
||||
|
@ -469,7 +515,7 @@ TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
|
|||
volatile unsigned char scratch;
|
||||
switch (test) {
|
||||
case 0: scratch = *(volatile unsigned char *)opaddr; break;
|
||||
case 1: ((void (*)())opaddr)(); break;
|
||||
case 1: JumpTo(opaddr); break;
|
||||
case 2: *(volatile unsigned char *)opaddr = 0; break;
|
||||
default: abort();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче