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