From 8d82cdd6d842237bdb1c1eb3b0042fe0424e60ee Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 11 Jun 2018 23:27:45 +0000 Subject: [PATCH] [build] Enable PIE on non-IA32 Linux. (Gets ASLR working to hopefully make non-determinism surface more often.) (Thought I enabled this back in 2015...) Bug: b/22479195 Bug: https://github.com/dart-lang/sdk/issues/31427 Change-Id: I02381e364ccb8bccbf5aa561959bceb7be067128 Reviewed-on: https://dart-review.googlesource.com/59281 Reviewed-by: Zach Anderson Commit-Queue: Ryan Macnak --- build/config/BUILDCONFIG.gn | 15 ++++++++++----- build/config/compiler/BUILD.gn | 2 +- build/config/linux/BUILD.gn | 7 +++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index e9129e3990d..3ad0c961c26 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -292,11 +292,16 @@ if (is_win) { "//build/config/mac:mac_dynamic_flags", "//build/config/mac:mac_executable_flags", ] -} else if (is_linux || is_android) { - _executable_configs += [ "//build/config/gcc:executable_ldconfig" ] - if (is_android) { - _executable_configs += [ "//build/config/android:executable_config" ] - } +} else if (is_linux) { + _executable_configs += [ + "//build/config/gcc:executable_ldconfig", + "//build/config/linux:executable_config", + ] +} else if (is_android) { + _executable_configs += [ + "//build/config/gcc:executable_ldconfig", + "//build/config/android:executable_config", + ] } set_defaults("executable") { configs = _executable_configs diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index eeece1cb86c..8154e4e9a2c 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -234,7 +234,7 @@ config("compiler") { # 3. When using the sanitizers. # Otherwise there is a performance hit, in particular on ia32. if (is_android || is_asan || is_lsan || is_msan || is_tsan || - (is_linux && current_cpu == "arm")) { + (is_linux && current_cpu != "x86")) { cflags += [ "-fPIC" ] ldflags += [ "-fPIC" ] } diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn index 051809acd14..215025bc8ff 100644 --- a/build/config/linux/BUILD.gn +++ b/build/config/linux/BUILD.gn @@ -28,3 +28,10 @@ config("sdk") { } } } + +config("executable_config") { + if (current_cpu != "x86") { + cflags = [ "-fPIE" ] + ldflags = [ "-pie" ] + } +}