# HG changeset patch # User Michael Pavone # Date 1493956825 25200 # Node ID 101b5ce682fe9419317fb634a8c7bd25fe3bf507 # Parent 35e6a93b4586a011913723e15e7bef075259ce4a Fix some inconsequential issues in code for executable memory allocation noticed while tracking down a different issue diff -r 35e6a93b4586 -r 101b5ce682fe gen_x86.c --- a/gen_x86.c Wed May 03 21:28:40 2017 -0700 +++ b/gen_x86.c Thu May 04 21:00:25 2017 -0700 @@ -207,7 +207,6 @@ //new chunk is not contiguous with the current one jmp_nocheck(code, next_code); code->cur = next_code; - code->last = next_code + size/sizeof(RESERVE_WORDS); } code->last = next_code + size/sizeof(code_word) - RESERVE_WORDS; } diff -r 35e6a93b4586 -r 101b5ce682fe mem.c --- a/mem.c Wed May 03 21:28:40 2017 -0700 +++ b/mem.c Thu May 04 21:00:25 2017 -0700 @@ -30,8 +30,10 @@ if (ret) { return ret; } - *size += PAGE_SIZE - (*size & (PAGE_SIZE - 1)); - ret = mmap(NULL, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); + if (*size & (PAGE_SIZE -1)) { + *size += PAGE_SIZE - (*size & (PAGE_SIZE - 1)); + } + ret = mmap(next, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); if (ret == MAP_FAILED) { perror("alloc_code"); return NULL;