Blob Blame History Raw
From: Sverker Eriksson <sverker@erlang.org>
Date: Tue, 8 Nov 2016 16:52:32 +0100
Subject: [PATCH] erts: Disable -fPIE for HiPE on x86_64


diff --git a/erts/configure.in b/erts/configure.in
index 4ade3b3086..e99d22a0af 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -2887,6 +2887,22 @@ case $ARCH-$OPSYS in
 		;;
 esac
 
+dnl Check to disable -fPIE and friends for HiPE on amd64
+if test X${enable_hipe} = Xyes && test X$ARCH = Xamd64; then
+   AC_TRY_COMPILE(, [#if defined(__pie__) || defined(__PIE__)
+		     #error -fPIE is enabled by default
+		     #endif],
+		    [AC_MSG_NOTICE([No -fPIE enabled by default])],
+		    [AC_MSG_WARN([Security feature -fPIE will be disabled for HiPE])
+		     STATIC_CFLAGS="-fno-PIE $STATIC_CFLAGS"
+		     saved_LDFLAGS=$LDFLAGS
+		     LDFLAGS="-no-pie $LDFLAGS"
+		     AC_TRY_LINK(,, [],
+			[AC_MSG_WARN([Linked does not accept option -no-pie])
+			 LDFLAGS=$saved_LDFLAGS])])
+
+fi
+
 if test X${enable_fp_exceptions} = Xauto ; then
    case $host_os in
    	*linux*)