mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 17:44:48 +09:00

* Fix RHEL 8 ARM64 Clang on ARM64 places the .rodata section into the same segment as .text. On RHEL 8 ARM64, the kernel is configured for 64kB memory pages. When we flip the page protection of the page containing the GS cookie to RW and back to RO, we assume that the cookie lives in a non-executable memory. This assumption is broken on RHEL 8 and we end up setting protection of a part of the coreclr code to read only instead of back to RX. This change switches the linker we use to lld from the previously used gnu linker. That linker places .rodata into a different segment than .text by default. Moreover, I was planning to move to using lld anyways to use all build tools from LLVM. * Fix ARM build to use PC relative addresses only The lld linker has revealed that we were using absolute addresses in some asm helpers and so load time relocation was necessary. This change fixes it by replacing all of those by PC relative ones. * Update docker images used for building runtime Use new images that have lld linker * Disable lld linker for s390x
82 lines
2.9 KiB
CMake
82 lines
2.9 KiB
CMake
include(${CMAKE_CURRENT_LIST_DIR}/configureplatform.cmake)
|
|
|
|
# Get the version of the compiler that is in the file name for tool location.
|
|
set (CLR_CMAKE_COMPILER_FILE_NAME_VERSION "")
|
|
if (CMAKE_C_COMPILER MATCHES "-?[0-9]+(\.[0-9]+)?$")
|
|
set(CLR_CMAKE_COMPILER_FILE_NAME_VERSION "${CMAKE_MATCH_0}")
|
|
endif()
|
|
|
|
if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER)
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
if(APPLE)
|
|
set(TOOLSET_PREFIX "")
|
|
else()
|
|
set(TOOLSET_PREFIX "llvm-")
|
|
endif()
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
if(CMAKE_CROSSCOMPILING)
|
|
set(TOOLSET_PREFIX "${CMAKE_CXX_COMPILER_TARGET}-")
|
|
else()
|
|
set(TOOLSET_PREFIX "")
|
|
endif()
|
|
endif()
|
|
|
|
function(locate_toolchain_exec exec var)
|
|
string(TOUPPER ${exec} EXEC_UPPERCASE)
|
|
if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
|
|
set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
|
|
return()
|
|
endif()
|
|
|
|
find_program(EXEC_LOCATION_${exec}
|
|
NAMES
|
|
"${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
|
|
"${TOOLSET_PREFIX}${exec}")
|
|
|
|
if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
|
|
message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.")
|
|
endif()
|
|
set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
locate_toolchain_exec(ar CMAKE_AR)
|
|
locate_toolchain_exec(nm CMAKE_NM)
|
|
locate_toolchain_exec(ranlib CMAKE_RANLIB)
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
locate_toolchain_exec(link CMAKE_LINKER)
|
|
endif()
|
|
|
|
if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND (NOT CLR_CMAKE_TARGET_ANDROID OR CROSS_ROOTFS))
|
|
locate_toolchain_exec(objdump CMAKE_OBJDUMP)
|
|
|
|
if(CLR_CMAKE_TARGET_ANDROID)
|
|
set(TOOLSET_PREFIX ${ANDROID_TOOLCHAIN_PREFIX})
|
|
elseif(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR
|
|
CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL s390x))
|
|
set(TOOLSET_PREFIX "${TOOLCHAIN}-")
|
|
else()
|
|
set(TOOLSET_PREFIX "")
|
|
endif()
|
|
|
|
locate_toolchain_exec(objcopy CMAKE_OBJCOPY)
|
|
endif()
|
|
endif()
|
|
|
|
if (NOT CLR_CMAKE_HOST_WIN32)
|
|
# detect linker
|
|
separate_arguments(ldVersion UNIX_COMMAND "${CMAKE_C_COMPILER} ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version")
|
|
execute_process(COMMAND ${ldVersion}
|
|
ERROR_QUIET
|
|
OUTPUT_VARIABLE ldVersionOutput)
|
|
|
|
if("${ldVersionOutput}" MATCHES "LLD")
|
|
set(LD_LLVM 1)
|
|
elseif("${ldVersionOutput}" MATCHES "GNU ld" OR "${ldVersionOutput}" MATCHES "GNU gold" OR "${ldVersionOutput}" MATCHES "GNU linkers")
|
|
set(LD_GNU 1)
|
|
elseif("${ldVersionOutput}" MATCHES "Solaris Link")
|
|
set(LD_SOLARIS 1)
|
|
else(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
|
|
set(LD_OSX 1)
|
|
endif()
|
|
endif()
|