From 0b2c2ace3601d5d59cf89130b16840e7f132f7a6 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 17 Aug 2013 18:36:45 +0930 Subject: [PATCH] PowerPC makecontext http://sourceware.org/ml/libc-alpha/2013-08/msg00092.html Use conditional form of branch and link to avoid destroying the cpu link stack used to predict blr return addresses. * sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S: Use conditional form of branch and link when obtaining pc. * sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Likewise. --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S | 8 ++++++-- sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec81a6b..07aaa25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2013-10-04 Alan Modra + * sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S: Use + conditional form of branch and link when obtaining pc. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Likewise. + +2013-10-04 Alan Modra + * sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext-common.S: Use HIWORD/LOWORD. * sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S: Ditto. diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S index 95902b1..70e3c97 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S @@ -47,7 +47,9 @@ ENTRY(__makecontext) #ifdef PIC mflr r0 cfi_register(lr,r0) - bl 1f + /* Use this conditional form of branch and link to avoid destroying + the cpu link stack used to predict blr return addresses. */ + bcl 20,31,1f 1: mflr r6 addi r6,r6,L(exitcode)-1b mtlr r0 @@ -136,7 +138,9 @@ ENTRY(__novec_makecontext) #ifdef PIC mflr r0 cfi_register(lr,r0) - bl 1f + /* Use this conditional form of branch and link to avoid destroying + the cpu link stack used to predict blr return addresses. */ + bcl 20,31,1f 1: mflr r6 addi r6,r6,L(novec_exitcode)-1b mtlr r0 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S index 4a16669..32fc47c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S @@ -124,8 +124,10 @@ L(noparms): /* If the target function returns we need to do some cleanup. We use a code trick to get the address of our cleanup function into the link - register. Do not add any code between here and L(exitcode). */ - bl L(gotexitcodeaddr); + register. Do not add any code between here and L(exitcode). + Use this conditional form of branch and link to avoid destroying + the cpu link stack used to predict blr return addresses. */ + bcl 20,31,L(gotexitcodeaddr); /* This is the helper code which gets called if a function which is registered with 'makecontext' returns. In this case we -- 2.7.4