]> sourceware.org Git - glibc.git/commitdiff
configure: Check for static PIE support
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 20 Jan 2021 12:26:31 +0000 (12:26 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 21 Jan 2021 15:54:50 +0000 (15:54 +0000)
Add SUPPORT_STATIC_PIE that targets can define if they support
static PIE. This requires PI_STATIC_AND_HIDDEN support and various
linker features as described in

  commit 9d7a3741c9e59eba87fb3ca6b9f979befce07826
  Add --enable-static-pie configure option to build static PIE [BZ #19574]

Currently defined on x86_64, i386 and aarch64 where static PIE is
known to work.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
config.h.in
configure
configure.ac
sysdeps/aarch64/configure
sysdeps/aarch64/configure.ac
sysdeps/i386/configure
sysdeps/i386/configure.ac
sysdeps/x86_64/configure
sysdeps/x86_64/configure.ac

index 947feeff36704fddcfe91169d161b20b327f7183..06ee8ae26a0eb8332cb6c0b85cea2cf7aaab8b09 100644 (file)
 /* Build glibc with tunables support.  */
 #define HAVE_TUNABLES 0
 
+/* Define if static PIE is supported.  */
+#undef SUPPORT_STATIC_PIE
+
 /* Define if static PIE is enabled.  */
 #define ENABLE_STATIC_PIE 0
 
index 49f7b32b52b23b505c2e4e3c0008ee9d7ff4f1cf..1dc3af60b4146ba5f9fd251a6820e21752c65444 100755 (executable)
--- a/configure
+++ b/configure
@@ -6814,6 +6814,19 @@ libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
 
 
 if test "$static_pie" = yes; then
+  # Check target support for static PIE
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef SUPPORT_STATIC_PIE
+# error static PIE is not supported
+#endif
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  as_fn_error $? "the architecture does not support static PIE" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   # The linker must support --no-dynamic-linker.
   if test "$libc_cv_no_dynamic_linker" != yes; then
     as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5
index 341d4eeac2622bac14f48b7b17bea4a18d4d9324..dfebb8a7cc1cac7e4d527448cba6804d7c58ba51 100644 (file)
@@ -1831,6 +1831,10 @@ libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
 AC_SUBST(libc_cv_multidir)
 
 if test "$static_pie" = yes; then
+  # Check target support for static PIE
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
+# error static PIE is not supported
+#endif]])], , AC_MSG_ERROR([the architecture does not support static PIE]))
   # The linker must support --no-dynamic-linker.
   if test "$libc_cv_no_dynamic_linker" != yes; then
     AC_MSG_ERROR([linker support for --no-dynamic-linker needed])
index 5f5f3cc44ce4c7ba1279f9dac30e134b1f0de1d3..83c3a23e4453c5880adadaffc943a9a85422b9d9 100644 (file)
@@ -6,6 +6,10 @@
 $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
 
 
+# Static PIE is supported.
+$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
+
+
 # We check to see if the compiler and flags are
 # selecting the big endian ABI and if they are then
 # we set libc_cv_aarch64_be to yes which causes
index 180a16a29fe95073ccbec1eec0609e13b8505223..66f755078acdc6c5b456a81f2ea348871d17fb64 100644 (file)
@@ -5,6 +5,9 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # The exception is -mcmodel=large which is unsupported with PIC/PIE.
 AC_DEFINE(PI_STATIC_AND_HIDDEN)
 
+# Static PIE is supported.
+AC_DEFINE(SUPPORT_STATIC_PIE)
+
 # We check to see if the compiler and flags are
 # selecting the big endian ABI and if they are then
 # we set libc_cv_aarch64_be to yes which causes
index 90c63caf351d9c1fb6a556b4bea84b1330449a84..bb482ca16cffb9bec0a88360290152e1901e353b 100644 (file)
@@ -117,3 +117,6 @@ if test x"$multi_arch" != xno; then
   $as_echo "#define NO_HIDDEN_EXTERN_FUNC_IN_PIE 1" >>confdefs.h
 
 fi
+
+$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
+
index 6d2068d2b3e1f54dc42bc2e63dcec7045c2299ba..5e43eb0adf99a5b08ccb1c2ea4abccf03e541dea 100644 (file)
@@ -77,3 +77,6 @@ dnl via PIC PLT in PIE, which requires setting up EBX register.
 if test x"$multi_arch" != xno; then
   AC_DEFINE(NO_HIDDEN_EXTERN_FUNC_IN_PIE)
 fi
+
+dnl Static PIE is supported.
+AC_DEFINE(SUPPORT_STATIC_PIE)
index 84f82c24068ef04b9ea55ad9bdc92cf1a70da0cf..198554d78894ebcb06bf90203b59d42f048e2586 100644 (file)
@@ -143,5 +143,8 @@ fi
 $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
 
 
+$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
+
+
 test -n "$critic_missing" && as_fn_error $? "
 *** $critic_missing" "$LINENO" 5
index cdaba0c075abfb2cca89d812cae32dd3e391dc16..ec776274af5c258d5c9bdffee16d1d0f77eca3cd 100644 (file)
@@ -82,5 +82,8 @@ dnl It is always possible to access static and hidden symbols in an
 dnl position independent way.
 AC_DEFINE(PI_STATIC_AND_HIDDEN)
 
+dnl Static PIE is supported.
+AC_DEFINE(SUPPORT_STATIC_PIE)
+
 test -n "$critic_missing" && AC_MSG_ERROR([
 *** $critic_missing])
This page took 0.05973 seconds and 5 git commands to generate.