Merge further fixes to the 32-bit recompiler
Remove mprotect usages in 32-bit x86 dynamic recompiler
This commit is contained in:
@@ -1173,17 +1173,10 @@ static uint32_t gen_MEM_CHECK_WRITE_L()
|
|||||||
|
|
||||||
void codegen_init()
|
void codegen_init()
|
||||||
{
|
{
|
||||||
#ifdef __unix__
|
|
||||||
void *start;
|
|
||||||
size_t len;
|
|
||||||
long pagesize = sysconf(_SC_PAGESIZE);
|
|
||||||
long pagemask = ~(pagesize - 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
codeblock = VirtualAlloc(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
codeblock = VirtualAlloc(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
#elif defined __unix__
|
#elif defined __unix__
|
||||||
codeblock = mmap(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, 0);
|
codeblock = mmap(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0);
|
||||||
#else
|
#else
|
||||||
codeblock = malloc((BLOCK_SIZE+1) * sizeof(codeblock_t));
|
codeblock = malloc((BLOCK_SIZE+1) * sizeof(codeblock_t));
|
||||||
#endif
|
#endif
|
||||||
@@ -1192,16 +1185,6 @@ void codegen_init()
|
|||||||
memset(codeblock, 0, (BLOCK_SIZE+1) * sizeof(codeblock_t));
|
memset(codeblock, 0, (BLOCK_SIZE+1) * sizeof(codeblock_t));
|
||||||
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
|
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
|
||||||
|
|
||||||
#ifdef __unix__
|
|
||||||
start = (void *)((long)codeblock & pagemask);
|
|
||||||
len = (((BLOCK_SIZE+1) * sizeof(codeblock_t)) + pagesize) & pagemask;
|
|
||||||
if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
|
|
||||||
{
|
|
||||||
perror("mprotect");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
block_current = BLOCK_SIZE;
|
block_current = BLOCK_SIZE;
|
||||||
block_pos = 0;
|
block_pos = 0;
|
||||||
mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos];
|
mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos];
|
||||||
|
Reference in New Issue
Block a user