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