aboutsummaryrefslogtreecommitdiff
path: root/ld/configure
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-02-27 11:34:20 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-02-27 11:34:29 -0800
commitf6aec96dce1ddbd8961a3aa8a2925db2021719bb (patch)
tree0837083a3f8011754f0fa415afa4a6fb27795580 /ld/configure
parent55089490f79ce1ddb9610fd6abeeaf896825fb71 (diff)
downloadbinutils-f6aec96dce1ddbd8961a3aa8a2925db2021719bb.zip
binutils-f6aec96dce1ddbd8961a3aa8a2925db2021719bb.tar.gz
binutils-f6aec96dce1ddbd8961a3aa8a2925db2021719bb.tar.bz2
ld: Add --enable-separate-code
This patch adds --enable-separate-code to ld configure to turn on -z separate-code by default and enables it by default for Linux/x86. This avoids mixing code pages with data to improve cache performance as well as security. To reduce x86-64 executable and shared object sizes, the maximum page size is reduced from 2MB to 4KB when -z separate-code is turned on by default. Note: -z max-page-size= can be used to set the maximum page size. We compared SPEC CPU 2017 performance before and after this change on Skylake server. There are no any significant performance changes. Everything is mostly below +/-1%. bfd/ * config.in: Regenerated. * configure: Likewise. * configure.ac: Add --enable-separate-code. (DEFAULT_LD_Z_SEPARATE_CODE): New AC_DEFINE_UNQUOTED. Default to 1 for Linux/x86 targets, * elf64-x86-64.c (ELF_MAXPAGESIZE): Set to 0x1000 if DEFAULT_LD_Z_SEPARATE_CODE is 1. ld/ * NEWS: Mention --enable-separate-code. * configure.ac: Add --enable-separate-code. (DEFAULT_LD_Z_SEPARATE_CODE): New AC_DEFINE_UNQUOTED. * configure.tgt: Default ac_default_ld_z_separate_code to 1 for Linux/x86 targets. * config.in: Regenerated. * configure: Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set link_info.separate_code DEFAULT_LD_Z_SEPARATE_CODE.
Diffstat (limited to 'ld/configure')
-rwxr-xr-xld/configure26
1 files changed, 24 insertions, 2 deletions
diff --git a/ld/configure b/ld/configure
index 17604bb..38f9739 100755
--- a/ld/configure
+++ b/ld/configure
@@ -790,6 +790,7 @@ enable_got
enable_compressed_debug_sections
enable_new_dtags
enable_relro
+enable_separate_code
enable_default_hash_style
enable_werror
enable_build_warnings
@@ -1451,6 +1452,7 @@ Optional Features:
compress debug sections by default]
--enable-new-dtags set DT_RUNPATH instead of DT_RPATH by default]
--enable-relro enable -z relro in ELF linker by default
+ --enable-separate-code enable -z separate-code in ELF linker by default
--enable-default-hash-style={sysv,gnu,both}
use this default hash style
--enable-werror treat compile warnings as errors
@@ -11725,7 +11727,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11728 "configure"
+#line 11730 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11831,7 +11833,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11834 "configure"
+#line 11836 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15567,6 +15569,17 @@ if test "${enable_relro+set}" = set; then :
esac
fi
+# Decide if -z separate-code should be enabled in ELF linker by default.
+ac_default_ld_z_separate_code=unset
+# Check whether --enable-separate-code was given.
+if test "${enable_separate_code+set}" = set; then :
+ enableval=$enable_separate_code; case "${enableval}" in
+ yes) ac_default_ld_z_separate_code=1 ;;
+ no) ac_default_ld_z_separate_code=0 ;;
+esac
+fi
+
+
# Decide which "--hash-style" to use by default
# Provide a configure time option to override our default.
# Check whether --enable-default-hash-style was given.
@@ -17258,6 +17271,15 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+if test "${ac_default_ld_z_separate_code}" = unset; then
+ ac_default_ld_z_separate_code=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_LD_Z_SEPARATE_CODE $ac_default_ld_z_separate_code
+_ACEOF
+
+
cat >>confdefs.h <<_ACEOF
#define DEFAULT_EMIT_SYSV_HASH $ac_default_emit_sysv_hash