From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26799 invoked by alias); 27 Feb 2013 03:16:55 -0000 Received: (qmail 26758 invoked by uid 22791); 27 Feb 2013 03:16:54 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_BL,TW_OV X-Spam-Check-By: sourceware.org Received: from mail-da0-f50.google.com (HELO mail-da0-f50.google.com) (209.85.210.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Feb 2013 03:16:44 +0000 Received: by mail-da0-f50.google.com with SMTP id h15so58858dan.23 for ; Tue, 26 Feb 2013 19:16:44 -0800 (PST) X-Received: by 10.68.196.35 with SMTP id ij3mr1044169pbc.56.1361935004307; Tue, 26 Feb 2013 19:16:44 -0800 (PST) Received: from pebble.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id pp1sm265271pac.7.2013.02.26.19.16.42 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 26 Feb 2013 19:16:43 -0800 (PST) From: Richard Henderson To: libc-ports@sourceware.org Cc: Joseph Myers Subject: [PATCH 07/26] arm: Introduce and use GET_TLS Date: Wed, 27 Feb 2013 03:17:00 -0000 Message-Id: <1361934986-17018-8-git-send-email-rth@twiddle.net> In-Reply-To: <1361934986-17018-1-git-send-email-rth@twiddle.net> References: <1361934986-17018-1-git-send-email-rth@twiddle.net> X-IsSubscribed: yes Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00087.txt.bz2 Factor out the sequence needed to call kuser_get_tls, as we can't play subtract into pc games in thumb mode. --- * sysdeps/unix/sysv/linux/arm/sysdep.h (GET_TLS): New macro. * sysdeps/unix/arm/sysdep.S (__syscall_error): Use it. * sysdeps/unix/sysv/linux/arm/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S (SAVE_PID): Likewise. * sysdeps/unix/sysv/linux/arm/nptl/vfork.S (SAVE_PID): Likewise. * sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S (__aeabi_read_tp): Add thumb2 alternative. --- ports/sysdeps/unix/arm/sysdep.S | 4 +--- ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S | 6 ++++++ ports/sysdeps/unix/sysv/linux/arm/clone.S | 4 +--- ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S | 4 +--- ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S | 4 +--- ports/sysdeps/unix/sysv/linux/arm/sysdep.h | 15 +++++++++++++++ 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ports/sysdeps/unix/arm/sysdep.S b/ports/sysdeps/unix/arm/sysdep.S index 76137b3..425f4ac 100644 --- a/ports/sysdeps/unix/arm/sysdep.S +++ b/ports/sysdeps/unix/arm/sysdep.S @@ -40,9 +40,7 @@ __syscall_error: cfi_register (lr, ip) mov r1, r0 - mov r0, #0xffff0fff - mov lr, pc - sub pc, r0, #31 + GET_TLS ldr r2, 1f 2: ldr r2, [pc, r2] diff --git a/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S b/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S index c4ddbc6..ecdc322 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S +++ b/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S @@ -41,6 +41,12 @@ .hidden __aeabi_read_tp ENTRY (__aeabi_read_tp) +#ifdef __thumb2__ + movw r0, #0x0fe0 + movt r0, #0xffff + bx r0 +#else mov r0, #0xffff0fff sub pc, r0, #31 +#endif END (__aeabi_read_tp) diff --git a/ports/sysdeps/unix/sysv/linux/arm/clone.S b/ports/sysdeps/unix/sysv/linux/arm/clone.S index de25db1..8807781 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/clone.S +++ b/ports/sysdeps/unix/sysv/linux/arm/clone.S @@ -73,9 +73,7 @@ PSEUDO_END (__clone) #ifdef RESET_PID tst ip, #CLONE_THREAD bne 3f - mov r0, #0xffff0fff - mov lr, pc - sub pc, r0, #31 + GET_TLS mov r1, r0 tst ip, #CLONE_VM movne r0, #-1 diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S b/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S index a38d564..749aaab 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S +++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S @@ -22,9 +22,7 @@ str lr, [sp, #-4]!; /* Save LR. */ \ cfi_adjust_cfa_offset (4); \ cfi_rel_offset (lr, 0); \ - mov r0, #0xffff0fff; /* Point to the high page. */ \ - mov lr, pc; /* Save our return address. */ \ - sub pc, r0, #31; /* Jump to the TLS entry. */ \ + GET_TLS; \ ldr lr, [sp], #4; /* Restore LR. */ \ cfi_adjust_cfa_offset (-4); \ cfi_restore (lr); \ diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S b/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S index 3fce2d1..1bbe5c6 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S +++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S @@ -22,9 +22,7 @@ str lr, [sp, #-4]!; /* Save LR. */ \ cfi_adjust_cfa_offset (4); \ cfi_rel_offset (lr, 0); \ - mov r0, #0xffff0fff; /* Point to the high page. */ \ - mov lr, pc; /* Save our return address. */ \ - sub pc, r0, #31; /* Jump to the TLS entry. */ \ + GET_TLS; \ ldr lr, [sp], #4; /* Restore LR. */ \ cfi_adjust_cfa_offset (-4); \ cfi_restore (lr); \ diff --git a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h index cb237d9..dae9d98 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -45,6 +45,21 @@ #ifdef __ASSEMBLER__ +/* Call the linux kernel kuser_get_tls helper. Returns in R0, clobbers LR. + Note that in thumb mode, a constant pool break is often out of range, so + we always expand the constant inline. */ +#ifdef __thumb2__ +# define GET_TLS \ + movw r0, #0x0fe0; \ + movt r0, #0xffff; \ + blx r0 +#else +# define GET_TLS \ + mov r0, #0xffff0fff; /* Point to the high page. */ \ + mov lr, pc; /* Save our return address. */ \ + sub pc, r0, #31 /* Jump to the TLS entry. */ +#endif + /* Linux uses a negative return value to indicate syscall errors, unlike most Unices, which use the condition codes' carry flag. -- 1.8.1.2