mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-12 01:18:53 +00:00
<rdar://problem/7813254> check enable_execute_stack implementation
llvm-svn: 100036
This commit is contained in:
parent
74729ae094
commit
b3d3ec7091
@ -21,6 +21,11 @@
|
||||
#include <unistd.h>
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#if __LP64__
|
||||
#define TRAMPOLINE_SIZE 48
|
||||
#else
|
||||
#define TRAMPOLINE_SIZE 40
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The compiler generates calls to __enable_execute_stack() when creating
|
||||
@ -45,7 +50,7 @@ void __enable_execute_stack(void* addr)
|
||||
const uintptr_t pageAlignMask = ~(pageSize-1);
|
||||
uintptr_t p = (uintptr_t)addr;
|
||||
unsigned char* startPage = (unsigned char*)(p & pageAlignMask);
|
||||
unsigned char* endPage = (unsigned char*)((p+48+pageSize) & pageAlignMask);
|
||||
unsigned char* endPage = (unsigned char*)((p+TRAMPOLINE_SIZE+pageSize) & pageAlignMask);
|
||||
size_t length = endPage - startPage;
|
||||
(void) mprotect((void *)startPage, length, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user