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