--- /dev/null
+/* $OpenBSD: DEFS.h,v 1.1 2016/08/06 19:16:09 guenther Exp $ */
+/*
+ * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * We define a hidden alias with the prefix "_libc_" for each global symbol
+ * that may be used internally. By referencing _libc_x instead of x, other
+ * parts of libc prevent overriding by the application and avoid unnecessary
+ * relocations.
+ */
+#define _HIDDEN(x) _libc_##x
+#define _HIDDEN_ALIAS(x,y) \
+ STRONG_ALIAS(_HIDDEN(x),y); \
+ .hidden _HIDDEN(x)
+#define _HIDDEN_FALIAS(x,y) \
+ _HIDDEN_ALIAS(x,y); \
+ .type _HIDDEN(x),#function
+
+/*
+ * For functions implemented in ASM that aren't syscalls.
+ * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names
+ * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names
+ */
+#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x))
+#define END_WEAK(x) END_STRONG(x); .weak x
-/* $OpenBSD: SYS.h,v 1.15 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.16 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */
/*-
* from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
*/
-#include <machine/asm.h>
+#include "DEFS.h"
#include <sys/syscall.h>
-/*
- * We define a hidden alias with the prefix "_libc_" for each global symbol
- * that may be used internally. By referencing _libc_x instead of x, other
- * parts of libc prevent overriding by the application and avoid unnecessary
- * relocations.
- */
-#define _HIDDEN(x) _libc_##x
-#define _HIDDEN_ALIAS(x,y) \
- STRONG_ALIAS(_HIDDEN(x),y); \
- .hidden _HIDDEN(x)
-#define _HIDDEN_FALIAS(x,y) \
- _HIDDEN_ALIAS(x,y); \
- .type _HIDDEN(x),#function
-
-/*
- * For functions implemented in ASM that aren't syscalls.
- * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names
- * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names
- */
-#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x))
-#define END_WEAK(x) END_STRONG(x); .weak x
-
-
#define SYSENTRY(x) \
.weak _C_LABEL(x); \
_C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \
#define _SYSCALL(x, y) \
_SYSCALL_NOERROR(x,y); \
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
#define _SYSCALL_HIDDEN(x, y) \
_SYSCALL_HIDDEN_NOERROR(x,y); \
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
#define SYSCALL_NOERROR(x) \
_SYSCALL_NOERROR(x,x)
-/* $OpenBSD: _setjmp.S,v 1.3 2016/05/23 00:18:57 guenther Exp $ */
+/* $OpenBSD: _setjmp.S,v 1.4 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: _setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "DEFS.h"
#include <machine/setjmp.h>
/*
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
+END_STRONG(_setjmp)
ENTRY(_longjmp)
ldr r2, .L_setjmp_magic
/* validation failed, die die die. */
botch:
- bl PIC_SYM(_libc_abort, PLT)
+ bl _HIDDEN(abort)
b . - 8 /* Cannot get here */
+END_STRONG(_longjmp)
-/* $OpenBSD: divsi3.S,v 1.2 2004/02/01 05:40:52 drahn Exp $ */
+/* $OpenBSD: divsi3.S,v 1.3 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: divsi3.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "DEFS.h"
/*
* stack is aligned as there's a possibility of branching to .L_overflow
.L_overflow:
#if !defined(_KERNEL) && !defined(_STANDALONE)
mov r0, #8 /* SIGFPE */
- bl PIC_SYM(_C_LABEL(raise), PLT) /* raise it */
+ bl _HIDDEN(raise) /* raise it */
mov r0, #0
#else
/* XXX should cause a fatal error */
-/* $OpenBSD: setjmp.S,v 1.4 2016/05/23 00:18:57 guenther Exp $ */
+/* $OpenBSD: setjmp.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "DEFS.h"
#include <machine/setjmp.h>
/*
stmfd sp!, {r0, r14}
mov r0, #0x00000000
- bl PIC_SYM(_C_LABEL(_libc_sigblock), PLT)
+ bl _HIDDEN(sigblock)
mov r1, r0
ldmfd sp!, {r0, r14}
.Lsetjmp_magic:
.word _JB_MAGIC_SETJMP
+END_STRONG(setjmp)
ENTRY(longjmp)
sub sp, sp, #4 /* align the stack */
mov r0, r2
- bl PIC_SYM(_C_LABEL(_libc_sigsetmask), PLT)
+ bl _HIDDEN(sigsetmask)
add sp, sp, #4 /* unalign the stack */
ldmfd sp!, {r0, r1, r14}
/* validation failed, die die die. */
botch:
- bl PIC_SYM(_libc_abort, PLT)
+ bl _HIDDEN(abort)
b . - 8 /* Cannot get here */
+END_STRONG(longjmp)
-/* $OpenBSD: sigsetjmp.S,v 1.2 2004/02/01 05:40:52 drahn Exp $ */
+/* $OpenBSD: sigsetjmp.S,v 1.3 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: sigsetjmp.S,v 1.3 2002/08/17 19:54:30 thorpej Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "DEFS.h"
#include <machine/setjmp.h>
/*
ENTRY(sigsetjmp)
teq r1, #0
- beq PIC_SYM(_C_LABEL(_setjmp), PLT)
- b PIC_SYM(_C_LABEL(setjmp), PLT)
+ beq _HIDDEN(_setjmp)
+ b _HIDDEN(setjmp)
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
ldr r2, .L_setjmp_magic
ldr r3, [r0]
teq r2, r3
- beq PIC_SYM(_C_LABEL(_longjmp), PLT)
- b PIC_SYM(_C_LABEL(longjmp), PLT)
+ beq _HIDDEN(_longjmp)
+ b _HIDDEN(longjmp)
-/* $OpenBSD: _memcpy.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: _memcpy.S,v 1.6 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: _memcpy.S,v 1.4 2003/04/05 23:08:52 bjh21 Exp $ */
/*-
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
/*
* This is one fun bit of code ...
.Lmemcpy_bsrcul1l4:
add r1, r1, #1
b .Lmemcpy_bl4
-END(_memcpy)
+END_STRONG(_memcpy)
-/* $OpenBSD: bcopy.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: bcopy.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: bcopy.S,v 1.2 2001/07/16 05:50:06 matt Exp $ */
/*-
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
/* bcopy = memcpy/memmove with arguments reversed. */
eor r0, r1, r0
eor r1, r0, r1
eor r0, r1, r0
- b PIC_SYM(_C_LABEL(_memcpy), PLT)
+ b _HIDDEN(_memcpy)
END_WEAK(bcopy)
-/* $OpenBSD: bzero.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: bzero.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: bzero.S,v 1.2 2001/07/16 05:50:06 matt Exp $ */
/*-
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
ENTRY(bzero)
mov r2, r1
mov r1, #0
- b PIC_SYM(_C_LABEL(memset), PLT)
+ b _HIDDEN(memset)
END_WEAK(bzero)
-/* $OpenBSD: ffs.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: ffs.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: ffs.S,v 1.5 2003/04/05 23:08:52 bjh21 Exp $ */
/*
* Copyright (c) 2001 Christopher Gilbert
* SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
/*
* ffs - find first set bit, this algorithm isolates the first set
-/* $OpenBSD: memcmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: memcmp.S,v 1.6 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: memcmp.S,v 1.2 2003/04/05 23:08:52 bjh21 Exp $ */
/*
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
ENTRY(memcmp)
/* if (len == 0) return 0 */
-/* $OpenBSD: memcpy.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: memcpy.S,v 1.6 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: memcpy.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*-
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
/*
* XXX
ENTRY(memcpy)
stmfd sp!, {r0, lr}
- bl PIC_SYM(_C_LABEL(_memcpy), PLT)
+ bl _HIDDEN(_memcpy)
ldmfd sp!, {r0, pc}
END_STRONG(memcpy)
-/* $OpenBSD: memmove.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: memmove.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: memmove.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*-
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
ENTRY(memmove)
stmfd sp!, {r0, lr}
- bl PIC_SYM(_C_LABEL(_memcpy), PLT)
+ bl _HIDDEN(_memcpy)
ldmfd sp!, {r0, pc}
END_STRONG(memmove)
-/* $OpenBSD: memset.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: memset.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: memset.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*
* SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
/*
* Sets a block of memory to the specified value
-/* $OpenBSD: strcmp.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: strcmp.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: strcmp.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
ENTRY(strcmp)
1:
-/* $OpenBSD: strncmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: strncmp.S,v 1.6 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: strncmp.S,v 1.2 2003/04/05 23:08:52 bjh21 Exp $ */
/*
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
ENTRY(strncmp)
/* if (len == 0) return 0 */
-/* $OpenBSD: Ovfork.S,v 1.6 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.7 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.6 2003/08/07 16:42:03 agc Exp $ */
/*-
SYSENTRY_HIDDEN(vfork)
mov r2, r14
SYSTRAP(vfork)
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
mov r15, r2
SYSCALL_END_HIDDEN(vfork)
-/* $OpenBSD: brk.S,v 1.8 2016/05/30 05:18:52 guenther Exp $ */
+/* $OpenBSD: brk.S,v 1.9 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: brk.S,v 1.7 2003/12/26 11:23:44 martin Exp $ */
/*-
movcc r0, r1
mov r2, r0
SYSTRAP(break)
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
#ifdef __PIC__
ldr r1, .Lcurbrk
-/* $OpenBSD: cerror.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: cerror.S,v 1.9 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: cerror.S,v 1.5 2003/08/07 16:42:04 agc Exp $ */
/*-
_ENTRY(CERROR)
stmfd sp!, {r4, lr}
mov r4, r0
- bl PIC_SYM(_C_LABEL(__errno), PLT)
+ bl _HIDDEN(__errno)
str r4, [r0]
mvn r0, #0x00000000
mvn r1, #0x00000000
-/* $OpenBSD: sbrk.S,v 1.8 2016/05/30 05:18:52 guenther Exp $ */
+/* $OpenBSD: sbrk.S,v 1.9 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: sbrk.S,v 1.7 2003/08/07 16:42:05 agc Exp $ */
/*-
mov r3, r0
add r0, r0, r1
SYSTRAP(break)
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
/* Store new curbrk value */
ldr r0, [r2]
-/* $OpenBSD: sigpending.S,v 1.4 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: sigpending.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: sigpending.S,v 1.5 2003/08/07 16:42:05 agc Exp $ */
/*-
SYSENTRY(sigpending)
mov r2, r0
SYSTRAP(sigpending)
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
str r0, [r2]
mov r0, #0x00000000
mov r15, r14
-/* $OpenBSD: sigprocmask.S,v 1.4 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.5 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: sigprocmask.S,v 1.5 2003/08/07 16:42:05 agc Exp $ */
/*-
moveq r1, #0x00000000
ldrne r1, [r1]
SYSTRAP(sigprocmask)
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
teq r2, #0x00000000
strne r0, [r2]
mov r0, #0x00000000
-/* $OpenBSD: sigsuspend.S,v 1.5 2016/05/07 19:05:21 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.6 2016/08/06 19:16:09 guenther Exp $ */
/* $NetBSD: sigsuspend.S,v 1.6 2003/08/07 16:42:05 agc Exp $ */
/*-
SYSENTRY_HIDDEN(sigsuspend)
ldr r0, [r0]
SYSTRAP(sigsuspend)
- bcs PIC_SYM(CERROR, PLT)
+ bcs CERROR
mov r0, #0x00000000
mov r15, r14
SYSCALL_END_HIDDEN(sigsuspend)
-/* $OpenBSD: tfork_thread.S,v 1.3 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.4 2016/08/06 19:16:09 guenther Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@openbsd.org>
*
ENTRY(__tfork_thread)
SYSTRAP(__tfork)
- bcs 1f /* XXX can this be PIC_SYM(CERROR, PLT) ? */
+ bcs CERROR
/* check if we are parent or child */
cmp r0, #0
mov pc, r2
nop
SYSTRAP(__threxit)
-1:
- b PIC_SYM(CERROR, PLT)
END(__tfork_thread)