|
From: <sv...@va...> - 2017-07-28 20:49:30
|
Author: iraisr
Date: Fri Jul 28 21:49:20 2017
New Revision: 16463
Log:
Check whether it is ok to use compiler flag '-pie'.
Some compilers actually do not support -pie and report its usage
as an error. We need to check if it is safe to use it first.
n-i-bz
Modified:
trunk/configure.ac
trunk/gdbserver_tests/Makefile.am
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Jul 28 21:49:20 2017
@@ -2177,6 +2177,27 @@
AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
+# Does this compiler and linker support -pie?
+# Some compilers actually do not support -pie and report its usage
+# as an error. We need to check if it is safe to use it first.
+
+AC_MSG_CHECKING([if gcc accepts -pie])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-pie"
+
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
+ return 0;
+]])], [
+AC_SUBST([FLAG_PIE], ["-pie"])
+AC_MSG_RESULT([yes])
+], [
+AC_SUBST([FLAG_PIE], [""])
+AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+
# Does this compiler support -no-pie?
# On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
# default. However this gets in the way with some tests, we use -no-pie
Modified: trunk/gdbserver_tests/Makefile.am
==============================================================================
--- trunk/gdbserver_tests/Makefile.am (original)
+++ trunk/gdbserver_tests/Makefile.am Fri Jul 28 21:49:20 2017
@@ -167,5 +167,5 @@
LDADD = -lpthread
-main_pic_LDFLAGS = -pie
+main_pic_LDFLAGS = @FLAG_PIE@
main_pic_CFLAGS = $(AM_CFLAGS) -fPIC
|