public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v5 3/7] configure: Check for static PIE support
Date: Wed, 20 Jan 2021 15:30:48 +0000	[thread overview]
Message-ID: <51119c6aa5f2a7ff0966d5c9fda4a61d781591fb.1611155254.git.szabolcs.nagy@arm.com> (raw)
In-Reply-To: <cover.1611155254.git.szabolcs.nagy@arm.com>

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.
---
 config.h.in                  |  3 +++
 configure                    | 13 +++++++++++++
 configure.ac                 |  4 ++++
 sysdeps/aarch64/configure    |  4 ++++
 sysdeps/aarch64/configure.ac |  3 +++
 sysdeps/i386/configure       |  3 +++
 sysdeps/i386/configure.ac    |  3 +++
 sysdeps/x86_64/configure     |  3 +++
 sysdeps/x86_64/configure.ac  |  3 +++
 9 files changed, 39 insertions(+)

diff --git a/config.h.in b/config.h.in
index 947feeff36..06ee8ae26a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -259,6 +259,9 @@
 /* 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
 
diff --git a/configure b/configure
index 49f7b32b52..1dc3af60b4 100755
--- 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
diff --git a/configure.ac b/configure.ac
index 341d4eeac2..dfebb8a7cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure
index 5f5f3cc44c..83c3a23e44 100644
--- a/sysdeps/aarch64/configure
+++ b/sysdeps/aarch64/configure
@@ -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
diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac
index 180a16a29f..66f755078a 100644
--- a/sysdeps/aarch64/configure.ac
+++ b/sysdeps/aarch64/configure.ac
@@ -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
diff --git a/sysdeps/i386/configure b/sysdeps/i386/configure
index 90c63caf35..bb482ca16c 100644
--- a/sysdeps/i386/configure
+++ b/sysdeps/i386/configure
@@ -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
+
diff --git a/sysdeps/i386/configure.ac b/sysdeps/i386/configure.ac
index 6d2068d2b3..5e43eb0adf 100644
--- a/sysdeps/i386/configure.ac
+++ b/sysdeps/i386/configure.ac
@@ -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)
diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure
index 84f82c2406..198554d788 100644
--- a/sysdeps/x86_64/configure
+++ b/sysdeps/x86_64/configure
@@ -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
diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
index cdaba0c075..ec776274af 100644
--- a/sysdeps/x86_64/configure.ac
+++ b/sysdeps/x86_64/configure.ac
@@ -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])
-- 
2.17.1


  parent reply	other threads:[~2021-01-20 15:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 15:29 [PATCH v5 0/7] fix ifunc with static pie [BZ #27072] Szabolcs Nagy
2021-01-20 15:30 ` [PATCH v5 1/7] elf: Make the tunable struct definition internal only Szabolcs Nagy
2021-01-20 15:30 ` [PATCH v5 2/7] elf: Avoid RELATIVE relocs in __tunables_init Szabolcs Nagy
2021-01-20 15:30 ` Szabolcs Nagy [this message]
2021-01-21 13:59   ` [PATCH v5 3/7] configure: Check for static PIE support Adhemerval Zanella
2021-01-20 15:31 ` [PATCH v5 4/7] csu: Avoid weak ref for __ehdr_start in static PIE Szabolcs Nagy
2021-01-20 15:36   ` H.J. Lu
2021-01-21 14:01   ` Adhemerval Zanella
2021-01-20 15:31 ` [PATCH v5 5/7] Use hidden visibility for early static PIE code Szabolcs Nagy
2021-01-21 14:04   ` Adhemerval Zanella
2021-01-20 15:31 ` [PATCH v5 6/7] csu: Move static pie self relocation later [BZ #27072] Szabolcs Nagy
2021-01-21 14:07   ` Adhemerval Zanella
2021-01-21 15:38     ` Szabolcs Nagy
2021-01-20 15:31 ` [PATCH v5 7/7] Make libc symbols hidden in static PIE Szabolcs Nagy
2021-01-21 14:10   ` Adhemerval Zanella
2021-01-21 15:44     ` Szabolcs Nagy
2021-01-22  1:25   ` Tulio Magno Quites Machado Filho
2021-01-22  9:41     ` Szabolcs Nagy
2021-01-27  9:44   ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51119c6aa5f2a7ff0966d5c9fda4a61d781591fb.1611155254.git.szabolcs.nagy@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).