29e444
#
29e444
# All patches are from upstream and provide support for correct lib
29e444
# directory for AArch64.
29e444
#
29e444
# From 37bf2f1f983e37c0d87a1e34cd3d8a228ead5e16 Mon Sep 17 00:00:00 2001
29e444
# From: Andreas Schwab <schwab@suse.de>
29e444
# Date: Thu, 4 Apr 2013 12:22:22 -0400
29e444
# Subject: [PATCH 2/4] Add support for rtld directory different from slib
29e444
#  directory
29e444
# 
29e444
# ---
29e444
#  ChangeLog         | 15 +++++++++++++++
29e444
#  Makeconfig        | 10 ++++++++--
29e444
#  Makerules         |  4 ++--
29e444
#  config.make.in    |  1 +
29e444
#  configure         |  2 ++
29e444
#  configure.in      |  1 +
29e444
#  elf/Makefile      | 11 ++++++-----
29e444
#  scripts/rellns-sh | 17 +++++++++++++++--
29e444
#  8 files changed, 50 insertions(+), 11 deletions(-)
29e444
# 
29e444
# From 937dd2d4a5da7d51b87261b037e22dfca05face7 Mon Sep 17 00:00:00 2001
29e444
# From: Marcus Shawcroft <marcus.shawcroft@linaro.org>
29e444
# Date: Thu, 4 Apr 2013 12:26:55 -0400
29e444
# Subject: [PATCH 4/4] Correct missed use of $(rtlddir).
29e444
# 
29e444
# ---
29e444
#  ChangeLog | 4 ++++
29e444
#  Makerules | 2 +-
29e444
#  2 files changed, 5 insertions(+), 1 deletion(-)
29e444
# 
29e444
# From bcce68c6dc678b443e7f140d664ba1fa49c0ceaa Mon Sep 17 00:00:00 2001
29e444
# From: Andreas Schwab <schwab@suse.de>
29e444
# Date: Thu, 4 Apr 2013 12:23:43 -0400
29e444
# Subject: [PATCH 3/4] aarch64: Move rtld link to /lib
29e444
# 
29e444
# ---
29e444
#  ports/ChangeLog.aarch64                            | 6 ++++++
29e444
#  ports/sysdeps/unix/sysv/linux/aarch64/configure    | 1 +
29e444
#  ports/sysdeps/unix/sysv/linux/aarch64/configure.in | 1 +
29e444
#  3 files changed, 8 insertions(+)
29e444
# 
29e444
# From 05bc48a20b8c20574bc59a048750f0dd77fd6e23 Mon Sep 17 00:00:00 2001
29e444
# From: Andreas Schwab <schwab@suse.de>
29e444
# Date: Thu, 4 Apr 2013 12:02:53 -0400
29e444
# Subject: [PATCH 1/4] aarch64: use lib64 as default lib and slib directory
29e444
# 
29e444
# ---
29e444
#  ports/ChangeLog.aarch64                            |  6 ++++++
29e444
#  ports/sysdeps/unix/sysv/linux/aarch64/configure    | 13 +++++++++++++
29e444
#  ports/sysdeps/unix/sysv/linux/aarch64/configure.in | 12 ++++++++++++
29e444
#  3 files changed, 31 insertions(+)
29e444
# 
29e444
# commit 446737706c186b33529a2c07fcb6f0cc10b2d1ea
29e444
# Author: Andreas Schwab <schwab@suse.de>
29e444
# Date:   Tue Mar 19 10:13:46 2013 +0100
29e444
#
29e444
#    s390x: Move rtld link to /lib
29e444
#
29e444
diff -urN glibc-2.17-c758a686.orig/config.make.in glibc-2.17-c758a686/config.make.in
29e444
--- glibc-2.17-c758a686.orig/config.make.in	2013-10-28 10:56:39.996320904 -0400
29e444
+++ glibc-2.17-c758a686/config.make.in	2013-10-28 10:56:57.773317467 -0400
29e444
@@ -11,6 +11,7 @@
29e444
 datadir = @datadir@
29e444
 libdir = @libdir@
29e444
 slibdir = @libc_cv_slibdir@
29e444
+rtlddir = @libc_cv_rtlddir@
29e444
 localedir = @libc_cv_localedir@
29e444
 sysconfdir = @libc_cv_sysconfdir@
29e444
 libexecdir = @libexecdir@
