ce426f
# commit 5b118558f9fb0620508d51c34c2cb5ba4f1f01c2
ce426f
# Author: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
ce426f
# Date:   Wed Dec 4 07:08:48 2013 -0600
ce426f
# 
ce426f
#     PowerPC64 ELFv2 ABI 6/6: Bump ld.so soname version number
ce426f
#     
ce426f
#     To avoid having a ELFv2 binary accidentally picking up an old ABI ld.so,
ce426f
#     this patch bumps the soname to ld64.so.2.
ce426f
#     
ce426f
#     In theory (or for testing purposes) this will also allow co-installing
ce426f
#     ld.so versions for both ABIs on the same system.  Note that the kernel
ce426f
#     will already be able to load executables of both ABIs.  However, there
ce426f
#     is currently no plan to use that theoretical possibility in a any
ce426f
#     supported distribution environment ...
ce426f
#     
ce426f
#     Note that in order to check which ABI to use, we need to invoke the
ce426f
#     compiler to check the _CALL_ELF macro; this is done in a new configure
ce426f
#     check in sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac,
ce426f
#     replacing the hard-coded value of default-abi in the Makefile.
ce426f
# 
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile	2014-05-29 14:12:25.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile	2014-05-29 14:12:30.000000000 -0500
ce426f
@@ -1,9 +1,12 @@
ce426f
-abi-variants := 32 64
ce426f
+abi-variants := 32 64-v1 64-v2
ce426f
 abi-32-options := -U__powerpc64__
ce426f
 abi-32-condition := __WORDSIZE == 32
ce426f
-abi-64-options := -D__powerpc64__
ce426f
-abi-64-condition := __WORDSIZE == 64
ce426f
-abi-64-ld-soname := ld64.so.1
ce426f
+abi-64-v1-options := -D__powerpc64__ -U_CALL_ELF -D_CALL_ELF=1
ce426f
+abi-64-v1-condition := __WORDSIZE == 64 && _CALL_ELF != 2
ce426f
+abi-64-v1-ld-soname := ld64.so.1
ce426f
+abi-64-v2-options := -D__powerpc64__ -U_CALL_ELF -D_CALL_ELF=2
ce426f
+abi-64-v2-condition := __WORDSIZE == 64 && _CALL_ELF == 2
ce426f
+abi-64-v2-ld-soname := ld64.so.2
ce426f
 
ce426f
 ifeq ($(subdir),rt)
ce426f
 librt-routines += rt-sysdep
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldconfig.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldconfig.h	2014-05-29 14:12:25.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldconfig.h	2014-05-29 14:12:30.000000000 -0500
ce426f
@@ -20,7 +20,8 @@
ce426f
 
ce426f
 #define SYSDEP_KNOWN_INTERPRETER_NAMES \
ce426f
   { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
ce426f
-  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 },
ce426f
+  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 }, \
ce426f
+  { "/lib64/ld64.so.2", FLAG_ELF_LIBC6 },
ce426f
 #define SYSDEP_KNOWN_LIBRARY_NAMES \
ce426f
   { "libc.so.6", FLAG_ELF_LIBC6 },	\
