diff options
author | Juan Hoyos <juan.hoyos@microsoft.com> | 2021-03-19 11:08:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 11:08:23 +0300 |
commit | c69ed5a4ad2e625dbe2206b170822f6b5154bd5e (patch) | |
tree | 848581fb45e2652a836c37237340f69d8426cee5 /eng/native/functions.cmake | |
parent | 25f1800f1444a012217911e6f9522cabeb7672d1 (diff) |
Disable looking for PaxCtl on non Linux/BSD distros (#49746)
Diffstat (limited to 'eng/native/functions.cmake')
-rw-r--r-- | eng/native/functions.cmake | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index f39fb67bd0c..3e01c275025 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -392,19 +392,24 @@ endfunction() # - creating executable pages from anonymous memory, # - making read-only-after-relocations (RELRO) data pages writable again. function(disable_pax_mprotect targetName) - # Try to locate the paxctl tool. Failure to find it is not fatal, - # but the generated executables won't work on a system where PAX is set - # to prevent applications to create executable memory mappings. - find_program(PAXCTL paxctl) - - if (NOT PAXCTL STREQUAL "PAXCTL-NOTFOUND") - add_custom_command( - TARGET ${targetName} - POST_BUILD - VERBATIM - COMMAND ${PAXCTL} -c -m $<TARGET_FILE:${targetName}> - ) - endif() + # Disabling PAX hardening only makes sense in systems that use Elf image formats. Particularly, looking + # for paxctl in macOS is problematic as it collides with popular software for that OS that performs completely + # unrelated functionality. Only look for it when we'll generate Elf images. + if (CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + # Try to locate the paxctl tool. Failure to find it is not fatal, + # but the generated executables won't work on a system where PAX is set + # to prevent applications to create executable memory mappings. + find_program(PAXCTL paxctl) + + if (NOT PAXCTL STREQUAL "PAXCTL-NOTFOUND") + add_custom_command( + TARGET ${targetName} + POST_BUILD + VERBATIM + COMMAND ${PAXCTL} -c -m $<TARGET_FILE:${targetName}> + ) + endif() + endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) endfunction() if (CMAKE_VERSION VERSION_LESS "3.12") |