mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-17 12:34:35 +03:00
[Bug] Don't enable both MAP_JIT and MAP_SHARED (#402)
This commit is contained in:
@@ -548,13 +548,17 @@ static inline bool hasMapJitSupport() noexcept {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns either MAP_JIT or 0 based on `flags` and the host operating system.
|
// Returns either MAP_JIT or 0 based on `memoryFlags` and the host operating system.
|
||||||
static inline int mmMapJitFromMemoryFlags(MemoryFlags memoryFlags) noexcept {
|
static inline int mmMapJitFromMemoryFlags(MemoryFlags memoryFlags) noexcept {
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// Always use MAP_JIT flag if user asked for it (could be used for testing on non-hardened processes) and detect
|
// Always use MAP_JIT flag if user asked for it (could be used for testing on non-hardened processes) and detect
|
||||||
// whether it must be used when the process is actually hardened (in that case it doesn't make sense to rely on
|
// whether it must be used when the process is actually hardened (in that case it doesn't make sense to rely on
|
||||||
// user `memoryFlags`).
|
// user `memoryFlags`).
|
||||||
bool useMapJit = Support::test(memoryFlags, MemoryFlags::kMMapEnableMapJit) || hasHardenedRuntime();
|
//
|
||||||
|
// MAP_JIT is not required when dual-mapping memory and is incompatible with MAP_SHARED, so it will not be
|
||||||
|
// added when the latter is enabled.
|
||||||
|
bool useMapJit = (Support::test(memoryFlags, MemoryFlags::kMMapEnableMapJit) || hasHardenedRuntime())
|
||||||
|
&& !Support::test(memoryFlags, MemoryFlags::kMapShared);
|
||||||
if (useMapJit)
|
if (useMapJit)
|
||||||
return hasMapJitSupport() ? int(MAP_JIT) : 0;
|
return hasMapJitSupport() ? int(MAP_JIT) : 0;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user