Better description for jit-sealloc option and early check for executable memory.
This commit is contained in:
parent
3787601f81
commit
70b0debf10
|
@ -178,7 +178,7 @@ SET(PCRE2_SUPPORT_JIT OFF CACHE BOOL
|
|||
"Enable support for Just-in-time compiling.")
|
||||
|
||||
SET(PCRE2_SUPPORT_JIT_SEALLOC OFF CACHE BOOL
|
||||
"Enable SELinux compatible execmem allocator in JIT.")
|
||||
"Enable SELinux compatible execmem allocator in JIT (experimental).")
|
||||
|
||||
SET(PCRE2GREP_SUPPORT_JIT ON CACHE BOOL
|
||||
"Enable use of Just-in-time compiling in pcre2grep.")
|
||||
|
|
8
README
8
README
|
@ -164,9 +164,11 @@ library. They are also documented in the pcre2build man page.
|
|||
will be a compile time error. If in doubt, use --enable-jit=auto, which
|
||||
enables JIT only if the current hardware is supported.
|
||||
|
||||
. If you are enabling JIT under SELinux you may also want to add
|
||||
--enable-jit-sealloc, which enables the use of an execmem allocator in JIT
|
||||
that is compatible with SELinux. This has no effect if JIT is not enabled.
|
||||
. If you are enabling JIT under SELinux environment you may also want to add
|
||||
--enable-jit-sealloc, which enables the use of an executable memory allocator
|
||||
that is compatible with SELinux. Warning: this allocator is experimental!
|
||||
It does not support fork() operation and may crash when no disk space is
|
||||
available. This option has no effect if JIT is disabled.
|
||||
|
||||
. If you do not want to make use of the default support for UTF-8 Unicode
|
||||
character strings in the 8-bit library, UTF-16 Unicode character strings in
|
||||
|
|
|
@ -161,7 +161,7 @@ fi
|
|||
# Handle --enable-jit-sealloc (disabled by default)
|
||||
AC_ARG_ENABLE(jit-sealloc,
|
||||
AS_HELP_STRING([--enable-jit-sealloc],
|
||||
[enable SELinux compatible execmem allocator in JIT]),
|
||||
[enable SELinux compatible execmem allocator in JIT (experimental)]),
|
||||
, enable_jit_sealloc=no)
|
||||
|
||||
# Handle --disable-pcre2grep-jit (enabled by default)
|
||||
|
|
|
@ -13740,12 +13740,33 @@ Returns: 0: success or (*NOJIT) was used
|
|||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_jit_compile(pcre2_code *code, uint32_t options)
|
||||
{
|
||||
static int executable_allocator_is_working = 0;
|
||||
|
||||
pcre2_real_code *re = (pcre2_real_code *)code;
|
||||
|
||||
#ifdef SUPPORT_JIT
|
||||
executable_functions *functions = (executable_functions *)re->executable_jit;
|
||||
#endif
|
||||
|
||||
if (executable_allocator_is_working == 0)
|
||||
{
|
||||
/* Checks whether the executable allocator is working. This check
|
||||
might run multiple times in multi-threaded environments, but the result
|
||||
should not be affected by it. */
|
||||
void *ptr = SLJIT_MALLOC_EXEC(32);
|
||||
|
||||
executable_allocator_is_working = -1;
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
SLJIT_FREE_EXEC(((sljit_u8*)(ptr)) + SLJIT_EXEC_OFFSET(ptr));
|
||||
executable_allocator_is_working = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (executable_allocator_is_working < 0)
|
||||
return PCRE2_ERROR_NOMEMORY;
|
||||
|
||||
if (code == NULL)
|
||||
return PCRE2_ERROR_NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue