powerpc64: Fix calls when r2 is not used [BZ #26173]

Message ID 20200625230224.301671-1-tuliom@linux.ibm.com
State New
Headers show
Series
  • powerpc64: Fix calls when r2 is not used [BZ #26173]
Related show

Commit Message

H.J. Lu via Libc-alpha June 25, 2020, 11:02 p.m.
Teach the linker that __mcount_internal, __sigjmp_save_symbol,
__syscall_error and __GI_exit do not use r2, so that it does not need to
recover r2 after the call.
---
 sysdeps/powerpc/powerpc64/ppc-mcount.S                  | 2 +-
 sysdeps/powerpc/powerpc64/setjmp-common.S               | 2 +-
 sysdeps/powerpc/powerpc64/sysdep.h                      | 2 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.25.4

Comments

H.J. Lu via Libc-alpha June 30, 2020, 7:44 p.m. | #1
Hi Tulio,

On 6/25/20 8:02 PM, Tulio Magno Quites Machado Filho via Libc-alpha wrote:
> Teach the linker that __mcount_internal, __sigjmp_save_symbol,

> __syscall_error and __GI_exit do not use r2, so that it does not need to

> recover r2 after the call.

> ---

>  sysdeps/powerpc/powerpc64/ppc-mcount.S                  | 2 +-

>  sysdeps/powerpc/powerpc64/setjmp-common.S               | 2 +-

>  sysdeps/powerpc/powerpc64/sysdep.h                      | 2 +-

>  sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S | 2 +-

>  4 files changed, 4 insertions(+), 4 deletions(-)

> 

> diff --git a/sysdeps/powerpc/powerpc64/ppc-mcount.S b/sysdeps/powerpc/powerpc64/ppc-mcount.S

> index f7e9836cae..7b2b3ab908 100644

> --- a/sysdeps/powerpc/powerpc64/ppc-mcount.S

> +++ b/sysdeps/powerpc/powerpc64/ppc-mcount.S

> @@ -29,7 +29,7 @@ ENTRY(_mcount)

>  	cfi_adjust_cfa_offset (FRAME_MIN_SIZE)

>  	cfi_offset (lr, FRAME_LR_SAVE)

>  	ld		 r3, FRAME_LR_SAVE(r11)

> -	bl		 JUMPTARGET(__mcount_internal)

> +	bl		 JUMPTARGET(__mcount_internal@notoc)

Ok.

>  #ifndef SHARED

>  	nop

>  #endif

> diff --git a/sysdeps/powerpc/powerpc64/setjmp-common.S b/sysdeps/powerpc/powerpc64/setjmp-common.S

> index eb37000980..44cc43937e 100644

> --- a/sysdeps/powerpc/powerpc64/setjmp-common.S

> +++ b/sysdeps/powerpc/powerpc64/setjmp-common.S

> @@ -217,7 +217,7 @@ L(no_vmx):

>  	li	r3,0

>  	blr

>  #elif defined SHARED

> -	b	JUMPTARGET (__sigjmp_save_symbol)

> +	b	JUMPTARGET (__sigjmp_save_symbol@notoc)

Ok.

>  #else

>  	mflr	r0

>  	std	r0,FRAME_LR_SAVE(r1)

> diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h

> index d6616ac905..fbddeb492e 100644

> --- a/sysdeps/powerpc/powerpc64/sysdep.h

> +++ b/sysdeps/powerpc/powerpc64/sysdep.h

> @@ -278,7 +278,7 @@ LT_LABELSUFFIX(name,_name_end): ; \

>  

>  #ifdef SHARED

>  #define TAIL_CALL_SYSCALL_ERROR \

> -    b JUMPTARGET(__syscall_error)

> +    b JUMPTARGET(__syscall_error@notoc)

Ok.

>  #else

>  /* Static version might be linked into a large app with a toc exceeding

>     64k.  We can't put a toc adjusting stub on a plain branch, so can't

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S

> index e4d4575d68..fd22f8f7ae 100644

> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S

> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S

> @@ -160,7 +160,7 @@ L(exitcode):

>  	li    r3,-1

>  L(do_exit):

>  #ifdef SHARED

> -	b     JUMPTARGET(__GI_exit);

> +	b     JUMPTARGET(__GI_exit@notoc);

Ok.

>  #else

>  	b     JUMPTARGET(exit);

>  	nop

> 


LGTM.

Thanks,
Matheus Castanho
H.J. Lu via Libc-alpha June 30, 2020, 8:50 p.m. | #2
On 6/25/20 6:02 PM, Tulio Magno Quites Machado Filho via Libc-alpha wrote:

> --- a/sysdeps/powerpc/powerpc64/setjmp-common.S

> +++ b/sysdeps/powerpc/powerpc64/setjmp-common.S

> @@ -217,7 +217,7 @@ L(no_vmx):

>   	li	r3,0

>   	blr

>   #elif defined SHARED

> -	b	JUMPTARGET (__sigjmp_save_symbol)

> +	b	JUMPTARGET (__sigjmp_save_symbol@notoc)


Will this also require a newer version of binutils?

Patch

diff --git a/sysdeps/powerpc/powerpc64/ppc-mcount.S b/sysdeps/powerpc/powerpc64/ppc-mcount.S
index f7e9836cae..7b2b3ab908 100644
--- a/sysdeps/powerpc/powerpc64/ppc-mcount.S
+++ b/sysdeps/powerpc/powerpc64/ppc-mcount.S
@@ -29,7 +29,7 @@  ENTRY(_mcount)
 	cfi_adjust_cfa_offset (FRAME_MIN_SIZE)
 	cfi_offset (lr, FRAME_LR_SAVE)
 	ld		 r3, FRAME_LR_SAVE(r11)
-	bl		 JUMPTARGET(__mcount_internal)
+	bl		 JUMPTARGET(__mcount_internal@notoc)
 #ifndef SHARED
 	nop
 #endif
diff --git a/sysdeps/powerpc/powerpc64/setjmp-common.S b/sysdeps/powerpc/powerpc64/setjmp-common.S
index eb37000980..44cc43937e 100644
--- a/sysdeps/powerpc/powerpc64/setjmp-common.S
+++ b/sysdeps/powerpc/powerpc64/setjmp-common.S
@@ -217,7 +217,7 @@  L(no_vmx):
 	li	r3,0
 	blr
 #elif defined SHARED
-	b	JUMPTARGET (__sigjmp_save_symbol)
+	b	JUMPTARGET (__sigjmp_save_symbol@notoc)
 #else
 	mflr	r0
 	std	r0,FRAME_LR_SAVE(r1)
diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h
index d6616ac905..fbddeb492e 100644
--- a/sysdeps/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/powerpc/powerpc64/sysdep.h
@@ -278,7 +278,7 @@  LT_LABELSUFFIX(name,_name_end): ; \
 
 #ifdef SHARED
 #define TAIL_CALL_SYSCALL_ERROR \
-    b JUMPTARGET(__syscall_error)
+    b JUMPTARGET(__syscall_error@notoc)
 #else
 /* Static version might be linked into a large app with a toc exceeding
    64k.  We can't put a toc adjusting stub on a plain branch, so can't
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
index e4d4575d68..fd22f8f7ae 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
@@ -160,7 +160,7 @@  L(exitcode):
 	li    r3,-1
 L(do_exit):
 #ifdef SHARED
-	b     JUMPTARGET(__GI_exit);
+	b     JUMPTARGET(__GI_exit@notoc);
 #else
 	b     JUMPTARGET(exit);
 	nop