[2/6] aarch64: Merge __local_multiple_threads offset with memory reference
diff mbox

Message ID 1400619378-7262-3-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson May 20, 2014, 8:56 p.m. UTC
From: Richard Henderson <rth@redhat.com>

This also highlights that we'd been loading 64-bits instead of
the proper 32-bits.  Caught by the linker as a relocation error,
since the variable happened to be unaligned for 64-bits.

	* sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
	(SINGLE_THREAD_P): Use the correct width load.  Fold an add into
	the ldr offset.
---
 sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Marcus Shawcroft May 21, 2014, 8:50 a.m. UTC | #1
On 20 May 2014 21:56, Richard Henderson <rth@twiddle.net> wrote:
> From: Richard Henderson <rth@redhat.com>
>
> This also highlights that we'd been loading 64-bits instead of
> the proper 32-bits.  Caught by the linker as a relocation error,
> since the variable happened to be unaligned for 64-bits.
>
>         * sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
>         (SINGLE_THREAD_P): Use the correct width load.  Fold an add into
>         the ldr offset.

OK thanks.  This is broken in 2.19, would you mind back porting your fix?
/Marcus
Richard Henderson May 21, 2014, 5:26 p.m. UTC | #2
On 05/21/2014 01:50 AM, Marcus Shawcroft wrote:
> On 20 May 2014 21:56, Richard Henderson <rth@twiddle.net> wrote:
>> From: Richard Henderson <rth@redhat.com>
>>
>> This also highlights that we'd been loading 64-bits instead of
>> the proper 32-bits.  Caught by the linker as a relocation error,
>> since the variable happened to be unaligned for 64-bits.
>>
>>         * sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
>>         (SINGLE_THREAD_P): Use the correct width load.  Fold an add into
>>         the ldr offset.
> 
> OK thanks.  This is broken in 2.19, would you mind back porting your fix?

Done; committed as 690bb11f6080800be584d5db7b0b0ff61253c461.


r~

Patch
diff mbox

diff --git a/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h b/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
index 0e9bef3..acaed5d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
@@ -163,9 +163,8 @@  extern int __local_multiple_threads attribute_hidden;
 #  else
 #   define SINGLE_THREAD_P						\
   adrp	x16, __local_multiple_threads;					\
-  add	x16, x16, #:lo12:__local_multiple_threads;			\
-  ldr	x16, [x16];							\
-  cmp	x16, 0;
+  ldr	w16, [x16, #:lo12:__local_multiple_threads];			\
+  cmp	w16, 0;
 #  endif
 # else
 /*  There is no __local_multiple_threads for librt, so use the TCB.  */
@@ -181,12 +180,12 @@  extern int __local_multiple_threads attribute_hidden;
   cfi_rel_offset (x30, 8);						\
   bl	__read_tp;							\
   sub	x0, x0, PTHREAD_SIZEOF;						\
-  ldr	x16, [x0, PTHREAD_MULTIPLE_THREADS_OFFSET];			\
+  ldr	w16, [x0, PTHREAD_MULTIPLE_THREADS_OFFSET];			\
   ldp	x0, x30, [sp], 16;						\
   cfi_restore (x0);							\
   cfi_restore (x30);							\
   cfi_adjust_cfa_offset (-16);						\
-  cmp	x16, 0
+  cmp	w16, 0
 #   define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P
 #  endif
 # endif