00db10
# commit 0b2c2ace3601d5d59cf89130b16840e7f132f7a6
00db10
# Author: Alan Modra <amodra@gmail.com>
00db10
# Date:   Sat Aug 17 18:36:45 2013 +0930
00db10
# 
00db10
#     PowerPC makecontext
00db10
#     http://sourceware.org/ml/libc-alpha/2013-08/msg00092.html
00db10
#     
00db10
#     Use conditional form of branch and link to avoid destroying the cpu
00db10
#     link stack used to predict blr return addresses.
00db10
#     
00db10
#         * sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S: Use
00db10
#         conditional form of branch and link when obtaining pc.
00db10
#         * sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Likewise.
00db10
# 
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S	2014-05-28 12:25:49.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S	2014-05-28 12:25:51.000000000 -0500
00db10
@@ -47,7 +47,9 @@
00db10
 #ifdef PIC
00db10
 	mflr	r0
00db10
 	cfi_register(lr,r0)
00db10
-	bl	1f
00db10
+	/* Use this conditional form of branch and link to avoid destroying
00db10
+	   the cpu link stack used to predict blr return addresses.  */
00db10
+	bcl	20,31,1f
00db10
 1:	mflr	r6
00db10
 	addi	r6,r6,L(exitcode)-1b
00db10
 	mtlr	r0
00db10
@@ -136,7 +138,9 @@
00db10
 #ifdef PIC
00db10
 	mflr	r0
00db10
 	cfi_register(lr,r0)
00db10
-	bl	1f
00db10
+	/* Use this conditional form of branch and link to avoid destroying
00db10
+	   the cpu link stack used to predict blr return addresses.  */
00db10
+	bcl	20,31,1f
00db10
 1:	mflr	r6
00db10
 	addi	r6,r6,L(novec_exitcode)-1b
00db10
 	mtlr	r0
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S	2014-05-28 12:25:49.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S	2014-05-28 12:25:51.000000000 -0500
00db10
@@ -124,8 +124,10 @@
00db10
 
00db10
   /* If the target function returns we need to do some cleanup.  We use a
00db10
      code trick to get the address of our cleanup function into the link
00db10
-     register.  Do not add any code between here and L(exitcode).  */
00db10
-  bl  L(gotexitcodeaddr);
00db10
+     register.  Do not add any code between here and L(exitcode).
00db10
+     Use this conditional form of branch and link to avoid destroying
00db10
+     the cpu link stack used to predict blr return addresses.  */
00db10
+  bcl	20,31,L(gotexitcodeaddr);
00db10
 
00db10
 	/* This is the helper code which gets called if a function which
00db10
 	   is registered with 'makecontext' returns.  In this case we