29e444
diff -urN glibc-2.17-c758a686.orig/configure glibc-2.17-c758a686/configure
29e444
--- glibc-2.17-c758a686.orig/configure	2013-10-28 10:56:39.935320916 -0400
29e444
+++ glibc-2.17-c758a686/configure	2013-10-28 10:56:57.775317467 -0400
29e444
@@ -594,6 +594,7 @@
29e444
 libc_cv_localstatedir
29e444
 libc_cv_sysconfdir
29e444
 libc_cv_localedir
29e444
+libc_cv_rtlddir
29e444
 libc_cv_slibdir
29e444
 old_glibc_headers
29e444
 use_nscd
29e444
@@ -7600,6 +7601,7 @@
29e444
 
29e444
 
29e444
 
29e444
+
29e444
 
29e444
 
29e444
 
29e444
diff -urN glibc-2.17-c758a686.orig/configure.in glibc-2.17-c758a686/configure.in
29e444
--- glibc-2.17-c758a686.orig/configure.in	2013-10-28 10:56:39.902320923 -0400
29e444
+++ glibc-2.17-c758a686/configure.in	2013-10-28 10:56:57.776317467 -0400
29e444
@@ -2127,6 +2127,7 @@
29e444
 AC_SUBST(old_glibc_headers)
29e444
 
29e444
 AC_SUBST(libc_cv_slibdir)
29e444
+AC_SUBST(libc_cv_rtlddir)
29e444
 AC_SUBST(libc_cv_localedir)
29e444
 AC_SUBST(libc_cv_sysconfdir)
29e444
 AC_SUBST(libc_cv_localstatedir)
29e444
diff -urN glibc-2.17-c758a686.orig/elf/Makefile glibc-2.17-c758a686/elf/Makefile
29e444
--- glibc-2.17-c758a686.orig/elf/Makefile	2013-10-28 10:56:40.127320879 -0400
29e444
+++ glibc-2.17-c758a686/elf/Makefile	2013-10-28 10:56:57.776317467 -0400
29e444
@@ -66,7 +66,7 @@
29e444
 ifeq (yes,$(build-shared))
29e444
 extra-objs	= $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
29e444
 generated	+= librtld.os dl-allobjs.os ld.so ldd
29e444
-install-others	= $(inst_slibdir)/$(rtld-installed-name)
29e444
+install-others = $(inst_rtlddir)/$(rtld-installed-name)
29e444
 install-bin-script = ldd
29e444
 endif
29e444
 
29e444
@@ -341,7 +341,7 @@
29e444
 	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
29e444
 
29e444
 # interp.c exists just to get this string into the libraries.
29e444
-CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' \
29e444
+CFLAGS-interp.c = -D'RUNTIME_LINKER="$(rtlddir)/$(rtld-installed-name)"' \
29e444
 		  -DNOT_IN_libc=1
29e444
 $(objpfx)interp.os: $(common-objpfx)config.make
29e444
 
29e444
@@ -373,18 +373,19 @@
29e444
 	$(make-target-directory)
29e444
 	$(do-install-program)
29e444
 
29e444
-$(inst_slibdir)/$(rtld-installed-name): \
29e444
+$(inst_rtlddir)/$(rtld-installed-name): \
29e444
   $(inst_slibdir)/$(rtld-version-installed-name) \
29e444
   $(inst_slibdir)/libc-$(version).so
29e444
+	$(make-target-directory)
29e444
 	$(make-shlib-link)
29e444
 
29e444
 # Special target called by parent to install just the dynamic linker.
29e444
 .PHONY: ldso_install
29e444
-ldso_install: $(inst_slibdir)/$(rtld-installed-name)
29e444
+ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
29e444
 endif
29e444
 
29e444
 
29e444
-common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
29e444
+common-ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
29e444
 		     -e 's%@VERSION@%$(version)%g' \
29e444
 		     -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
29e444
 		     -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g'
29e444
diff -urN glibc-2.17-c758a686.orig/Makeconfig glibc-2.17-c758a686/Makeconfig
29e444
--- glibc-2.17-c758a686.orig/Makeconfig	2013-10-28 10:56:40.434320820 -0400
29e444
+++ glibc-2.17-c758a686/Makeconfig	2013-10-28 10:56:57.772317467 -0400
29e444
@@ -148,12 +148,18 @@
29e444
 endif
29e444
 inst_libdir = $(install_root)$(libdir)
29e444
 
29e444
-# Where to install the shared library and dynamic linker.
29e444
+# Where to install the shared library.
29e444
 ifndef slibdir
