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/pal/src/CMakeLists.txt | 2 -- src/pal/src/eventprovider/lttngprovider/CMakeLists.txt | 2 -- src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt | 1 - 3 files changed, 5 deletions(-) (limited to 'src/pal') diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index 3bc1dc89a0..683eda0c7e 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -9,8 +9,6 @@ if(NOT DEFINED ENV{ROOTFS_DIR}) include_directories(SYSTEM /usr/local/include) endif() -add_compile_options(-fPIC) - if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) include_directories(libunwind/include) include_directories(libunwind/include/tdep) diff --git a/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt index b5bf8e8551..1f49aef64e 100644 --- a/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt +++ b/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt @@ -46,8 +46,6 @@ add_library(eventprovider eventproviderhelpers.cpp ) -add_compile_options(-fPIC) - add_library(coreclrtraceptprovider SHARED ${TRACEPOINT_PROVIDER_SOURCES} diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt index 4a3abc2d64..685ac2ed4f 100644 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) if(CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-fPIC) add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS) endif(CLR_CMAKE_PLATFORM_UNIX) -- cgit v1.2.3