From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27073 invoked by alias); 27 Feb 2013 03:17:02 -0000 Received: (qmail 26930 invoked by uid 22791); 27 Feb 2013 03:16:58 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_STOCKGEN,KHOP_RCVD_TRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_MV X-Spam-Check-By: sourceware.org Received: from mail-pb0-f43.google.com (HELO mail-pb0-f43.google.com) (209.85.160.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Feb 2013 03:16:50 +0000 Received: by mail-pb0-f43.google.com with SMTP id md12so75448pbc.16 for ; Tue, 26 Feb 2013 19:16:49 -0800 (PST) X-Received: by 10.66.84.202 with SMTP id b10mr5118568paz.71.1361935009443; Tue, 26 Feb 2013 19:16:49 -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.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 26 Feb 2013 19:16:48 -0800 (PST) From: Richard Henderson To: libc-ports@sourceware.org Cc: Joseph Myers Subject: [PATCH 10/26] arm: Introduce and use LDST_PCREL Date: Wed, 27 Feb 2013 03:17:00 -0000 Message-Id: <1361934986-17018-11-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/msg00096.txt.bz2 Macro-ising the few instances where we need to distinguish between arm and thumb pc-relative memory operations. --- * sysdeps/arm/sysdep.h (LDST_PCREL): New macro. * sysdeps/unix/arm/sysdep.S (__syscall_error): Use LDST_PCREL. Fix up gottpoff load of errno for thumb2. * sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h (SINGLE_THREAD_P): Use LDST_PCREL. (PSEUDO_PROLOGUE): Remove. (PSEUDO): Don't use it. * sysdeps/unix/sysv/linux/arm/sysdep.h (SYSCALL_ERROR_HANDLER): Use LDST_PCREL. --- ports/sysdeps/arm/sysdep.h | 18 +++++++++++++ ports/sysdeps/unix/arm/sysdep.S | 30 +++++++++++----------- .../unix/sysv/linux/arm/nptl/sysdep-cancel.h | 10 ++------ ports/sysdeps/unix/sysv/linux/arm/sysdep.h | 10 +++----- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ports/sysdeps/arm/sysdep.h b/ports/sysdeps/arm/sysdep.h index 4a9f05a..b7ba9b1 100644 --- a/ports/sysdeps/arm/sysdep.h +++ b/ports/sysdeps/arm/sysdep.h @@ -129,4 +129,22 @@ # define pc_ofs 8 #endif +/* Load or store to/from a pc-relative EXPR into/from R, using T. */ +#ifdef __thumb2__ +# define LDST_PCREL(OP, R, T, EXPR) \ + ldr T, 98f; \ + .subsection 2; \ +98: .word EXPR - 99f - pc_ofs; \ + .previous; \ +99: add T, T, pc; \ + OP R, [T] +#else +# define LDST_PCREL(OP, R, T, EXPR) \ + ldr T, 98f; \ + .subsection 2; \ +98: .word EXPR - 99f - pc_ofs; \ + .previous; \ +99: OP R, [pc, T] +#endif + #endif /* __ASSEMBLER__ */ diff --git a/ports/sysdeps/unix/arm/sysdep.S b/ports/sysdeps/unix/arm/sysdep.S index 951642f..969628a 100644 --- a/ports/sysdeps/unix/arm/sysdep.S +++ b/ports/sysdeps/unix/arm/sysdep.S @@ -37,26 +37,26 @@ __syscall_error: #endif #ifndef IS_IN_rtld - mov ip, lr + mov ip, lr cfi_register (lr, ip) - mov r1, r0 - + mov r1, r0 GET_TLS + ldr r2, 1f +#ifdef __thumb__ +2: add r2, r2, pc + ldr r2, [r2] +#else +2: ldr r2, [pc, r2] +#endif + str r1, [r0, r2] + mvn r0, #0 + DO_RET(ip) - ldr r2, 1f -2: ldr r2, [pc, r2] - str r1, [r0, r2] - mvn r0, #0 - RETINSTR (, ip) - -1: .word errno(gottpoff) + (. - 2b - pc_ofs) +1: .word errno(gottpoff) + (. - 2b - pc_ofs) #elif RTLD_PRIVATE_ERRNO - ldr r1, 1f -0: str r0, [pc, r1] - mvn r0, $0 + LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno)) + mvn r0, #0 DO_RET(r14) - -1: .word C_SYMBOL_NAME(rtld_errno) - 0b - pc_ofs #else #error "Unsupported non-TLS case" #endif diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h index 1745f9e..b6dc3e0 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h +++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h @@ -31,7 +31,6 @@ # undef PSEUDO # define PSEUDO(name, syscall_name, args) \ .section ".text"; \ - PSEUDO_PROLOGUE; \ .type __##syscall_name##_nocancel,%function; \ .globl __##syscall_name##_nocancel; \ __##syscall_name##_nocancel: \ @@ -207,12 +206,8 @@ extern int __local_multiple_threads attribute_hidden; # define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else # define SINGLE_THREAD_P \ - ldr ip, 1b; \ -2: \ - ldr ip, [pc, ip]; \ - teq ip, #0; -# define PSEUDO_PROLOGUE \ - 1: .word __local_multiple_threads - 2f - pc_ofs; + LDST_PCREL(ldr, ip, ip, __local_multiple_threads); \ + teq ip, #0 # endif # else /* There is no __local_multiple_threads for librt, so use the TCB. */ @@ -221,7 +216,6 @@ extern int __local_multiple_threads attribute_hidden; __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) # else -# define PSEUDO_PROLOGUE # define SINGLE_THREAD_P \ stmfd sp!, {r0, lr}; \ cfi_adjust_cfa_offset (8); \ diff --git a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h index c1f2c9e..e448e61 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -125,12 +125,10 @@ # if RTLD_PRIVATE_ERRNO # define SYSCALL_ERROR_HANDLER \ __local_syscall_error: \ - ldr r1, 1f; \ - rsb r0, r0, #0; \ -0: str r0, [pc, r1]; \ - mvn r0, #0; \ - DO_RET(lr); \ -1: .word C_SYMBOL_NAME(rtld_errno) - 0b - pc_ofs; + rsb r0, r0, #0; \ + LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno)); \ + mvn r0, #0; \ + DO_RET(lr) # else # if defined(__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__) # define POP_PC \ -- 1.8.1.2