29e444
 slibdir = $(exec_prefix)/lib
29e444
 endif
29e444
 inst_slibdir = $(install_root)$(slibdir)
29e444
 
29e444
+# Where to install the dynamic linker.
29e444
+ifndef rtlddir
29e444
+rtlddir = $(slibdir)
29e444
+endif
29e444
+inst_rtlddir = $(install_root)$(rtlddir)
29e444
+
29e444
 # Prefix to put on files installed in $(libdir).  For libraries `libNAME.a',
29e444
 # the prefix is spliced between `lib' and the name, so the linker switch
29e444
 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
29e444
@@ -443,7 +449,7 @@
29e444
 endif
29e444
 ifndef config-LDFLAGS
29e444
 ifeq (yes,$(build-shared))
29e444
-config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
29e444
+config-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
29e444
 endif
29e444
 endif
29e444
 ifndef link-libc
29e444
diff -urN glibc-2.17-c758a686.orig/Makerules glibc-2.17-c758a686/Makerules
29e444
--- glibc-2.17-c758a686.orig/Makerules	2013-10-28 10:56:39.928320918 -0400
29e444
+++ glibc-2.17-c758a686/Makerules	2013-10-28 10:56:57.777317467 -0400
29e444
@@ -873,7 +873,7 @@
29e444
 symbolic-link-prog := $(common-objpfx)elf/sln
29e444
 symbolic-link-list := $(common-objpfx)elf/symlink.list
29e444
 define make-shlib-link
29e444
-echo $(<F) $@ >> $(symbolic-link-list)
29e444
+echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
29e444
 endef
29e444
 else # cross-compiling
29e444
 # We need a definition that can be used by elf/Makefile's install rules.
29e444
@@ -883,7 +883,7 @@
29e444
 ifndef make-shlib-link
29e444
 define make-shlib-link
29e444
 rm -f $@
29e444
-$(LN_S) $(
29e444
+$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
29e444
 endef
29e444
 endif
29e444
 
29e444
@@ -937,7 +937,7 @@
29e444
 	 cat $<; \
29e444
 	 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
29e444
 	      '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
29e444
-	      ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
29e444
+	      ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
29e444
 	) > $@.new
29e444
 	mv -f $@.new $@
29e444
 
29e444
diff -urN glibc-2.17-c758a686.orig/ports/sysdeps/unix/sysv/linux/aarch64/configure glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/configure
29e444
--- glibc-2.17-c758a686.orig/ports/sysdeps/unix/sysv/linux/aarch64/configure	2013-10-28 10:56:39.873320928 -0400
29e444
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/configure	2013-10-28 10:57:26.270311964 -0400
29e444
@@ -1,3 +1,17 @@
29e444
 # This file is generated from configure.in by Autoconf.  DO NOT EDIT!
29e444
+ # Local configure fragment for sysdeps/unix/sysv/linux/aarch64.
29e444
 
29e444
 arch_minimum_kernel=3.7.0
29e444
+
29e444
+test -n "$libc_cv_slibdir" ||
29e444
+case "$prefix" in
29e444
+  /usr | /usr/)
29e444
+    libc_cv_slibdir="/lib64"
29e444
+    libc_cv_rtlddir="/lib"
29e444
+    if test "$libdir" = '${exec_prefix}/lib'; then
29e444
+      libdir='${exec_prefix}/lib64';
29e444
+      # Locale data can be shared between 32bit and 64bit libraries
29e444
+      libc_cv_localedir='${exec_prefix}/lib/locale'
29e444
+    fi
29e444
+    ;;
29e444
+esac
29e444
diff -urN glibc-2.17-c758a686.orig/ports/sysdeps/unix/sysv/linux/aarch64/configure.in glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/configure.in
29e444
--- glibc-2.17-c758a686.orig/ports/sysdeps/unix/sysv/linux/aarch64/configure.in	2013-10-28 10:56:39.873320928 -0400
29e444
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/configure.in	2013-10-28 10:57:49.162307556 -0400
29e444
@@ -2,3 +2,16 @@
29e444
 # Local configure fragment for sysdeps/unix/sysv/linux/aarch64.
29e444
 
29e444
 arch_minimum_kernel=3.7.0