ce426f
   { "libm.so.6", FLAG_ELF_LIBC6 },
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/Makefile glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/Makefile
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/Makefile	2014-05-29 14:12:25.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/Makefile	1969-12-31 18:00:00.000000000 -0600
ce426f
@@ -1,2 +0,0 @@
ce426f
-# See Makeconfig regarding the use of default-abi.
ce426f
-default-abi := 64
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure	1969-12-31 18:00:00.000000000 -0600
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure	2014-05-29 14:12:30.000000000 -0500
ce426f
@@ -0,0 +1,166 @@
ce426f
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
ce426f
+ # Local configure fragment for sysdeps/unix/sysv/linux/powerpc/powerpc64/.
ce426f
+
ce426f
+# Define default-abi according to compiler flags.
ce426f
+
ce426f
+
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
ce426f
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
ce426f
+if ${ac_cv_path_GREP+:} false; then :
ce426f
+  $as_echo_n "(cached) " >&6
ce426f
+else
ce426f
+  if test -z "$GREP"; then
ce426f
+  ac_path_GREP_found=false
ce426f
+  # Loop through the user's path and test for each of PROGNAME-LIST
ce426f
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
ce426f
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
ce426f
+do
ce426f
+  IFS=$as_save_IFS
ce426f
+  test -z "$as_dir" && as_dir=.
ce426f
+    for ac_prog in grep ggrep; do
ce426f
+    for ac_exec_ext in '' $ac_executable_extensions; do
ce426f
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
ce426f
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
ce426f
+# Check for GNU ac_path_GREP and select it if it is found.
ce426f
+  # Check for GNU $ac_path_GREP
ce426f
+case `"$ac_path_GREP" --version 2>&1` in
ce426f
+*GNU*)
ce426f
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
ce426f
+*)
ce426f
+  ac_count=0
ce426f
+  $as_echo_n 0123456789 >"conftest.in"
ce426f
+  while :
ce426f
+  do
ce426f
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
ce426f
+    mv "conftest.tmp" "conftest.in"
ce426f
+    cp "conftest.in" "conftest.nl"
ce426f
+    $as_echo 'GREP' >> "conftest.nl"
ce426f
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
ce426f
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ce426f
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
ce426f
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
ce426f
+      # Best one so far, save it but keep looking for a better one
ce426f
+      ac_cv_path_GREP="$ac_path_GREP"
ce426f
+      ac_path_GREP_max=$ac_count
ce426f
+    fi
ce426f
+    # 10*(2^10) chars as input seems more than enough
ce426f
+    test $ac_count -gt 10 && break
ce426f
+  done
ce426f
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
ce426f
+esac
ce426f
+
ce426f
+      $ac_path_GREP_found && break 3
ce426f
+    done
ce426f
+  done
ce426f
+  done
ce426f
+IFS=$as_save_IFS
ce426f
+  if test -z "$ac_cv_path_GREP"; then
ce426f
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
ce426f
+  fi
ce426f
+else
ce426f
+  ac_cv_path_GREP=$GREP
ce426f
+fi
ce426f
+
ce426f
+fi
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
ce426f
+$as_echo "$ac_cv_path_GREP" >&6; }
ce426f
+ GREP="$ac_cv_path_GREP"
ce426f
+
ce426f
+
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
ce426f
+$as_echo_n "checking for egrep... " >&6; }
ce426f
+if ${ac_cv_path_EGREP+:} false; then :
ce426f
+  $as_echo_n "(cached) " >&6
ce426f
+else
ce426f
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
ce426f
+   then ac_cv_path_EGREP="$GREP -E"
ce426f
+   else
ce426f
+     if test -z "$EGREP"; then
ce426f
+  ac_path_EGREP_found=false
ce426f
+  # Loop through the user's path and test for each of PROGNAME-LIST
ce426f
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
ce426f
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
ce426f
+do
ce426f
+  IFS=$as_save_IFS
ce426f
+  test -z "$as_dir" && as_dir=.
ce426f
+    for ac_prog in egrep; do
ce426f
+    for ac_exec_ext in '' $ac_executable_extensions; do
ce426f
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
ce426f
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
ce426f
+# Check for GNU ac_path_EGREP and select it if it is found.
ce426f
+  # Check for GNU $ac_path_EGREP
ce426f
+case `"$ac_path_EGREP" --version 2>&1` in
ce426f
+*GNU*)
ce426f
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
ce426f
+*)
ce426f
+  ac_count=0
ce426f
+  $as_echo_n 0123456789 >"conftest.in"
ce426f
+  while :
ce426f
+  do
ce426f
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
ce426f
+    mv "conftest.tmp" "conftest.in"
ce426f
+    cp "conftest.in" "conftest.nl"
ce426f
+    $as_echo 'EGREP' >> "conftest.nl"
ce426f
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
ce426f
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ce426f
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
ce426f
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
ce426f
+      # Best one so far, save it but keep looking for a better one
ce426f
+      ac_cv_path_EGREP="$ac_path_EGREP"
ce426f
+      ac_path_EGREP_max=$ac_count
ce426f
+    fi
ce426f
+    # 10*(2^10) chars as input seems more than enough
ce426f
+    test $ac_count -gt 10 && break
ce426f
+  done
ce426f
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
ce426f
+esac
ce426f
+
ce426f
+      $ac_path_EGREP_found && break 3
ce426f
+    done
ce426f
+  done
ce426f
+  done
ce426f
+IFS=$as_save_IFS
ce426f
+  if test -z "$ac_cv_path_EGREP"; then
ce426f
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
ce426f
+  fi
ce426f
+else
ce426f
+  ac_cv_path_EGREP=$EGREP
ce426f
+fi
ce426f
+
ce426f
+   fi
ce426f
+fi
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
ce426f
+$as_echo "$ac_cv_path_EGREP" >&6; }
ce426f
+ EGREP="$ac_cv_path_EGREP"
ce426f
+
ce426f
+
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler is using the PowerPC64 ELFv2 ABI" >&5
ce426f
+$as_echo_n "checking whether the compiler is using the PowerPC64 ELFv2 ABI... " >&6; }
ce426f
+if ${libc_cv_ppc64_elfv2_abi+:} false; then :
ce426f
+  $as_echo_n "(cached) " >&6
ce426f
+else
ce426f
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
ce426f
+/* end confdefs.h.  */
ce426f
+#if _CALL_ELF == 2
ce426f
+                      yes
ce426f
+                     #endif
ce426f
+
ce426f
+_ACEOF
ce426f
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ce426f
+  $EGREP "yes" >/dev/null 2>&1; then :
ce426f
+  libc_cv_ppc64_elfv2_abi=yes
ce426f
+else
ce426f
+  libc_cv_ppc64_elfv2_abi=no
ce426f
+fi
ce426f
+rm -f conftest*
ce426f
+
ce426f
+fi
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ppc64_elfv2_abi" >&5
ce426f
+$as_echo "$libc_cv_ppc64_elfv2_abi" >&6; }
ce426f
+if test $libc_cv_ppc64_elfv2_abi = yes; then
ce426f
+  config_vars="$config_vars
ce426f
+default-abi = 64-v2"
ce426f
+else
ce426f
+  config_vars="$config_vars
ce426f
+default-abi = 64-v1"
ce426f
+fi
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac	1969-12-31 18:00:00.000000000 -0600
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac	2014-05-29 14:12:30.000000000 -0500
ce426f
@@ -0,0 +1,15 @@
ce426f
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
ce426f
+# Local configure fragment for sysdeps/unix/sysv/linux/powerpc/powerpc64/.
ce426f
+
ce426f
+# Define default-abi according to compiler flags.
ce426f
+AC_CACHE_CHECK([whether the compiler is using the PowerPC64 ELFv2 ABI],
ce426f
+  [libc_cv_ppc64_elfv2_abi],
ce426f
+  [AC_EGREP_CPP(yes,[#if _CALL_ELF == 2
ce426f
+                      yes
ce426f
+                     #endif
ce426f
+  ], libc_cv_ppc64_elfv2_abi=yes, libc_cv_ppc64_elfv2_abi=no)])
ce426f
+if test $libc_cv_ppc64_elfv2_abi = yes; then
ce426f
+  LIBC_CONFIG_VAR([default-abi], [64-v2])
ce426f
+else
ce426f
+  LIBC_CONFIG_VAR([default-abi], [64-v1])
ce426f
+fi