public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: libc-ports@sourceware.org
Cc: joseph@codesourcery.com
Subject: [PATCH v2 01/14] arm: Introduce and use LDST_PCREL
Date: Fri, 01 Mar 2013 17:36:00 -0000	[thread overview]
Message-ID: <1362159320-5934-2-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1362159320-5934-1-git-send-email-rth@twiddle.net>

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                         | 17 +++++++++++++++++
 ports/sysdeps/unix/arm/sysdep.S                    | 22 ++++++++++++----------
 .../unix/sysv/linux/arm/nptl/sysdep-cancel.h       | 10 ++--------
 ports/sysdeps/unix/sysv/linux/arm/sysdep.h         | 10 ++++------
 4 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/ports/sysdeps/arm/sysdep.h b/ports/sysdeps/arm/sysdep.h
index 4af7429..29a78f0 100644
--- a/ports/sysdeps/arm/sysdep.h
+++ b/ports/sysdeps/arm/sysdep.h
@@ -117,6 +117,23 @@
    the caller.  */
 	.eabi_attribute 24, 1
 
+/* 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__ */
 
 /* This number is the offset from the pc at the current location.  */
diff --git a/ports/sysdeps/unix/arm/sysdep.S b/ports/sysdeps/unix/arm/sysdep.S
index 40e4d80..d44ee48 100644
--- a/ports/sysdeps/unix/arm/sysdep.S
+++ b/ports/sysdeps/unix/arm/sysdep.S
@@ -45,20 +45,22 @@ __syscall_error:
 	mov lr, pc
 	sub pc, r0, #31
 
-	ldr r2, 1f
-2:	ldr r2, [pc, r2]
-	str r1, [r0, r2]
-	mvn r0, #0
-	RETINSTR (, ip)
+	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)
 
 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 df85d51..8889369 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)				\
 	.text;								\
-	PSEUDO_PROLOGUE;						\
   ENTRY (__##syscall_name##_nocancel);					\
 	CFI_SECTIONS;							\
 	DO_CALL (syscall_name, args);					\
@@ -203,12 +202,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.  */
@@ -217,7 +212,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 f40cb95..89208a9 100644
--- a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -110,12 +110,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

  parent reply	other threads:[~2013-03-01 17:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01 17:36 [PATCH v2 00/14] ARM improvements Richard Henderson
2013-03-01 17:36 ` [PATCH v2 07/14] arm: Commonize BX conditionals Richard Henderson
2013-03-01 17:36 ` [PATCH v2 02/14] arm: Introduce and use NEGOFF series of macros Richard Henderson
2013-03-01 17:57   ` Roland McGrath
2013-03-05  1:42   ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 12/14] arm: Add optimized addmul_1 Richard Henderson
2013-03-01 17:58   ` Roland McGrath
2013-03-01 18:00   ` Roland McGrath
2013-03-06  1:18     ` Joseph S. Myers
2013-10-25 22:13       ` Roland McGrath
2013-03-06  1:11   ` Joseph S. Myers
2013-03-01 17:36 ` Richard Henderson [this message]
2013-03-04 17:47   ` [PATCH v2 01/14] arm: Introduce and use LDST_PCREL Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 04/14] arm: Enable thumb2 mode in assembly files Richard Henderson
2013-03-01 17:36 ` [PATCH v2 03/14] arm: Introduce and use GET_TLS Richard Henderson
2013-03-01 17:57   ` Roland McGrath
2013-03-05  1:45   ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 10/14] arm: Implement hard-tp for GET_TLS Richard Henderson
2013-03-01 17:55   ` Roland McGrath
2013-03-05  2:01   ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 08/14] arm: Unless arm4t, pop return address directly into pc Richard Henderson
2013-03-01 17:36 ` [PATCH v2 11/14] arm: Add optimized ffs for armv6t2 Richard Henderson
2013-03-05  2:08   ` Joseph S. Myers
2013-03-06 15:52     ` Richard Henderson
2013-03-01 17:36 ` [PATCH v2 13/14] arm: Add optimized submul_1 Richard Henderson
2013-03-01 17:58   ` Roland McGrath
2013-03-06  1:14   ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 06/14] arm: Delete LOADREGS macro Richard Henderson
2013-03-01 17:36 ` [PATCH v2 14/14] arm: Add optimized add_n and sub_n Richard Henderson
2013-03-01 17:59   ` Roland McGrath
2013-03-06  0:53   ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 05/14] arm: Use push/pop mnemonics Richard Henderson
2013-03-01 17:36 ` [PATCH v2 09/14] arm: Tidy architecture selection Richard Henderson
2013-03-01 17:55   ` Roland McGrath
2013-03-05  2:01   ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1362159320-5934-2-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=joseph@codesourcery.com \
    --cc=libc-ports@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).