diff mbox series

[v3,1/5] configure: Require PI_STATIC_AND_HIDDEN for static pie

Message ID 5a446e7a422bc4edd49384884106383485d05c08.1610471272.git.szabolcs.nagy@arm.com
State Superseded
Headers show
Series fix ifunc with static pie [BZ #27072] | expand

Commit Message

Szabolcs Nagy Jan. 12, 2021, 5:21 p.m. UTC
The glibc static pie self relocation code relies on that local
symbols can be accessed without dynamic relocations in position
independent code.
---
 configure    | 14 ++++++++++++++
 configure.ac |  5 +++++
 2 files changed, 19 insertions(+)

Comments

Adhemerval Zanella Jan. 12, 2021, 6:38 p.m. UTC | #1
On 12/01/2021 14:21, Szabolcs Nagy via Libc-alpha wrote:
> The glibc static pie self relocation code relies on that local
> symbols can be accessed without dynamic relocations in position
> independent code.

LGTM with the nit below.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  configure    | 14 ++++++++++++++
>  configure.ac |  5 +++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/configure b/configure
> index 49f7b32b52..81fd116d87 100755
> --- a/configure
> +++ b/configure
> @@ -6818,6 +6818,20 @@ if test "$static_pie" = yes; then
>    if test "$libc_cv_no_dynamic_linker" != yes; then
>      as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5
>    fi
> +
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#ifndef PI_STATIC_AND_HIDDEN
> +# error static pie depends on PI_STATIC_AND_HIDDEN
> +#endif
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +
> +else
> +  as_fn_error $? "the target does not support static pie" "$LINENO" 5
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +
>    # Default to PIE.
>    libc_cv_pie_default=yes
>    $as_echo "#define ENABLE_STATIC_PIE 1" >>confdefs.h
> diff --git a/configure.ac b/configure.ac
> index 341d4eeac2..8b7c99001d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1835,6 +1835,11 @@ if test "$static_pie" = yes; then
>    if test "$libc_cv_no_dynamic_linker" != yes; then
>      AC_MSG_ERROR([linker support for --no-dynamic-linker needed])
>    fi
> +
> +  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PI_STATIC_AND_HIDDEN
> +# error static pie depends on PI_STATIC_AND_HIDDEN
> +#endif]])], , AC_MSG_ERROR([the target does not support static pie]))
> +

I think we need a more explicit error message stating that the 
architecture does not support static pie, this might give the user 
the impression either a compiler options would fix it or, worse,
if it defines PI_STATIC_AND_HIDDEN on architecture configure.ac
it would fix it.  Maybe "the architecture does not support static pie".

>    # Default to PIE.
>    libc_cv_pie_default=yes
>    AC_DEFINE(ENABLE_STATIC_PIE)
>
diff mbox series

Patch

diff --git a/configure b/configure
index 49f7b32b52..81fd116d87 100755
--- a/configure
+++ b/configure
@@ -6818,6 +6818,20 @@  if test "$static_pie" = yes; then
   if test "$libc_cv_no_dynamic_linker" != yes; then
     as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5
   fi
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef PI_STATIC_AND_HIDDEN
+# error static pie depends on PI_STATIC_AND_HIDDEN
+#endif
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  as_fn_error $? "the target does not support static pie" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
   # Default to PIE.
   libc_cv_pie_default=yes
   $as_echo "#define ENABLE_STATIC_PIE 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 341d4eeac2..8b7c99001d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1835,6 +1835,11 @@  if test "$static_pie" = yes; then
   if test "$libc_cv_no_dynamic_linker" != yes; then
     AC_MSG_ERROR([linker support for --no-dynamic-linker needed])
   fi
+
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PI_STATIC_AND_HIDDEN
+# error static pie depends on PI_STATIC_AND_HIDDEN
+#endif]])], , AC_MSG_ERROR([the target does not support static pie]))
+
   # Default to PIE.
   libc_cv_pie_default=yes
   AC_DEFINE(ENABLE_STATIC_PIE)