Blame otp-0008-erts-Disable-fPIE-for-HiPE-on-x86_64.patch

d8d49b
From: Sverker Eriksson <sverker@erlang.org>
d8d49b
Date: Tue, 8 Nov 2016 16:52:32 +0100
d8d49b
Subject: [PATCH] erts: Disable -fPIE for HiPE on x86_64
d8d49b
d8d49b
d8d49b
diff --git a/erts/configure.in b/erts/configure.in
d8d49b
index 7455516..7489f8a 100644
d8d49b
--- a/erts/configure.in
d8d49b
+++ b/erts/configure.in
d8d49b
@@ -2778,6 +2778,23 @@ if test "$cross_compiling" != "yes" && test X${enable_hipe} != Xno; then
d8d49b
   fi
d8d49b
 fi
d8d49b
 
d8d49b
+dnl Check to disable -fPIE and friends for HiPE on amd64
d8d49b
+if test X${enable_hipe} = Xyes && test X$ARCH = Xamd64; then
d8d49b
+   AC_TRY_COMPILE(, [#if defined(__pie__) || defined(__PIE__)
d8d49b
+		     #error -fPIE is enabled by default
d8d49b
+		     #endif],
d8d49b
+		    [AC_MSG_NOTICE([No -fPIE enabled by default])],
d8d49b
+		    [AC_MSG_WARN([Security feature -fPIE will be disabled for HiPE])
d8d49b
+		     STATIC_CFLAGS="-fno-PIE $STATIC_CFLAGS"
d8d49b
+		     saved_LDFLAGS=$LDFLAGS
d8d49b
+		     LDFLAGS="-no-pie $LDFLAGS"
d8d49b
+		     AC_TRY_LINK(,, [],
d8d49b
+			[AC_MSG_WARN([Linked does not accept option -no-pie])
d8d49b
+			 LDFLAGS=$saved_LDFLAGS])])
d8d49b
+
d8d49b
+fi
d8d49b
+
d8d49b
+
d8d49b
 if test X${enable_fp_exceptions} = Xauto ; then
d8d49b
    case $host_os in
d8d49b
    	*linux*)