Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/arm Use less got, add END(), make thumb tolerant.
details: https://anonhg.NetBSD.org/src/rev/dc54a8098948
branches: trunk
changeset: 789687:dc54a8098948
user: matt <matt%NetBSD.org@localhost>
date: Tue Sep 03 00:30:19 2013 +0000
description:
Use less got, add END(), make thumb tolerant.
diffstat:
lib/libc/arch/arm/Makefile.inc | 3 +-
lib/libc/arch/arm/gen/_setjmp.S | 128 +++++++++++++++++++-------
lib/libc/arch/arm/gen/setjmp.S | 171 ++++++++++++++++++++++++++---------
lib/libc/arch/arm/gen/sigsetjmp.S | 57 +++++++++--
lib/libc/arch/arm/gen/swapcontext.S | 47 ++++++++-
lib/libc/arch/arm/sys/__clone.S | 75 +++++++++++----
lib/libc/arch/arm/sys/__vfork14.S | 5 +-
lib/libc/arch/arm/sys/brk.S | 40 +++----
lib/libc/arch/arm/sys/cerror.S | 57 +++++++++--
lib/libc/arch/arm/sys/getcontext.S | 14 ++-
lib/libc/arch/arm/sys/ptrace.S | 33 ++++--
lib/libc/arch/arm/sys/sbrk.S | 22 +--
12 files changed, 464 insertions(+), 188 deletions(-)
diffs (truncated from 1057 to 300 lines):
diff -r 48c1b372379d -r dc54a8098948 lib/libc/arch/arm/Makefile.inc
--- a/lib/libc/arch/arm/Makefile.inc Mon Sep 02 19:26:42 2013 +0000
+++ b/lib/libc/arch/arm/Makefile.inc Tue Sep 03 00:30:19 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.24 2013/08/21 03:09:08 matt Exp $
+# $NetBSD: Makefile.inc,v 1.25 2013/09/03 00:30:19 matt Exp $
.include <bsd.own.mk>
@@ -24,6 +24,7 @@
# for earm, use the 64-bit softfloat
.if ${LIBC_MACHINE_ARCH} == "arm" || ${LIBC_MACHINE_ARCH} == "armeb"
SOFTFLOAT_BITS=32
+#SRCS+= floatunsidf_ieee754.c floatunsisf_ieee754.c
.endif
.include <softfloat/Makefile.inc>
diff -r 48c1b372379d -r dc54a8098948 lib/libc/arch/arm/gen/_setjmp.S
--- a/lib/libc/arch/arm/gen/_setjmp.S Mon Sep 02 19:26:42 2013 +0000
+++ b/lib/libc/arch/arm/gen/_setjmp.S Tue Sep 03 00:30:19 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _setjmp.S,v 1.12 2013/04/19 13:45:45 matt Exp $ */
+/* $NetBSD: _setjmp.S,v 1.13 2013/09/03 00:30:19 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -36,7 +36,7 @@
#error FPA is not supported anymore
#endif
-#ifdef __ARM_EABI__
+#if defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
.fpu vfp
#endif
@@ -59,77 +59,135 @@
ENTRY(_setjmp)
ldr r1, .L_setjmp_magic
-#ifdef __ARM_EABI__
+#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2))
ldr r2, .Lfpu_present
#ifdef PIC
- GOT_INIT(r3, .L_setjmp_got, .L_setjmp_gotinit)
- ldr r2, [r2, r3]
-#else
- ldr r2, [r2]
+ add r2, r2, pc /* pc = &.LPIC0 */
#endif
- teq r2, #0 /* do we have a FPU? */
+ ldr r2, [r2]
+.LPIC0:
+#if defined(__thumb__) && defined(_ARM_ARCH_T2)
+ cbz r2, 1f
+#else
+ cmp r2, #0 /* do we have a FPU? */
beq 1f /* no, don't save VFP registers */
+#endif
- orr r1, r1, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
+ orrs r1, r1, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
/* change magic to VFP magic */
- add r2, r0, #(_JB_REG_D8 * 4)
+ adds r2, r0, #(_JB_REG_D8 * 4)
vstmia r2, {d8-d15}
vmrs r2, fpscr
str r2, [r0, #(_JB_REG_FPSCR * 4)]
1:
-#endif /* __ARM_EABI__ */
+#endif /* __ARM_EABI__ && (_ARM_ARCH_T2 || !__thumb__) */
str r1, [r0]
- add r0, r0, #(_JB_REG_R4 * 4)
+ adds r0, r0, #(_JB_REG_R4 * 4)
/* Store integer registers */
+#if !defined(__thumb__) || defined(_ARCH_ARCH_T2)
stmia r0, {r4-r14}
+#else
+ stmia r0!, {r4-r7}
+ mov r1, r8
+ mov r2, r9
+ mov r3, r10
+ stmia r0!, {r1-r3}
+ mov r2, r11
+ mov r3, r12
+ stmia r0!, {r2-r3}
+ mov r2, sp
+ mov r3, lr
+ stmia r0!, {r2-r3}
+#endif
- mov r0, #0x00000000
+ movs r0, #0
RET
-.L_setjmp_magic:
- .word _JB_MAGIC__SETJMP
-#ifdef __ARM_EABI__
- GOT_INITSYM(.L_setjmp_got, .L_setjmp_gotinit)
+#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2))
+ .align 0
.Lfpu_present:
- .word PIC_SYM(_libc_arm_fpu_present, GOTOFF)
-#endif /* __ARM_EABI__ */
+ .word REL_SYM(_libc_arm_fpu_present, .LPIC0)
+#endif /* __ARM_EABI__ && (_ARM_ARCH_T2 || !__thumb__) */
+END(_setjmp)
ENTRY(_longjmp)
ldr r2, [r0] /* get magic from jmp_buf */
- bic r3, r2, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
+#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
+ bics r3, r2, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
/* ignore VFP-ness of magic */
ldr ip, .L_setjmp_magic /* load magic */
- teq ip, r3 /* magic correct? */
+#else
+ ldr r3, .L_setjmp_magic /* load magic */
+ mov ip, r3
+ movs r3, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
+ ands r3, r3, r2
+ eors r3, r3, r2 /* ignore VFP-ness of magic */
+#endif
+ cmp ip, r3 /* magic correct? */
bne botch /* no, botch */
-#ifdef __ARM_EABI__
- teq r3, r2 /* did magic change? */
+#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2))
+ cmp r3, r2 /* did magic change? */
beq 1f /* no, don't restore VFP */
- add ip, r0, #(_JB_REG_D8 * 4)
- vldmia ip, {d8-d15}
- ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
- vmsr fpscr, ip
-1:
-#endif /* __ARM_EABI__ */
+ adds r3, r0, #(_JB_REG_D8 * 4)
+ vldmia r3, {d8-d15}
+ ldr r3, [r0, #(_JB_REG_FPSCR * 4)]
+ vmsr fpscr, r3
+#endif /* __ARM_EABI__ && (_ARM_ARCH_T2 || !__thumb__) */
- add r0, r0, #(_JB_REG_R4 * 4)
+ adds r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
- ldmia r0, {r4-r14}
+#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
+ ldmia r0!, {r4-r12}
+#else
+ ldmia r0!, {r4-r7}
+ ldmia r0!, {r2-r3}
+ mov r8, r2
+ mov r9, r3
+ ldmia r0!, {r2-r3}
+ mov r10, r2
+ mov r1, r3
+ adds r0, r0, #4 /* skip r12 */
+#endif
+ ldmia r0!, {r2-r3} /* r2 = sp, r3 = lr */
/* Validate sp and r14 */
- teq sp, #0
- teqne r14, #0
+#if defined(__thumb__) && defined(_ARM_ARCH_T2)
+ cbz r2, botch
+#else
+ cmp r2, #0
beq botch
+#endif
+ mov sp, r2
+
+#if defined(__thumb__) && defined(_ARM_ARCH_T2)
+ cbz r3, botch
+#else
+ cmp r3, #0
+ beq botch
+#endif
+ mov lr, r3
/* Set return value */
movs r0, r1
- moveq r0, #0x00000001
+#ifdef __thumb__
+ bne 1f
+ movs r0, #1
+1:
+#else
+ moveq r0, #1
+#endif
RET
/* validation failed, die die die. */
botch:
bl PIC_SYM(_C_LABEL(longjmperror), PLT)
bl PIC_SYM(_C_LABEL(abort), PLT)
- b . - 8 /* Cannot get here */
+1: b 1b /* Cannot get here */
+
+ .align 0
+.L_setjmp_magic:
+ .word _JB_MAGIC__SETJMP
+END(_longjmp)
diff -r 48c1b372379d -r dc54a8098948 lib/libc/arch/arm/gen/setjmp.S
--- a/lib/libc/arch/arm/gen/setjmp.S Mon Sep 02 19:26:42 2013 +0000
+++ b/lib/libc/arch/arm/gen/setjmp.S Tue Sep 03 00:30:19 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setjmp.S,v 1.14 2013/04/19 13:45:45 matt Exp $ */
+/* $NetBSD: setjmp.S,v 1.15 2013/09/03 00:30:19 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -36,7 +36,7 @@
#error FPA is not supported anymore
#endif
-#ifdef __ARM_EABI__
+#if defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
.fpu vfp
#endif
@@ -55,93 +55,174 @@
ENTRY(__setjmp14)
/* Get the signal mask. */
- stmfd sp!, {r0-r2, r14}
- add r2, r0, #(_JB_SIGMASK * 4)
- mov r1, #0x00000000
- mov r0, #0x00000000
+ push {r0-r2, lr}
+#if !defined(__thumb__)
+ adds r2, r0, #(_JB_SIGMASK * 4)
+#else
+ mov r2, r0
+ adds r2, r2, #(_JB_SIGMASK * 4)
+#endif
+ movs r1, #0
+ movs r0, #0
bl PIC_SYM(_C_LABEL(__sigprocmask14), PLT)
- ldmfd sp!, {r0-r2, r14}
+#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
+ pop {r0-r2, lr}
+#else
+ pop {r0-r3}
+ mov lr, r3
+#endif
ldr r1, .Lsetjmp_magic
-#ifdef __ARM_EABI__
+#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2))
ldr r2, .Lfpu_present
#ifdef PIC
- GOT_INIT(r3, .Lsetjmp_got, .Lsetjmp_gotinit)
- ldr r2, [r2, r3]
-#else
- ldr r2, [r2]
+ add r2, r2, pc /* pc = &.LPIC0 */
#endif
- teq r2, #0 /* do we have a FPU? */
+ ldr r2, [r2]
+.LPIC0:
+#if defined(__thumb__) && defined(_ARM_ARCH_T2)
+ cbz r2, 1f /* don't save if we don't have a FPU */
+#else
+ cmp r2, #0 /* do we have a FPU? */
beq 1f /* no, don't save VFP registers */
+#endif
- orr r1, r1, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
+ orrs r1, r1, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
/* change magic to VFP magic */
- add r2, r0, #(_JB_REG_D8 * 4)
+ adds r2, r0, #(_JB_REG_D8 * 4)
vstmia r2, {d8-d15}
vmrs r2, fpscr
str r2, [r0, #(_JB_REG_FPSCR * 4)]
1:
-#endif /* __ARM_EABI__ */
+#endif /* __ARM_EABI__ && (!__thumb__ || _ARM_ARCH_T2) */
str r1, [r0] /* store magic */
/* Store integer registers */
- add r0, r0, #(_JB_REG_R4 * 4)
- stmia r0, {r4-r14}
- mov r0, #0x00000000
- RET
+ adds r0, r0, #(_JB_REG_R4 * 4)
+#if !defined(__thumb__)
+ stmia r0!, {r4-lr}
+#else
+ stmia r0!, {r4-r7}
+ mov r2, r8
+ mov r3, r9
+ stmia r0!, {r2-r3}
+ mov r2, r10
+ mov r3, r11
+ stmia r0!, {r2-r3}
Home |
Main Index |
Thread Index |
Old Index