diff mbox series

[5/5] Enable static-pie on powerpc64

Message ID Ye4lrkAX7ED7mq0V@squeak.grove.modra.org
State Superseded
Headers show
Series [PowerPC64] Use medium model toc accesses throughout | expand

Commit Message

Alan Modra Jan. 24, 2022, 4:06 a.m. UTC
Also regenerate another powerpc configure file that wasn't done when
making the corresponding configure.ac change.

With this series and latest gcc + binutils I get mostly working
static-pie on powerpc64le-linux.  There are a number of regressions:
FAIL: elf/tst-glibc-hwcaps-cache
FAIL: elf/tst-glibc-hwcaps-prepend-cache
FAIL: elf/tst-ldconfig-bad-aux-cache
FAIL: elf/tst-ldconfig-ld_so_conf-update
FAIL: elf/tst-tlsifunc-static

	* sysdeps/powerpc/powerpc64/configure.ac (SUPPORT_STATIC_PIE): Define.
	(PI_STATIC_AND_HIDDEN): Define.
	* sysdeps/powerpc/powerpc64/configure: Regenerate.
	* sysdeps/unix/sysv/linux/powerpc/configure: Regenerate.

Comments

Florian Weimer Jan. 27, 2022, 6:39 p.m. UTC | #1
* Alan Modra via Libc-alpha:

> diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac
> index 1f3d54414c..5eedd2f81c 100644
> --- a/sysdeps/powerpc/powerpc64/configure.ac
> +++ b/sysdeps/powerpc/powerpc64/configure.ac
> @@ -1,6 +1,13 @@
>  GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
>  # Local configure fragment for sysdeps/powerpc/powerpc64.
>  
> +dnl It is always possible to access static and hidden symbols in an
> +dnl position independent way.
> +AC_DEFINE(PI_STATIC_AND_HIDDEN)

I must say that this is the most surprising glibc patch I've seen in a
while.

But I think it's true—once you've set up the TOC pointer, the link
editor can generate a fixed offset offset for local and hidden symbols.
Has this always been the case for powerpc64le?

Thanks,
Florian
Alan Modra Jan. 28, 2022, 8:45 a.m. UTC | #2
On Thu, Jan 27, 2022 at 07:39:44PM +0100, Florian Weimer wrote:
> * Alan Modra via Libc-alpha:
> 
> > diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac
> > index 1f3d54414c..5eedd2f81c 100644
> > --- a/sysdeps/powerpc/powerpc64/configure.ac
> > +++ b/sysdeps/powerpc/powerpc64/configure.ac
> > @@ -1,6 +1,13 @@
> >  GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> >  # Local configure fragment for sysdeps/powerpc/powerpc64.
> >  
> > +dnl It is always possible to access static and hidden symbols in an
> > +dnl position independent way.
> > +AC_DEFINE(PI_STATIC_AND_HIDDEN)
> 
> I must say that this is the most surprising glibc patch I've seen in a
> while.
> 
> But I think it's true—once you've set up the TOC pointer, the link
> editor can generate a fixed offset offset for local and hidden symbols.
> Has this always been the case for powerpc64le?

2010-06-25 binutils git commit ba761f19f5.  I'm not at all sure the
optimisation was perfect in binutils-2.21, but yes, medium and large
code model toc-indirect code has been converted to toc-relative for a
long time.
diff mbox series

Patch

diff --git a/sysdeps/powerpc/powerpc64/configure b/sysdeps/powerpc/powerpc64/configure
index fddea0355a..4a219ab8ac 100644
--- a/sysdeps/powerpc/powerpc64/configure
+++ b/sysdeps/powerpc/powerpc64/configure
@@ -1,6 +1,13 @@ 
 # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
  # Local configure fragment for sysdeps/powerpc/powerpc64.
 
+$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
+
+
+# Static PIE is supported.
+$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for support for overlapping .opd entries" >&5
 $as_echo_n "checking for support for overlapping .opd entries... " >&6; }
 if ${libc_cv_overlapping_opd+:} false; then :
diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac
index 1f3d54414c..5eedd2f81c 100644
--- a/sysdeps/powerpc/powerpc64/configure.ac
+++ b/sysdeps/powerpc/powerpc64/configure.ac
@@ -1,6 +1,13 @@ 
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/powerpc/powerpc64.
 
+dnl It is always possible to access static and hidden symbols in an
+dnl position independent way.
+AC_DEFINE(PI_STATIC_AND_HIDDEN)
+
+# Static PIE is supported.
+AC_DEFINE(SUPPORT_STATIC_PIE)
+
 AC_CACHE_CHECK(for support for overlapping .opd entries,
 libc_cv_overlapping_opd, [dnl
 libc_cv_overlapping_opd=no
diff --git a/sysdeps/unix/sysv/linux/powerpc/configure b/sysdeps/unix/sysv/linux/powerpc/configure
index a4c809fd98..7183573bc0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/configure
+++ b/sysdeps/unix/sysv/linux/powerpc/configure
@@ -93,7 +93,13 @@  EOF
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }
   then
-    libc_linker_feature=yes
+    if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,--no-tls-get-addr-optimize -nostdlib \
+	-nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \
+	| grep "warning: --no-tls-get-addr-optimize ignored" > /dev/null 2>&1; then
+      true
+    else
+      libc_linker_feature=yes
+    fi
   fi
   rm -f conftest*
 fi