Fix PIE options (dotnet/coreclr#26323)
authorJan Vorlicek <janvorli@microsoft.com>
Fri, 23 Aug 2019 15:03:01 +0000 (17:03 +0200)
committerJan Kotas <jkotas@microsoft.com>
Fri, 23 Aug 2019 15:03:01 +0000 (08:03 -0700)
commit9c0353962e89a1548e2d0545219c3e4aef536942
tree293d910c273071dfdb818d6438d0c3da55b880f9
parentdcde00bb70dc0e421669e86eb199410ce366b492
Fix PIE options (dotnet/coreclr#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

Commit migrated from https://github.com/dotnet/coreclr/commit/f7205db2901015b721cb75a4d595441265223c21
47 files changed:
src/coreclr/configurecompiler.cmake
src/coreclr/src/binder/CMakeLists.txt
src/coreclr/src/classlibnative/bcltype/CMakeLists.txt
src/coreclr/src/classlibnative/float/CMakeLists.txt
src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt
src/coreclr/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt
src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt
src/coreclr/src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt
src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt
src/coreclr/src/debug/createdump/CMakeLists.txt
src/coreclr/src/debug/daccess/CMakeLists.txt
src/coreclr/src/debug/dbgutil/CMakeLists.txt
src/coreclr/src/debug/debug-pal/CMakeLists.txt
src/coreclr/src/debug/di/CMakeLists.txt
src/coreclr/src/debug/ee/CMakeLists.txt
src/coreclr/src/debug/ee/wks/CMakeLists.txt
src/coreclr/src/debug/ildbsymlib/CMakeLists.txt
src/coreclr/src/debug/shim/CMakeLists.txt
src/coreclr/src/dlls/dbgshim/CMakeLists.txt
src/coreclr/src/dlls/mscordac/CMakeLists.txt
src/coreclr/src/dlls/mscorrc/CMakeLists.txt
src/coreclr/src/gc/CMakeLists.txt
src/coreclr/src/gc/unix/CMakeLists.txt
src/coreclr/src/gcinfo/CMakeLists.txt
src/coreclr/src/ilasm/CMakeLists.txt
src/coreclr/src/ildasm/exe/CMakeLists.txt
src/coreclr/src/inc/CMakeLists.txt
src/coreclr/src/jit/dll/CMakeLists.txt
src/coreclr/src/md/ceefilegen/CMakeLists.txt
src/coreclr/src/md/compiler/CMakeLists.txt
src/coreclr/src/md/datasource/CMakeLists.txt
src/coreclr/src/md/enc/CMakeLists.txt
src/coreclr/src/md/hotdata/CMakeLists.txt
src/coreclr/src/md/runtime/CMakeLists.txt
src/coreclr/src/md/staticmd/CMakeLists.txt
src/coreclr/src/md/winmd/CMakeLists.txt
src/coreclr/src/nativeresources/CMakeLists.txt
src/coreclr/src/pal/src/CMakeLists.txt
src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt
src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
src/coreclr/src/palrt/CMakeLists.txt
src/coreclr/src/strongname/api/CMakeLists.txt
src/coreclr/src/tools/crossgen/CMakeLists.txt
src/coreclr/src/unwinder/CMakeLists.txt
src/coreclr/src/utilcode/CMakeLists.txt
src/coreclr/src/vm/CMakeLists.txt
src/coreclr/tests/CMakeLists.txt