From 4feb5cbcbeea277f7addb372b3c632e89f9ed1ae Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 23 Aug 2019 17:03:01 +0200 Subject: Fix PIE options (#26323) * Fix PIE options We were missing passing the -pie linker option. That means that while we were compiling our code as position independent, the executables (not shared libraries) were not marked as position independent and ASLR was not applied to them. They were always loaded to fixed addresses. This change adds the missing -pie option and also replaces all the individual settings of -fPIE / -fPIC on the targets we build by a centralized setting of CMAKE_POSITION_INDEPENDENT_CODE variable that causes cmake to add the appropriate compiler options everywhere. * Fix native parts of coreclr tests build The native parts of the tests are not built using the root CMakeLists.txt so I am moving enabling the position independent code to configurecompiler.cmake Change-Id: Ieafff8984ec23e5fdb00fb0c2fb017e53afbce88 --- src/dlls/dbgshim/CMakeLists.txt | 2 -- src/dlls/mscordac/CMakeLists.txt | 4 ---- src/dlls/mscorrc/CMakeLists.txt | 4 ---- 3 files changed, 10 deletions(-) (limited to 'src/dlls') diff --git a/src/dlls/dbgshim/CMakeLists.txt b/src/dlls/dbgshim/CMakeLists.txt index 7e6ae61de1..ca4556bd03 100644 --- a/src/dlls/dbgshim/CMakeLists.txt +++ b/src/dlls/dbgshim/CMakeLists.txt @@ -41,8 +41,6 @@ endif(CLR_CMAKE_PLATFORM_DARWIN) add_library_clr(dbgshim SHARED ${DBGSHIM_SOURCES}) if(CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-fPIC) - add_custom_target(dbgshim_exports DEPENDS ${EXPORTS_FILE}) add_dependencies(dbgshim dbgshim_exports) diff --git a/src/dlls/mscordac/CMakeLists.txt b/src/dlls/mscordac/CMakeLists.txt index e065eba023..df8d615e0a 100644 --- a/src/dlls/mscordac/CMakeLists.txt +++ b/src/dlls/mscordac/CMakeLists.txt @@ -1,10 +1,6 @@ include(${CLR_DIR}/dac.cmake) add_definitions(-DFEATURE_NO_HOST) -if(CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-fPIC) -endif(CLR_CMAKE_PLATFORM_UNIX) - set(CLR_DAC_SOURCES ) diff --git a/src/dlls/mscorrc/CMakeLists.txt b/src/dlls/mscorrc/CMakeLists.txt index 8f67988a23..366ace4631 100644 --- a/src/dlls/mscorrc/CMakeLists.txt +++ b/src/dlls/mscorrc/CMakeLists.txt @@ -9,10 +9,6 @@ if(WIN32) string(REPLACE "/guard:cf" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif(WIN32) -if(CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-fPIC) -endif(CLR_CMAKE_PLATFORM_UNIX) - add_subdirectory(full) # Only add the small version of the resources if the platform is Windows. -- cgit v1.2.3