From ad73bc04ae5384d06c0b0843281732cae5dc634e Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 21 Aug 2019 19:12:19 +0200 Subject: Add configure options --enable-pie and --disable-pie --- HOWTO/INSTALL.md | 1 + configure.src | 16 +++++++++++++--- erts/aclocal.m4 | 2 ++ lib/erl_interface/configure.in | 4 ++++ make/configure.in | 4 ++++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/HOWTO/INSTALL.md b/HOWTO/INSTALL.md index 674454bc8e..0c7de9d4e6 100644 --- a/HOWTO/INSTALL.md +++ b/HOWTO/INSTALL.md @@ -353,6 +353,7 @@ Some of the available `configure` options are: `(g)cc` * `--enable-m32-build` - Build 32-bit binaries using the `-m32` flag to `(g)cc` +* `--{enable,disable}-pie` - Build position independent executable binaries. * `--with-assumed-cache-line-size=SIZE` - Set assumed cache-line size in bytes. Default is 64. Valid values are powers of two between and including 16 and 8192. The runtime system use this value in order to diff --git a/configure.src b/configure.src index 4b748f2545..ff39a58aa9 100644 --- a/configure.src +++ b/configure.src @@ -37,6 +37,8 @@ unset CDPATH default_cflags="-g -O2" +pie_cflags= +pie_ldflags= mXY_build= static_cache= @@ -125,6 +127,14 @@ while test $# != 0; do if test "$mXY_build" = "-m32"; then mXY_build= fi;; + --enable-pie) + pie_cflags="-fPIE" + pie_ldflags="-pie" + ;; + --disable-pie) + pie_cflags="-fno-PIE" + pie_ldflags="-no-pie" + ;; CFLAGS=* | LDFLAGS=*) flgs_var=`expr "$1" : '\([^=]*\)=.*'` flgs_val=`expr "$1" : '[^=]*=\(.*\)'` @@ -263,7 +273,7 @@ case "$help" in exit 0;; esac -if test "$mXY_build" = ""; then +if test "$mXY_build" = "" && test "$pie_cflags" = ""; then if test "$CFLAGS" != ""; then config_arguments="$config_arguments CFLAGS='$CFLAGS'" unset CFLAGS @@ -277,9 +287,9 @@ else if test "$CFLAGS" = ""; then CFLAGS=$default_cflags fi - config_arguments="$config_arguments CFLAGS='$mXY_build $CFLAGS'" + config_arguments="$config_arguments CFLAGS='$mXY_build $pie_cflags $CFLAGS'" unset CFLAGS - config_arguments="$config_arguments LDFLAGS='$mXY_build $LDFLAGS'" + config_arguments="$config_arguments LDFLAGS='$mXY_build $pie_ldflags $LDFLAGS'" unset LDFLAGS case $mXY_build in -m32) diff --git a/erts/aclocal.m4 b/erts/aclocal.m4 index e2b7e1eada..3a9872f891 100644 --- a/erts/aclocal.m4 +++ b/erts/aclocal.m4 @@ -2938,6 +2938,8 @@ DED_CFLAGS="$CFLAGS $CPPFLAGS $DED_CFLAGS" if test "x$GCC" = xyes; then DED_STATIC_CFLAGS="$DED_CFLAGS" DED_CFLAGS="$DED_CFLAGS -fPIC" + # Remove -fPIE and -fno-PIE + DED_CFLAGS=`echo $DED_CFLAGS | sed 's/-f\(no-\)\?PIE//g'` fi DED_EXT=so diff --git a/lib/erl_interface/configure.in b/lib/erl_interface/configure.in index f0e9b2eb3f..540a9eaa73 100644 --- a/lib/erl_interface/configure.in +++ b/lib/erl_interface/configure.in @@ -330,6 +330,10 @@ if test "X$host" = "Xwin32"; then LIB_CFLAGS="$CFLAGS" else if test "x$GCC" = xyes; then + # Remove all PIE stuff + CFLAGS=`echo $CFLAGS | sed 's/-f\(no-\)\?PIE//g'` + LDFLAGS=`echo $LDFLAGS | sed 's/-\(no-\)\?pie//g'` + LIB_CFLAGS="$CFLAGS -fPIC" else LIB_CFLAGS="$CFLAGS" diff --git a/make/configure.in b/make/configure.in index c4b89c4f45..64680d55ca 100644 --- a/make/configure.in +++ b/make/configure.in @@ -339,6 +339,10 @@ AS_HELP_STRING([--enable-m32-build], esac ],enable_m32_build=no) +AC_ARG_ENABLE(pie, +AS_HELP_STRING([--enable-pie], [build position independent executables]) +AS_HELP_STRING([--disable-pie], [do no build position independent executables])) + AC_ARG_WITH(libatomic_ops, AS_HELP_STRING([--with-libatomic_ops=PATH], [specify and prefer usage of libatomic_ops in the ethread library])) -- cgit v1.2.1