Use less got, add END(), make thumb tolerant.
This commit is contained in:
parent
be3c37de45
commit
2a674d4fc6
|
@ -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 @@ CPPFLAGS += -DSOFTFLOAT
|
|||
# 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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
mov r2, sp
|
||||
mov r3, lr
|
||||
str r2, [r0, #4]
|
||||
str r3, [r0, #8]
|
||||
#endif
|
||||
movs r0, #0
|
||||
RET
|
||||
|
||||
.Lsetjmp_magic:
|
||||
.word _JB_MAGIC_SETJMP
|
||||
#ifdef __ARM_EABI__
|
||||
GOT_INITSYM(.Lsetjmp_got, .Lsetjmp_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__ && (!__thumb__ || _ARM_ARCH_T2) */
|
||||
END(__setjmp14)
|
||||
|
||||
ENTRY(__longjmp14)
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
ldr r2, [r0]
|
||||
ldr ip, .Lsetjmp_magic
|
||||
bic r3, r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
|
||||
teq r3, ip
|
||||
#else
|
||||
ldr r3, .Lsetjmp_magic
|
||||
mov ip, r3
|
||||
ldr r3, [r0]
|
||||
movs r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
|
||||
bics r3, r2
|
||||
/* r2 is not the magic but we don't need it since we can't do VFP */
|
||||
#endif
|
||||
cmp r3, ip
|
||||
bne .Lbotch
|
||||
|
||||
/* Restore the signal mask. */
|
||||
stmfd sp!, {r0-r2, r14}
|
||||
mov r2, #0x00000000
|
||||
add r1, r0, #(_JB_SIGMASK * 4)
|
||||
mov r0, #3 /* SIG_SETMASK */
|
||||
push {r0-r2, lr}
|
||||
movs r2, #0
|
||||
#if !defined(__thumb__)
|
||||
adds r1, r0, #(_JB_SIGMASK * 4)
|
||||
#else
|
||||
mov r1, r0
|
||||
adds r1, r1, #(_JB_SIGMASK * 4)
|
||||
#endif
|
||||
movs r0, #3 /* SIG_SETMASK */
|
||||
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
|
||||
|
||||
#ifdef __ARM_EABI__
|
||||
#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2))
|
||||
tst r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
|
||||
/* is this a VFP magic? */
|
||||
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
|
||||
adds r2, r0, #(_JB_REG_D8 * 4)
|
||||
vldmia r2, {d8-d15}
|
||||
ldr r2, [r0, #(_JB_REG_FPSCR * 4)]
|
||||
vmsr fpscr, r2
|
||||
1:
|
||||
#endif /* __ARM_EABI__ */
|
||||
#endif /* __ARM_EABI__ && (!__thumb__ || _ARM_ARCH_T2) */
|
||||
|
||||
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 r11, r3
|
||||
adds r0, r0, #4 /* skip ip(r12) */
|
||||
#endif
|
||||
|
||||
/* Validate sp and r14 */
|
||||
teq sp, #0
|
||||
teqne r14, #0
|
||||
ldmia r0!, {r2-r3}
|
||||
|
||||
/* Validate sp and lr */
|
||||
#if defined(__thumb__) && defined(_ARM_ARCH_T2)
|
||||
cbz r2, .Lbotch
|
||||
#else
|
||||
cmp r2, #0
|
||||
beq .Lbotch
|
||||
#endif
|
||||
mov sp, r2
|
||||
|
||||
#if defined(__thumb__) && defined(_ARM_ARCH_T2)
|
||||
cbz r3, .Lbotch
|
||||
#else
|
||||
cmp r3, #0
|
||||
beq .Lbotch
|
||||
#endif
|
||||
mov lr, r3
|
||||
|
||||
/* Set return value */
|
||||
movs r0, r1
|
||||
moveq r0, #0x00000001
|
||||
#if !defined(__thumb__)
|
||||
moveq r0, #1
|
||||
#else
|
||||
bne 1f
|
||||
movs r0, #1
|
||||
1:
|
||||
#endif
|
||||
RET
|
||||
|
||||
/* validation failed, die die die. */
|
||||
.Lbotch:
|
||||
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
|
||||
.Lsetjmp_magic:
|
||||
.word _JB_MAGIC_SETJMP
|
||||
END(__longjmp14)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sigsetjmp.S,v 1.6 2013/04/19 16:50:22 matt Exp $ */
|
||||
/* $NetBSD: sigsetjmp.S,v 1.7 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Mark Brinicombe
|
||||
|
@ -46,17 +46,50 @@
|
|||
*/
|
||||
|
||||
ENTRY(__sigsetjmp14)
|
||||
teq r1, #0
|
||||
beq PIC_SYM(_C_LABEL(_setjmp), PLT)
|
||||
b PIC_SYM(_C_LABEL(__setjmp14), PLT)
|
||||
|
||||
.L_setjmp_magic:
|
||||
.word _JB_MAGIC__SETJMP
|
||||
#if defined(__thumb__) && defined(_ARM_ARCH_T2)
|
||||
cbnz r1, 1f
|
||||
b PLT_SYM(_C_LABEL(_setjmp))
|
||||
1: b PLT_SYM(_C_LABEL(__setjmp14))
|
||||
#elif !defined(__thumb__)
|
||||
cmp r1, #0
|
||||
beq PLT_SYM(_C_LABEL(_setjmp))
|
||||
b PLT_SYM(_C_LABEL(__setjmp14))
|
||||
#else
|
||||
push {r3, lr}
|
||||
beq 1f
|
||||
bl PLT_SYM(_C_LABEL(__setjmp14))
|
||||
b 2f
|
||||
1: bl PLT_SYM(_C_LABEL(_setjmp))
|
||||
2: pop {r3, pc}
|
||||
#endif
|
||||
END(__sigsetjmp14)
|
||||
|
||||
ENTRY(__siglongjmp14)
|
||||
ldr r2, .L_setjmp_magic
|
||||
ldr r3, [r0]
|
||||
bic r3, r3, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
|
||||
teq r2, r3
|
||||
#if !defined(__thumb__)
|
||||
bics r3, r3, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
|
||||
#else
|
||||
movs r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
|
||||
bics r3, r3, r2
|
||||
#endif
|
||||
ldr r2, .L_setjmp_magic
|
||||
cmp r2, r3
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
#ifdef __thumb__
|
||||
it eq
|
||||
#endif
|
||||
beq PIC_SYM(_C_LABEL(_longjmp), PLT)
|
||||
b PIC_SYM(_C_LABEL(__longjmp14), PLT)
|
||||
#else
|
||||
push {r3, lr}
|
||||
beq 11f
|
||||
bl PIC_SYM(_C_LABEL(__longjmp14), PLT)
|
||||
pop {r3, pc}
|
||||
11: bl PIC_SYM(_C_LABEL(_longjmp), PLT)
|
||||
pop {r3, pc}
|
||||
#endif
|
||||
|
||||
.align 0
|
||||
.L_setjmp_magic:
|
||||
.word _JB_MAGIC__SETJMP
|
||||
END(__siglongjmp14)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: swapcontext.S,v 1.9 2012/11/28 02:18:24 matt Exp $ */
|
||||
/* $NetBSD: swapcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -33,22 +33,53 @@
|
|||
#include "assym.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
RCSID("$NetBSD: swapcontext.S,v 1.9 2012/11/28 02:18:24 matt Exp $")
|
||||
RCSID("$NetBSD: swapcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
ENTRY(swapcontext)
|
||||
stmfd sp!, {r0-r1, lr} /* Must save oucp, ucp, lr. */
|
||||
sub sp, sp, #4
|
||||
.fnstart
|
||||
.cfi_startproc
|
||||
push {r0-r2, lr} /* Must save oucp, ucp, lr. */
|
||||
.save {r0-r2, lr}
|
||||
.cfi_def_cfa_offset 16
|
||||
.cfi_offset 14, -4
|
||||
.cfi_offset 2, -8
|
||||
.cfi_offset 1, -12
|
||||
.cfi_offset 0, -16
|
||||
bl PIC_SYM(_C_LABEL(_getcontext), PLT) /* getcontext(oucp) */
|
||||
cmp r0, #0
|
||||
add sp, sp, #4
|
||||
ldmfd sp!, {r0-r1, lr}
|
||||
#if !defined(__thumb__)
|
||||
pop {r0-r2, lr}
|
||||
.cfi_def_cfa_offset 0
|
||||
RETc(ne)
|
||||
#else
|
||||
pop {r0-r3}
|
||||
beq 1f
|
||||
.cfi_def_cfa_offset 0
|
||||
.cfi_register 14, 3
|
||||
RETr(r3)
|
||||
1:
|
||||
#endif
|
||||
#if !defined(__thumb__)
|
||||
str sp, [r0, #_UC_REGS_SP] /* Adjust saved SP. */
|
||||
str lr, [r0, #_UC_REGS_PC] /* Adjust saved PC. */
|
||||
str lr, [r0, #_UC_REGS_PC] /* Adjust saved SP. */
|
||||
#else
|
||||
mov r2, sp
|
||||
str r2, [r0, #_UC_REGS_SP] /* Adjust saved SP. */
|
||||
str r3, [r0, #_UC_REGS_PC] /* Adjust saved PC. */
|
||||
mov lr, r3
|
||||
#endif
|
||||
#ifdef SOFTFLOAT
|
||||
/* Ahem. */
|
||||
#endif
|
||||
mov r0, r1
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
b PIC_SYM(_C_LABEL(setcontext), PLT)
|
||||
#else
|
||||
push {lr}
|
||||
bl PIC_SYM(_C_LABEL(setcontext), PLT)
|
||||
RET
|
||||
pop {pc}
|
||||
#endif
|
||||
.cfi_endproc
|
||||
.fnend
|
||||
END(swapcontext)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __clone.S,v 1.7 2013/08/01 05:54:24 matt Exp $ */
|
||||
/* $NetBSD: __clone.S,v 1.8 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Christopher Gilbert
|
||||
|
@ -26,9 +26,8 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/errno.h>
|
||||
#include "SYS.h"
|
||||
#include <sys/errno.h>
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(clone, __clone)
|
||||
|
@ -40,54 +39,90 @@ WEAK_ALIAS(clone, __clone)
|
|||
ENTRY(__clone)
|
||||
|
||||
/* test stack and function are not null */
|
||||
teq r0, #0x00
|
||||
teqne r1, #0x00
|
||||
#if defined(__thumb__) && defined(_ARM_ARCH_T2)
|
||||
cbz r0, .Leinval
|
||||
cbz r1, .Leinval
|
||||
#elif !defined(__thumb__)
|
||||
cmp r0, #0x00
|
||||
cmpne r1, #0x00
|
||||
beq .Leinval
|
||||
#else
|
||||
cmp r0, #0x00
|
||||
beq .Leinval
|
||||
cmp r1, #0x00
|
||||
beq .Leinval
|
||||
#endif
|
||||
|
||||
/* place the func and its arg onto the child's stack */
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
stmfd r1!, {r0, r3}
|
||||
#else
|
||||
subs r1, r1, #8
|
||||
stmia r1!, {r0, r3}
|
||||
#endif
|
||||
|
||||
/* syscall expects (flags, stack) */
|
||||
mov r0, r2
|
||||
|
||||
SYSTRAP(__clone)
|
||||
bcs CERROR
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
_INVOKE_CERROR()
|
||||
#else
|
||||
bcs .Lcerror
|
||||
#endif
|
||||
|
||||
/*
|
||||
* r1 and r0 are the same as from fork:
|
||||
* r1 == 0 in parent process, r1 == 1 in child process.
|
||||
* r0 == pid of child in parent, r0 == pid of parent in child.
|
||||
*/
|
||||
teq r1, #0x00
|
||||
|
||||
/* if this is the parent then just return the pid */
|
||||
#if defined(__thumb__)
|
||||
#if defined(_ARM_ARCH_T2)
|
||||
cbz r1, 1f
|
||||
#else
|
||||
cmp r1, #0x00
|
||||
bne 1f
|
||||
#endif
|
||||
RET
|
||||
1:
|
||||
#else
|
||||
cmp r1, #0x00
|
||||
RETc(eq)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is the child
|
||||
* load the function and arg off the stack
|
||||
*/
|
||||
ldmfd sp!, {r1, r2}
|
||||
|
||||
/* setup return address */
|
||||
add lr, pc, #.Lreturnhere - . - 8
|
||||
pop {r1, r2}
|
||||
|
||||
/* place arg in r0 */
|
||||
mov r0, r2
|
||||
|
||||
/* call the function */
|
||||
#ifdef _ARM_ARCH_4T
|
||||
bx r1
|
||||
#ifdef _ARM_ARCH_5T
|
||||
blx r1
|
||||
#else
|
||||
mov pc, r1
|
||||
/* setup return address */
|
||||
mov lr, pc
|
||||
RETr(r1)
|
||||
#endif
|
||||
|
||||
.Lreturnhere:
|
||||
/* call _exit with the returned value */
|
||||
b PIC_SYM(_C_LABEL(_exit), PLT)
|
||||
bl PIC_SYM(_C_LABEL(_exit), PLT)
|
||||
|
||||
/* NOTREACHED */
|
||||
|
||||
/* error handler if func or stack is NULL */
|
||||
.align 0
|
||||
.Leinval:
|
||||
mov R0, #EINVAL
|
||||
movs r0, #EINVAL
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
b CERROR
|
||||
#else
|
||||
.Lcerror:
|
||||
push {lr}
|
||||
bl CERROR
|
||||
pop {pc}
|
||||
#endif
|
||||
END(__clone)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __vfork14.S,v 1.9 2013/08/16 22:27:32 matt Exp $ */
|
||||
/* $NetBSD: __vfork14.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -40,9 +40,6 @@
|
|||
* r1 == 0 in parent process, r1 == 1 in child process.
|
||||
* r0 == pid of child in parent, r0 == pid of parent in child.
|
||||
*/
|
||||
.text
|
||||
.align 0
|
||||
|
||||
ENTRY(__vfork14)
|
||||
mov r2, lr
|
||||
SYSTRAP(__vfork14)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: brk.S,v 1.11 2013/08/01 05:54:24 matt Exp $ */
|
||||
/* $NetBSD: brk.S,v 1.12 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -52,15 +52,10 @@ _C_LABEL(__minbrk):
|
|||
* Change the data segment size
|
||||
*/
|
||||
ENTRY(_brk)
|
||||
ldr r1, .Lminbrk
|
||||
#ifdef PIC
|
||||
/* Setup the GOT */
|
||||
ldr r3, .Lgot
|
||||
add r3, pc, r3
|
||||
.L1:
|
||||
ldr r1, .Lminbrk
|
||||
add r1, r3, r1
|
||||
#else
|
||||
ldr r1, .Lminbrk
|
||||
adr r3, .Lminbrk
|
||||
adds r1, r1, r3
|
||||
#endif
|
||||
/* Get the minimum allowable brk address */
|
||||
ldr r1, [r1]
|
||||
|
@ -70,30 +65,31 @@ ENTRY(_brk)
|
|||
* if the address is below minbrk.
|
||||
*/
|
||||
cmp r0, r1
|
||||
#ifdef __thumb__
|
||||
bcs 1f
|
||||
mov r0, r1
|
||||
1:
|
||||
#else
|
||||
movcc r0, r1
|
||||
#endif
|
||||
mov r2, r0
|
||||
SYSTRAP(break)
|
||||
bcs CERROR
|
||||
_INVOKE_CERROR()
|
||||
|
||||
ldr r1, .Lcurbrk
|
||||
#ifdef PIC
|
||||
ldr r1, .Lcurbrk
|
||||
add r1, r3, r1
|
||||
#else
|
||||
ldr r1, .Lcurbrk
|
||||
adds r1, r1, r3
|
||||
#endif
|
||||
/* Store the new address in curbrk */
|
||||
str r2, [r1]
|
||||
|
||||
/* Return 0 for success */
|
||||
mov r0, #0x00000000
|
||||
movs r0, #0
|
||||
RET
|
||||
|
||||
.align 2
|
||||
#ifdef PIC
|
||||
.Lgot:
|
||||
.word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (.L1+4))
|
||||
#endif
|
||||
.align 0
|
||||
.Lminbrk:
|
||||
.word PIC_SYM(_C_LABEL(__minbrk), GOTOFF)
|
||||
.word REL_SYM(_C_LABEL(__minbrk), .Lminbrk)
|
||||
.Lcurbrk:
|
||||
.word PIC_SYM(_C_LABEL(__curbrk), GOTOFF)
|
||||
.word REL_SYM(_C_LABEL(__curbrk), .Lminbrk)
|
||||
END(_brk)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cerror.S,v 1.9 2013/08/01 05:54:24 matt Exp $ */
|
||||
/* $NetBSD: cerror.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -33,39 +33,70 @@
|
|||
|
||||
#include "SYS.h"
|
||||
|
||||
ASENTRY(CERROR)
|
||||
ENTRY_NP(CERROR)
|
||||
#ifdef _REENTRANT
|
||||
stmfd sp!, {r4, lr}
|
||||
#ifdef __ARM_EABI__
|
||||
.fnstart
|
||||
.cfi_startproc
|
||||
#endif
|
||||
push {r4, lr}
|
||||
#ifdef __ARM_EABI__
|
||||
.save {r4, lr}
|
||||
.cfi_def_cfa_offset 8
|
||||
.cfi_offset 14, -4
|
||||
.cfi_offset 4, -8
|
||||
#endif
|
||||
mov r4, r0
|
||||
bl PIC_SYM(_C_LABEL(__errno), PLT)
|
||||
str r4, [r0]
|
||||
mvn r0, #0x00000000
|
||||
mvn r1, #0x00000000
|
||||
ldmfd sp!, {r4, pc}
|
||||
#ifdef __thumb__
|
||||
movs r0, #0
|
||||
mvns r0, r0
|
||||
#else
|
||||
mvn r0, #0
|
||||
#endif
|
||||
mov r1, r0
|
||||
pop {r4, pc}
|
||||
#ifdef __ARM_EABI__
|
||||
.cfi_endproc
|
||||
.fnend
|
||||
#endif
|
||||
#else /* !_REENTRANT */
|
||||
#ifdef __ARM_EABI__
|
||||
.fnstart
|
||||
.cfi_startproc
|
||||
#endif
|
||||
#ifdef PIC
|
||||
/* Setup the GOT */
|
||||
ldr r3, .Lgot
|
||||
add r3, pc, r3
|
||||
.L1:
|
||||
add r3, r3, pc /* pc = &.LPIC0 */
|
||||
ldr r1, .Lerrno
|
||||
ldr r1, [r3, r1]
|
||||
.LPIC0: ldr r1, [r3, r1]
|
||||
#else
|
||||
ldr r1, .Lerrno
|
||||
#endif /* PIC */
|
||||
str r0, [r1]
|
||||
mvn r0, #0x00000000
|
||||
mvn r1, #0x00000000
|
||||
#ifdef __thumb__
|
||||
movs r0, #0
|
||||
mvns r0, r0
|
||||
#else
|
||||
mvn r0, #0
|
||||
#endif /* __thumb__ */
|
||||
mov r1, r0
|
||||
RET
|
||||
#ifdef __ARM_EABI__
|
||||
.cfi_endproc
|
||||
.fnend
|
||||
#endif
|
||||
|
||||
#ifdef PIC
|
||||
.align 0
|
||||
.Lgot:
|
||||
.word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (.L1+4))
|
||||
.word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - .LPIC0
|
||||
#endif /* PIC */
|
||||
|
||||
.globl _C_LABEL(errno)
|
||||
|
||||
.Lerrno:
|
||||
.word PIC_SYM(_C_LABEL(errno), GOT)
|
||||
#endif /* _REENTRANT */
|
||||
END(CERROR)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getcontext.S,v 1.9 2013/08/01 05:54:24 matt Exp $ */
|
||||
/* $NetBSD: getcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -33,7 +33,7 @@
|
|||
#include "assym.h"
|
||||
|
||||
#if defined(SYSLIBC_SCCS) && !defined(lint)
|
||||
RCSID("$NetBSD: getcontext.S,v 1.9 2013/08/01 05:54:24 matt Exp $")
|
||||
RCSID("$NetBSD: getcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $")
|
||||
#endif /* SYSLIBC_SCCS && !lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
|
@ -43,13 +43,19 @@ WEAK_ALIAS(getcontext, _getcontext)
|
|||
ENTRY(_getcontext)
|
||||
mov r2, r0 /* Must save argument pointer. */
|
||||
SYSTRAP (getcontext)
|
||||
bcs CERROR
|
||||
_INVOKE_CERROR()
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
str lr, [r2, #_UC_REGS_PC] /* Adjust PC. */
|
||||
#else
|
||||
mov r3, lr
|
||||
str r3, [r2, #_UC_REGS_PC] /* Adjust PC. */
|
||||
#endif
|
||||
#ifdef SOFTFLOAT
|
||||
/* Ahem. */
|
||||
/* Judging from the softfloat code we should at least save
|
||||
the exception codes and rounding mode here. */
|
||||
#endif
|
||||
mov r0, #0
|
||||
movs r0, #0
|
||||
str r0, [r2, #_UC_REGS_R0] /* Return 0. */
|
||||
RET
|
||||
END(_getcontext)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ptrace.S,v 1.9 2013/08/01 05:54:24 matt Exp $ */
|
||||
/* $NetBSD: ptrace.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -35,41 +35,52 @@
|
|||
|
||||
ENTRY(ptrace)
|
||||
#ifdef _REENTRANT
|
||||
stmfd sp!, {r0-r3, lr}
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
push {r0-r3, lr}
|
||||
#else
|
||||
push {r0-r4}
|
||||
mov r4, lr
|
||||
#endif
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl PIC_SYM(_C_LABEL(__errno), PLT)
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r1, #0x00000000
|
||||
movs r1, #0
|
||||
str r1, [r0]
|
||||
ldmfd sp!, {r0-r3, lr}
|
||||
#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
|
||||
pop {r0-r3, lr}
|
||||
#else
|
||||
stmfd sp!, {r0, r1}
|
||||
mov lr, r4
|
||||
pop {r0-r4}
|
||||
#endif
|
||||
#else
|
||||
push {r0, r1}
|
||||
#ifdef PIC
|
||||
/* Setup the GOT */
|
||||
ldr r0, .Lgot
|
||||
add r0, pc, r0
|
||||
.L1:
|
||||
adr r1, .Lgot
|
||||
add r0, r0, r1
|
||||
ldr r1, .Lerrno
|
||||
ldr r1, [r0, r1]
|
||||
#else
|
||||
ldr r1, .Lerrno
|
||||
#endif /* PIC */
|
||||
mov r0, #0x00000000
|
||||
movs r0, #0
|
||||
str r0, [r1]
|
||||
ldmfd sp!, {r0, r1}
|
||||
pop {r0, r1}
|
||||
#endif /* _REENTRANT */
|
||||
|
||||
SYSTRAP(ptrace)
|
||||
bcs CERROR
|
||||
_INVOKE_CERROR()
|
||||
RET
|
||||
|
||||
#ifndef _REENTRANT
|
||||
#ifdef PIC
|
||||
.align 0
|
||||
.Lgot:
|
||||
.word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (.L1+4))
|
||||
.word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - .Lgot
|
||||
#endif /* PIC */
|
||||
|
||||
.Lerrno:
|
||||
.word PIC_SYM(_C_LABEL(errno), GOT)
|
||||
#endif /* !_REENTRANT */
|
||||
END(ptrace)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sbrk.S,v 1.10 2013/08/01 05:32:33 matt Exp $ */
|
||||
/* $NetBSD: sbrk.S,v 1.11 2013/09/03 00:30:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -51,25 +51,24 @@ _C_LABEL(__curbrk):
|
|||
* Change the data segment size
|
||||
*/
|
||||
ENTRY(_sbrk)
|
||||
/* get address or PC offset to __curbrk */
|
||||
/* get address or offset to __curbrk */
|
||||
ldr r2, .Lcurbrk
|
||||
#ifdef PIC
|
||||
add r2, pc, r2
|
||||
.L1:
|
||||
add r2, r2, pc /* pc = &.LPIC0 */
|
||||
#endif
|
||||
|
||||
/* Get the current brk address */
|
||||
ldr r1, [r2]
|
||||
|
||||
/* Calculate new value */
|
||||
mov r3, r0
|
||||
add r0, r0, r1
|
||||
.LPIC0: mov r3, r0
|
||||
adds r0, r0, r1
|
||||
SYSTRAP(break)
|
||||
bcs CERROR
|
||||
_INVOKE_CERROR()
|
||||
|
||||
/* Store new curbrk value */
|
||||
ldr r0, [r2]
|
||||
add r1, r0, r3
|
||||
adds r1, r0, r3
|
||||
str r1, [r2]
|
||||
|
||||
/* Return old curbrk value */
|
||||
|
@ -77,8 +76,5 @@ ENTRY(_sbrk)
|
|||
|
||||
.align 0
|
||||
.Lcurbrk:
|
||||
#ifdef PIC
|
||||
.word _C_LABEL(__curbrk) - (.L1+4)
|
||||
#else
|
||||
.word _C_LABEL(__curbrk)
|
||||
#endif
|
||||
.word REL_SYM(_C_LABEL(__curbrk), .LPIC0)
|
||||
END(_sbrk)
|
||||
|
|
Loading…
Reference in New Issue