29e444
+
29e444
+test -n "$libc_cv_slibdir" ||
29e444
+case "$prefix" in
29e444
+  /usr | /usr/)
29e444
+    libc_cv_slibdir="/lib64"
29e444
+    libc_cv_rtlddir="/lib"
29e444
+    if test "$libdir" = '${exec_prefix}/lib'; then
29e444
+      libdir='${exec_prefix}/lib64';
29e444
+      # Locale data can be shared between 32bit and 64bit libraries
29e444
+      libc_cv_localedir='${exec_prefix}/lib/locale'
29e444
+    fi
29e444
+    ;;
29e444
+esac
29e444
diff -urN glibc-2.17-c758a686.orig/scripts/rellns-sh glibc-2.17-c758a686/scripts/rellns-sh
29e444
--- glibc-2.17-c758a686.orig/scripts/rellns-sh	2013-10-28 10:56:40.081320888 -0400
29e444
+++ glibc-2.17-c758a686/scripts/rellns-sh	2013-10-28 10:56:57.776317467 -0400
29e444
@@ -16,8 +16,17 @@
29e444
 # You should have received a copy of the GNU General Public License
29e444
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
29e444
 
29e444
+# With -p, instead of creating the link print the computed relative link
29e444
+# name.
29e444
+do_print=false
29e444
+case $1 in
29e444
+  -p)
29e444
+    do_print=true
29e444
+    shift
29e444
+    ;;
29e444
+esac
29e444
 if test $# -ne 2; then
29e444
-  echo "Usage: rellns SOURCE DEST" >&2
29e444
+  echo "Usage: rellns [-p] SOURCE DEST" >&2
29e444
   exit 1
29e444
 fi
29e444
 
29e444
@@ -70,4 +79,8 @@
29e444
   from=`echo $from | sed 's%^[^/]*/*%%'`
29e444
 done
29e444
 
29e444
-ln -s $rfrom$to $2
29e444
+if $do_print; then
29e444
+  echo "$rfrom$to"
29e444
+else
29e444
+  ln -s $rfrom$to $2
29e444
+fi
29e444
diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure
29e444
index 26327ca..70aaa90 100644
29e444
--- a/sysdeps/gnu/configure
29e444
+++ b/sysdeps/gnu/configure
29e444
@@ -9,12 +9,17 @@
29e444
 case "$prefix" in
29e444
 /usr | /usr/)
29e444
   # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
29e444
-  # Allow earlier configure scripts to handle libc_cv_slibdir, libdir,
29e444
-  # and libc_cv_localedir.
29e444
+  # Allow earlier configure scripts to handle libc_cv_slibdir,
29e444
+  # libc_cv_rtlddir, libdir, and libc_cv_localedir.
29e444
   test -n "$libc_cv_slibdir" || \
29e444
   case $machine in
29e444
   sparc/sparc64 | x86_64* | powerpc/powerpc64 | s390/s390-64)
29e444
     libc_cv_slibdir=/lib64
29e444
+    case $machine in
29e444
+    s390/s390-64)
29e444
+      libc_cv_rtlddir=/lib
29e444
+      ;;
29e444
+    esac
29e444
     if test "$libdir" = '${exec_prefix}/lib'; then
29e444
       libdir='${exec_prefix}/lib64';
29e444
       # Locale data can be shared between 32bit and 64bit libraries
29e444
diff --git a/sysdeps/gnu/configure.in b/sysdeps/gnu/configure.in
29e444
index b8fd74c..ce251df 100644
29e444
--- a/sysdeps/gnu/configure.in
29e444
+++ b/sysdeps/gnu/configure.in
29e444
@@ -9,12 +9,17 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
29e444
 case "$prefix" in
29e444
 /usr | /usr/)
29e444
   # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
29e444
-  # Allow earlier configure scripts to handle libc_cv_slibdir, libdir,
29e444
-  # and libc_cv_localedir.
29e444
+  # Allow earlier configure scripts to handle libc_cv_slibdir,
29e444
+  # libc_cv_rtlddir, libdir, and libc_cv_localedir.
29e444
   test -n "$libc_cv_slibdir" || \
29e444
   case $machine in
29e444
   sparc/sparc64 | x86_64* | powerpc/powerpc64 | s390/s390-64)
29e444
     libc_cv_slibdir=/lib64
29e444
+    case $machine in
29e444
+    s390/s390-64)
29e444
+      libc_cv_rtlddir=/lib
29e444
+      ;;
29e444
+    esac
29e444
     if test "$libdir" = '${exec_prefix}/lib'; then
29e444
       libdir='${exec_prefix}/lib64';
29e444
       # Locale data can be shared between 32bit and 64bit libraries