Index: Makefile.inc1 =================================================================== --- Makefile.inc1 +++ Makefile.inc1 @@ -2473,6 +2473,7 @@ _startup_libs= gnu/lib/csu _startup_libs+= lib/csu _startup_libs+= lib/libcompiler_rt +_startup_libs+= lib/libsys _startup_libs+= lib/libc _startup_libs+= lib/libc_nonshared .if ${MK_LIBCPLUSPLUS} != "no" Index: lib/Makefile =================================================================== --- lib/Makefile +++ lib/Makefile @@ -13,6 +13,7 @@ .WAIT \ libc \ libc_nonshared \ + libsys \ libcompiler_rt \ ${_libclang_rt} \ ${_libcplusplus} \ @@ -106,7 +107,7 @@ SUBDIR_DEPEND_libauditdm= libbsm SUBDIR_DEPEND_libbsnmp= ${_libnetgraph} SUBDIR_DEPEND_libc++:= libcxxrt -SUBDIR_DEPEND_libc= libcompiler_rt +SUBDIR_DEPEND_libc= libsys libcompiler_rt SUBDIR_DEPEND_libcam= libsbuf SUBDIR_DEPEND_libcasper= libnv SUBDIR_DEPEND_libdevstat= libkvm @@ -122,6 +123,7 @@ SUBDIR_DEPEND_libprocstat= libkvm libutil SUBDIR_DEPEND_libradius= libmd SUBDIR_DEPEND_libsmb= libkiconv +SUBDIR_DEPEND_libsys= libcompiler_rt SUBDIR_DEPEND_libtacplus= libmd SUBDIR_DEPEND_libulog= libmd SUBDIR_DEPEND_libunbound= ${_libldns} Index: lib/libc/Makefile =================================================================== --- lib/libc/Makefile +++ lib/libc/Makefile @@ -10,6 +10,7 @@ MK_TOOLCHAIN= yes LIBC_SRCTOP?= ${.CURDIR} +LIBSYS_SRCTOP?= ${.CURDIR}/../libsys/ # Pick the current architecture directory for libc. In general, this is # named MACHINE_CPUARCH, but some ABIs are different enough to require @@ -58,6 +59,9 @@ # LDFLAGS+= -nodefaultlibs LIBADD+= compiler_rt +LIBADD+= sys + +LDFLAGS+=-Wl,-f,libsys.so .if ${MK_SSP} != "no" LIBADD+= ssp_nonshared Index: lib/libc/aarch64/Symbol.map =================================================================== --- lib/libc/aarch64/Symbol.map +++ lib/libc/aarch64/Symbol.map @@ -8,9 +8,6 @@ * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { - /* PSEUDO syscalls */ - _exit; - _setjmp; _longjmp; fabs; @@ -27,7 +24,6 @@ htons; ntohl; ntohs; - vfork; makecontext; }; Index: lib/libc/aarch64/sys/Makefile.inc =================================================================== --- lib/libc/aarch64/sys/Makefile.inc +++ lib/libc/aarch64/sys/Makefile.inc @@ -1,5 +1,7 @@ # $FreeBSD$ +.PATH: ${LIBSYS_SRCTOP}/aarch64/sys/ + MIASM:= ${MIASM:Nfreebsd[467]_*} SRCS+= __vdso_gettc.c Index: lib/libc/amd64/SYS.h =================================================================== --- lib/libc/amd64/SYS.h +++ lib/libc/amd64/SYS.h @@ -38,17 +38,27 @@ #include #include +#define KERNCALL movq %rcx, %r10; syscall + +#if defined(PIC) && !defined(STATIC) +#define SYSCALL_BODY(name) \ + mov $0,%rdi; mov $0,%rsi; \ + mov $SYS_abort2,%eax; KERNCALL; \ + int $3; ret +#else +#define SYSCALL_BODY(name) \ + mov $SYS_##name,%eax; KERNCALL; \ + jb HIDENAME(cerror); ret +#endif + #define RSYSCALL(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror); ret; \ + SYSCALL_BODY(name); \ END(__sys_##name) #define PSEUDO(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror); ret; \ + SYSCALL_BODY(name); \ END(__sys_##name) -#define KERNCALL movq %rcx, %r10; syscall Index: lib/libc/amd64/sys/Makefile.inc =================================================================== --- lib/libc/amd64/sys/Makefile.inc +++ lib/libc/amd64/sys/Makefile.inc @@ -1,6 +1,8 @@ # from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp # $FreeBSD$ +.PATH: ${LIBSYS_SRCTOP}/amd64/sys/ + SRCS+= \ amd64_detect_rdfsgsbase.c \ amd64_get_fsbase.c \ Index: lib/libc/amd64/sys/vfork.S =================================================================== --- /dev/null +++ lib/libc/amd64/sys/vfork.S @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)Ovfork.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - - WEAK_REFERENCE(__sys_vfork, _vfork) - WEAK_REFERENCE(__sys_vfork, vfork) -ENTRY(__sys_vfork) - popq %rsi /* fetch return address (%rsi preserved) */ - mov $SYS_vfork,%rax - KERNCALL - jb 1f - jmp *%rsi -1: - pushq %rsi - jmp HIDENAME(cerror) -END(__sys_vfork) - - .section .note.GNU-stack,"",%progbits Index: lib/libc/arm/Symbol.map =================================================================== --- lib/libc/arm/Symbol.map +++ lib/libc/arm/Symbol.map @@ -8,9 +8,6 @@ * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { - /* PSEUDO syscalls */ - _exit; - __mcount; _setjmp; _longjmp; @@ -27,9 +24,6 @@ htons; ntohl; ntohs; - vfork; - brk; - sbrk; }; FBSD_1.3 { @@ -42,11 +36,6 @@ }; FBSDprivate_1.0 { - /* PSEUDO syscalls */ - __sys_getlogin; - _getlogin; - __sys_exit; - _set_tp; __aeabi_read_tp; ___longjmp; @@ -55,10 +44,6 @@ signalcontext; _signalcontext; __siglongjmp; - __sys_vfork; - _vfork; - _brk; - _sbrk; _libc_arm_fpu_present; }; Index: lib/libc/arm/sys/Makefile.inc =================================================================== --- lib/libc/arm/sys/Makefile.inc +++ lib/libc/arm/sys/Makefile.inc @@ -2,7 +2,3 @@ SRCS+= __vdso_gettc.c -MDASM= Ovfork.S cerror.S syscall.S - -# Don't generate default code for these syscalls: -NOASM+= sbrk.o vfork.o Index: lib/libc/arm/sys/Ovfork.S =================================================================== --- /dev/null +++ lib/libc/arm/sys/Ovfork.S @@ -1,57 +0,0 @@ -/* $NetBSD: Ovfork.S,v 1.6 2003/08/07 16:42:03 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -__FBSDID("$FreeBSD$"); -#include "SYS.h" - -/* - * pid = vfork(); - * - * On return from the SWI: - * 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(vfork) - mov r2, r14 - SYSTRAP(vfork) - bcs PIC_SYM(CERROR, PLT) - sub r1, r1, #1 /* r1 == 0xffffffff if parent, 0 if child */ - and r0, r0, r1 /* r0 == 0 if child, else unchanged */ - mov r15, r2 -END(vfork) - - .section .note.GNU-stack,"",%progbits Index: lib/libc/arm/sys/cerror.S =================================================================== --- /dev/null +++ lib/libc/arm/sys/cerror.S @@ -1,51 +0,0 @@ -/* $NetBSD: cerror.S,v 1.5 2003/08/07 16:42:04 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90 - */ - -#include -__FBSDID("$FreeBSD$"); -#include "SYS.h" - -.globl _C_LABEL(__error) -.type _C_LABEL(__error),%function - -ASENTRY(CERROR) - stmfd sp!, {r4, lr} - mov r4, r0 - bl PIC_SYM(_C_LABEL(__error), PLT) - str r4, [r0] - mvn r0, #0x00000000 - mvn r1, #0x00000000 - ldmfd sp!, {r4, pc} -END(CERROR) - - .section .note.GNU-stack,"",%progbits Index: lib/libc/i386/SYS.h =================================================================== --- lib/libc/i386/SYS.h +++ lib/libc/i386/SYS.h @@ -38,21 +38,27 @@ #include #include -#define SYSCALL(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ +#define KERNCALL int $0x80 + +#if defined(PIC) && !defined(STATIC) +#define SYSCALL_BODY(name) \ + pushl $0; pushl $0; \ + mov $SYS_abort2,%eax; KERNCALL; \ + int $3; ret +#else +#define SYSCALL_BODY(name) \ mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror) + jb HIDENAME(cerror); ret +#endif -#define RSYSCALL(name) SYSCALL(name); ret; END(__sys_##name) +#define RSYSCALL(name) ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + SYSCALL_BODY(name); \ + END(__sys_##name) #define PSEUDO(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror); ret; \ + SYSCALL_BODY(name); \ END(__sys_##name) -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x - -#define KERNCALL int $0x80 Index: lib/libc/i386/sys/Makefile.inc =================================================================== --- lib/libc/i386/sys/Makefile.inc +++ lib/libc/i386/sys/Makefile.inc @@ -1,6 +1,8 @@ # from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp # $FreeBSD$ +.PATH: ${LIBSYS_SRCTOP}/i386/sys/ + .if !defined(COMPAT_32BIT) SRCS+= i386_clr_watch.c i386_set_watch.c i386_vm86.c .endif Index: lib/libc/i386/sys/syscall.S =================================================================== --- /dev/null +++ lib/libc/i386/sys/syscall.S @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -ENTRY(syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - push %ecx - KERNCALL - push %ecx /* need to push a word to keep stack frame intact - upon return; the word must be the return address. */ - jb HIDENAME(cerror) - ret -END(syscall) - - .section .note.GNU-stack,"",%progbits Index: lib/libsys/Makefile =================================================================== --- /dev/null +++ lib/libsys/Makefile @@ -0,0 +1,73 @@ +# @(#)Makefile 8.2 (Berkeley) 2/3/94 +# $FreeBSD$ + +PACKAGE= clibs +SHLIBDIR?= /lib + +.include + +# Force building of libc_pic.a +MK_TOOLCHAIN= yes + +LIBC_SRCTOP?= ${.CURDIR}/../libc/ +LIBSYS_SRCTOP?= ${.CURDIR} + +.if exists(${LIBSYS_SRCTOP}/${MACHINE_ARCH}) +LIBSYS_ARCH=${MACHINE_ARCH} +.else +LIBSYS_ARCH=${MACHINE_CPUARCH} +.endif + +LIB=sys +SHLIB_MAJOR= 7 +WARNS?= 2 + +CFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include +CFLAGS+=-I${LIBSYS_SRCTOP}/${LIBSYS_ARCH} + +.PATH: ${LIBSYS_SRCTOP}/sys ${LIBSYS_SRCTOP}/${LIBSYS_ARCH}/sys + +INSTALL_PIC_ARCHIVE= +PRECIOUSLIB= + +# +# Link with static libcompiler_rt.a. +# +LDFLAGS+= -nodefaultlibs +LIBADD+= compiler_rt + +# Define (empty) variables so that make doesn't give substitution +# errors if the included makefiles don't change these: +MDSRCS= +MISRCS= +MDASM= +MIASM= +NOASM= + +.include "${LIBSYS_SRCTOP}/${LIBSYS_ARCH}/Makefile.inc" +.include "${LIBSYS_SRCTOP}/sys/Makefile.inc" + +VERSION_DEF=${LIBSYS_SRCTOP}/Versions.def +SYMBOL_MAPS=${SYM_MAPS} +CFLAGS+= -DSYMBOL_VERSIONING + +# If there are no machine dependent sources, append all the +# machine-independent sources: +.if empty(MDSRCS) +SRCS+= ${MISRCS} +.else +# Append machine-dependent sources, then append machine-independent sources +# for which there is no machine-dependent variant. +SRCS+= ${MDSRCS} +.for _src in ${MISRCS} +.if ${MDSRCS:R:M${_src:R}} == "" +SRCS+= ${_src} +.endif +.endfor +.endif + +MAN= +MLINKS= + +.include + Index: lib/libsys/Versions.def =================================================================== --- /dev/null +++ lib/libsys/Versions.def @@ -0,0 +1,42 @@ +# $FreeBSD$ + +# +# Note: Whenever bumping the FBSD version, always make +# FBSDprivate_1.0 depend on the new FBSD version. +# This will keep it at the end of the dependency chain. +# + +# This is our first version; it depends on no other. +# This version was first added to 7.0-current. +FBSD_1.0 { +}; + +# This version was first added to 8.0-current. +FBSD_1.1 { +} FBSD_1.0; + +# This version was first added to 9.0-current. +FBSD_1.2 { +} FBSD_1.1; + +# This version was first added to 10.0-current. +FBSD_1.3 { +} FBSD_1.2; + +# This version was first added to 11.0-current. +FBSD_1.4 { +} FBSD_1.3; + +# This version was first added to 12.0-current. +FBSD_1.5 { +} FBSD_1.4; + + +# This is our private namespace. Any global interfaces that are +# strictly for use only by other FreeBSD applications and libraries +# are listed here. We use a separate namespace so we can write +# simple ABI-checking tools. +# +# Please do NOT increment the version of this namespace. +FBSDprivate_1.0 { +} FBSD_1.5; Index: lib/libsys/aarch64/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/aarch64/Makefile.inc @@ -0,0 +1,7 @@ +# $FreeBSD$ +# +# Machine dependent definitions for the arm architecture. +# + +SYM_MAPS+=${LIBSYS_SRCTOP}/aarch64/Symbol.map + Index: lib/libsys/aarch64/SYS.h =================================================================== --- lib/libsys/aarch64/SYS.h +++ lib/libsys/aarch64/SYS.h @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015 The FreeBSD Foundation * All rights reserved. * * This software was developed by Andrew Turner under @@ -25,11 +26,46 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ +#include #include -__FBSDID("$FreeBSD$"); -#include "SYS.h" +#define _SYSCALL(name) \ + mov x8, SYS_ ## name; \ + svc 0 + +#define SYSCALL(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + ret; \ +END(__sys_##name) + +/* + * Conditional jumps can only go up to one megabyte in either + * direction, and cerror can be located anywhere, so we have + * to jump around to use more capable unconditional branch + * instruction. + */ +#define PSEUDO(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + b.cs 1f; \ + ret; \ +1: b cerror; \ +END(__sys_##name) -RSYSCALL(syscall) +#define RSYSCALL(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + b.cs 1f; \ + ret; \ +1: b cerror; \ +END(__sys_##name) Index: lib/libsys/aarch64/Symbol.map =================================================================== --- lib/libsys/aarch64/Symbol.map +++ lib/libsys/aarch64/Symbol.map @@ -11,27 +11,6 @@ /* PSEUDO syscalls */ _exit; - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; vfork; - makecontext; }; -FBSDprivate_1.0 { - _set_tp; - __makecontext; -}; Index: lib/libsys/aarch64/sys/Makefile.inc =================================================================== --- lib/libsys/aarch64/sys/Makefile.inc +++ lib/libsys/aarch64/sys/Makefile.inc @@ -2,8 +2,6 @@ MIASM:= ${MIASM:Nfreebsd[467]_*} -SRCS+= __vdso_gettc.c - MDASM= cerror.S \ syscall.S \ vfork.S Index: lib/libsys/amd64/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/amd64/Makefile.inc @@ -0,0 +1,6 @@ +# $FreeBSD$ +# +# Machine dependent definitions for the amd64 architecture. +# + +SYM_MAPS+=${LIBSYS_SRCTOP}/amd64/Symbol.map Index: lib/libsys/amd64/Symbol.map =================================================================== --- lib/libsys/amd64/Symbol.map +++ lib/libsys/amd64/Symbol.map @@ -9,29 +9,23 @@ */ FBSD_1.0 { /* PSEUDO syscalls */ - _exit; - - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; + rfork_thread; + brk; + sbrk; vfork; - makecontext; }; +/* + * + * FreeBSD private ABI + * + */ FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; + _brk; + __sys_vfork; + _vfork; }; Index: lib/libsys/amd64/sys/Makefile.inc =================================================================== --- lib/libsys/amd64/sys/Makefile.inc +++ lib/libsys/amd64/sys/Makefile.inc @@ -1,14 +1,7 @@ # from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp # $FreeBSD$ -SRCS+= \ - amd64_detect_rdfsgsbase.c \ - amd64_get_fsbase.c \ - amd64_get_gsbase.c \ - amd64_set_fsbase.c \ - amd64_set_gsbase.c - MDASM= vfork.S cerror.S getcontext.S # Don't generate default code for these syscalls: -NOASM+= sbrk.o vfork.o +NOASM+= vfork.o Index: lib/libsys/arm/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/arm/Makefile.inc @@ -0,0 +1,7 @@ +# $FreeBSD$ +# +# Machine dependent definitions for the arm architecture. +# + +SYM_MAPS+=${LIBSYS_SRCTOP}/arm/Symbol.map + Index: lib/libsys/arm/SYS.h =================================================================== --- lib/libsys/arm/SYS.h +++ lib/libsys/arm/SYS.h @@ -1,3 +1,5 @@ +/* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ + /*- * SPDX-License-Identifier: BSD-3-Clause * @@ -31,28 +33,50 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)SYS.h 5.5 (Berkeley) 5/7/91 + * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 * $FreeBSD$ */ -#include #include +#include +#include + +#define SYSTRAP(x) \ + mov ip, r7; \ + ldr r7, =SYS_ ## x; \ + swi 0; \ + mov r7, ip + +#define CERROR _C_LABEL(cerror) +#define CURBRK _C_LABEL(curbrk) + +#define _SYSCALL_NOERROR(x) \ + ENTRY(__CONCAT(__sys_, x)); \ + .weak _C_LABEL(x); \ + .set _C_LABEL(x), _C_LABEL(__CONCAT(__sys_,x)); \ + .weak _C_LABEL(__CONCAT(_,x)); \ + .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \ + SYSTRAP(x) -#define SYSCALL(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror) +#define _SYSCALL(x) \ + _SYSCALL_NOERROR(x); \ + it cs; \ + bcs PIC_SYM(CERROR, PLT) -#define RSYSCALL(name) SYSCALL(name); ret; END(__sys_##name) +#define SYSCALL(x) \ + _SYSCALL(x) -#define PSEUDO(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror); ret; \ - END(__sys_##name) +#define PSEUDO(x) \ + ENTRY(__CONCAT(__sys_, x)); \ + .weak _C_LABEL(__CONCAT(_,x)); \ + .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \ + SYSTRAP(x); \ + it cs; \ + bcs PIC_SYM(CERROR, PLT); \ + RET -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x +#define RSYSCALL(x) \ + _SYSCALL(x); \ + RET -#define KERNCALL int $0x80 + .globl CERROR Index: lib/libsys/arm/Symbol.map =================================================================== --- lib/libsys/arm/Symbol.map +++ lib/libsys/arm/Symbol.map @@ -11,27 +11,19 @@ /* PSEUDO syscalls */ _exit; - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; vfork; - makecontext; + brk; + sbrk; }; FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; + + __sys_vfork; + _vfork; + _brk; + _sbrk; }; Index: lib/libsys/arm/sys/Makefile.inc =================================================================== --- lib/libsys/arm/sys/Makefile.inc +++ lib/libsys/arm/sys/Makefile.inc @@ -1,7 +1,5 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c - MDASM= Ovfork.S cerror.S syscall.S # Don't generate default code for these syscalls: Index: lib/libsys/i386/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/i386/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +SYM_MAPS+=${LIBSYS_SRCTOP}/i386/Symbol.map Index: lib/libsys/i386/Symbol.map =================================================================== --- lib/libsys/i386/Symbol.map +++ lib/libsys/i386/Symbol.map @@ -10,28 +10,20 @@ FBSD_1.0 { /* PSEUDO syscalls */ _exit; - - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; + rfork_thread; vfork; - makecontext; + brk; + sbrk; }; FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; + __siglongjmp; + __sys_vfork; + _vfork; + _end; + _brk; }; Index: lib/libsys/i386/sys/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/i386/sys/Makefile.inc @@ -0,0 +1,7 @@ +# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp +# $FreeBSD$ + +MDASM= Ovfork.S cerror.S getcontext.S syscall.S + +NOASM+= vfork.o + Index: lib/libsys/mips/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/mips/Makefile.inc @@ -0,0 +1,4 @@ +# $NetBSD: Makefile.inc,v 1.7 2005/09/17 11:49:39 tsutsui Exp $ +# $FreeBSD$ + +SYM_MAPS+= ${LIBSYS_SRCTOP}/mips/Symbol.map Index: lib/libsys/mips/SYS.h =================================================================== --- /dev/null +++ lib/libsys/mips/SYS.h @@ -0,0 +1,153 @@ +/* $NetBSD: SYS.h,v 1.19 2009/12/14 01:07:41 matt Exp $ */ +/* $FreeBSD$ */ + +/*- + * SPDX-License-Identifier: (BSD-4-Clause AND BSD-3-Clause) + * + * Copyright (c) 1996 Jonathan Stone + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jonathan Stone for + * the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)SYS.h 8.1 (Berkeley) 6/4/93 + */ + +#include + +#include + +/* + * If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops. + * + * i) Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after. + * ii) Do interprocedure jumps indirectly via t9, with the side-effect of + * preserving the callee's entry address in t9. + */ +#ifdef __ABICALLS__ + .abicalls +# if defined(__mips_o32) || defined(__mips_o64) +# define PIC_PROLOGUE(x) SETUP_GP +# define PIC_TAILCALL(l) PTR_LA t9, _C_LABEL(l); jr t9 +# define PIC_RETURN() j ra +# else +# define PIC_PROLOGUE(x) SETUP_GP64(t3, x) +# define PIC_TAILCALL(l) PTR_LA t9, _C_LABEL(l); RESTORE_GP64; jr t9 +# define PIC_RETURN() RESTORE_GP64; j ra +# endif +#else +# define PIC_PROLOGUE(x) +# define PIC_TAILCALL(l) j _C_LABEL(l) +# define PIC_RETURN() j ra +#endif /* __ABICALLS__ */ + +# define SYSTRAP(x) li v0,SYS_ ## x; syscall; + +/* + * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id) + */ +#define RSYSCALL_NOERROR(x) \ +LEAF(__sys_ ## x); \ + .weak _C_LABEL(x); \ + _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \ + .weak _C_LABEL(__CONCAT(_,x)); \ + _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ + SYSTRAP(x); \ + j ra; \ +END(__sys_ ## x) + +/* + * Do a normal syscall. + */ +#define RSYSCALL(x) \ +LEAF(__sys_ ## x); \ + .weak _C_LABEL(x); \ + _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \ + .weak _C_LABEL(__CONCAT(_,x)); \ + _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ + PIC_PROLOGUE(__sys_ ## x); \ + SYSTRAP(x); \ + bne a3,zero,err; \ + PIC_RETURN(); \ +err: \ + PIC_TAILCALL(__cerror); \ +END(__sys_ ## x) + +/* + * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint + * and syscall name are not the same. + */ +#define PSEUDO_NOERROR(x) \ +LEAF(__sys_ ## x); \ + .weak _C_LABEL(__CONCAT(_,x)); \ + _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ + SYSTRAP(x); \ + j ra; \ +END(__sys_ ## x) + +#define PSEUDO(x) \ +LEAF(__sys_ ## x); \ + .weak _C_LABEL(__CONCAT(_,x)); \ + _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ + PIC_PROLOGUE(__sys_ ## x); \ + SYSTRAP(x); \ + bne a3,zero,err; \ + PIC_RETURN(); \ +err: \ + PIC_TAILCALL(__cerror); \ +END(__sys_ ## x) Index: lib/libsys/mips/Symbol.map =================================================================== --- lib/libsys/mips/Symbol.map +++ lib/libsys/mips/Symbol.map @@ -11,27 +11,19 @@ /* PSEUDO syscalls */ _exit; - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; vfork; - makecontext; + brk; + sbrk; }; FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; + + __sys_vfork; + _vfork; + _brk; + _sbrk; }; Index: lib/libsys/mips/sys/Makefile.inc =================================================================== --- lib/libsys/mips/sys/Makefile.inc +++ lib/libsys/mips/sys/Makefile.inc @@ -1,8 +1,6 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c - -MDASM= Ovfork.S cerror.S syscall.S +MDASM= Ovfork.S cerror.S syscall.S # Don't generate default code for these syscalls: NOASM+= sbrk.o vfork.o Index: lib/libsys/mips/sys/Ovfork.S =================================================================== --- lib/libsys/mips/sys/Ovfork.S +++ lib/libsys/mips/sys/Ovfork.S @@ -1,9 +1,11 @@ +/* $NetBSD: compat_Ovfork.S,v 1.1 2005/09/17 11:49:39 tsutsui Exp $ */ + /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by - * William Jolitz. + * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,25 +32,33 @@ * SUCH DAMAGE. */ -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)Ovfork.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); - #include "SYS.h" - WEAK_REFERENCE(__sys_vfork, _vfork) - WEAK_REFERENCE(__sys_vfork, vfork) -ENTRY(__sys_vfork) - popl %ecx /* my rta into ecx */ - mov $SYS_vfork,%eax - KERNCALL - jb 1f - jmp *%ecx +#if defined(LIBC_SCCS) && !defined(lint) + ASMSTR("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93") + ASMSTR("$NetBSD: compat_Ovfork.S,v 1.1 2005/09/17 11:49:39 tsutsui Exp $") +#endif /* LIBC_SCCS and not lint */ + +/* + * pid = vfork(); + * + * v1 == 0 in parent process, v1 == 1 in child process. + * v0 == pid of child in parent, v0 == pid of parent in child. + */ + +LEAF(__sys_vfork) + WEAK_ALIAS(vfork, __sys_vfork) + WEAK_ALIAS(_vfork, __sys_vfork) + PIC_PROLOGUE(__sys_vfork) + li v0, SYS_vfork # system call number for vfork + syscall + beq a3, zero, 1f # jump if no errors + PIC_TAILCALL(__cerror) 1: - pushl %ecx - jmp HIDENAME(cerror) + beq v1, zero, 2f # parent process ? + move v0, zero # return zero in child +2: + PIC_RETURN() END(__sys_vfork) - - .section .note.GNU-stack,"",%progbits Index: lib/libsys/mips/sys/cerror.S =================================================================== --- lib/libsys/mips/sys/cerror.S +++ lib/libsys/mips/sys/cerror.S @@ -1,9 +1,11 @@ +/* $NetBSD: cerror.S,v 1.14 2009/12/14 01:07:42 matt Exp $ */ + /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by - * William Jolitz. + * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,39 +32,41 @@ * SUCH DAMAGE. */ -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)cerror.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); - #include "SYS.h" - .globl HIDENAME(cerror) - .hidden HIDENAME(cerror) - - /* - * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, - * it returns a pointer to the global errno variable. - */ - .globl CNAME(__error) - .type CNAME(__error),@function -HIDENAME(cerror): -#ifdef PIC - PIC_PROLOGUE - pushl %eax - call PIC_PLT(CNAME(__error)) - popl %ecx - PIC_EPILOGUE +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 + RCSID("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93") #else - pushl %eax - call CNAME(__error) - popl %ecx + RCSID("$NetBSD: cerror.S,v 1.14 2009/12/14 01:07:42 matt Exp $") #endif - movl %ecx,(%eax) - movl $-1,%eax - movl $-1,%edx - ret +#endif /* LIBC_SCCS and not lint */ + + .globl _C_LABEL(__error) +NESTED_NOPROFILE(__cerror, CALLFRAME_SIZ, ra) + .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ) + SETUP_GP + PTR_SUBU sp, sp, CALLFRAME_SIZ + SETUP_GP64(CALLFRAME_GP, __cerror) + SAVE_GP(CALLFRAME_GP) + + PTR_S ra, CALLFRAME_RA(sp) + REG_S v0, CALLFRAME_S0(sp) # save errno value + + PTR_LA t9, _C_LABEL(__error) # locate address of errno + jalr t9 + + REG_L t0, CALLFRAME_S0(sp) + PTR_L ra, CALLFRAME_RA(sp) + INT_S t0, 0(v0) # update errno value + + RESTORE_GP64 + PTR_ADDU sp, sp, CALLFRAME_SIZ + + li v0, -1 + li v1, -1 - .section .note.GNU-stack,"",%progbits + j ra +END(__cerror) Index: lib/libsys/mips/sys/syscall.S =================================================================== --- lib/libsys/mips/sys/syscall.S +++ lib/libsys/mips/sys/syscall.S @@ -1,8 +1,11 @@ -/* $NetBSD: syscall.S,v 1.4 2003/08/07 16:42:05 agc Exp $ */ +/* $NetBSD: syscall.S,v 1.5 2003/08/07 16:42:18 agc Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,14 +30,15 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 */ #include __FBSDID("$FreeBSD$"); #include "SYS.h" -RSYSCALL(syscall) +#if defined(LIBC_SCCS) && !defined(lint) + ASMSTR("from: @(#)syscall.s 8.1 (Berkeley) 6/4/93") + ASMSTR("$NetBSD: syscall.S,v 1.5 2003/08/07 16:42:18 agc Exp $") +#endif /* LIBC_SCCS and not lint */ - .section .note.GNU-stack,"",%progbits +RSYSCALL(syscall) Index: lib/libsys/powerpc/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/powerpc/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +SYM_MAPS+=${LIBSYS_SRCTOP}/powerpc/Symbol.map Index: lib/libsys/powerpc/SYS.h =================================================================== --- lib/libsys/powerpc/SYS.h +++ lib/libsys/powerpc/SYS.h @@ -1,11 +1,8 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. + * Copyright (c) 2002 Benno Rice. All rights reserved. + * Copyright (c) 2002 David E. O'Brien. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -15,11 +12,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the author nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE @@ -31,28 +28,45 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)SYS.h 5.5 (Berkeley) 5/7/91 + * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $ * $FreeBSD$ */ #include #include -#define SYSCALL(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror) - -#define RSYSCALL(name) SYSCALL(name); ret; END(__sys_##name) +#define _SYSCALL(name) \ + .text; \ + .align 2; \ + li 0,(SYS_##name); \ + sc -#define PSEUDO(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror); ret; \ - END(__sys_##name) +#define SYSCALL(name) \ + .text; \ + .align 2; \ +2: b PIC_PLT(CNAME(HIDENAME(cerror))); \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bso 2b -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x +#define PSEUDO(name) \ + .text; \ + .align 2; \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bnslr; \ + b PIC_PLT(CNAME(HIDENAME(cerror))) -#define KERNCALL int $0x80 +#define RSYSCALL(name) \ + .text; \ + .align 2; \ +2: b PIC_PLT(CNAME(HIDENAME(cerror))); \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bnslr; \ + b PIC_PLT(CNAME(HIDENAME(cerror))) Index: lib/libsys/powerpc/Symbol.map =================================================================== --- lib/libsys/powerpc/Symbol.map +++ lib/libsys/powerpc/Symbol.map @@ -11,27 +11,14 @@ /* PSEUDO syscalls */ _exit; - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; + brk; + sbrk; vfork; - makecontext; }; FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; }; Index: lib/libsys/powerpc/sys/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/powerpc/sys/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +MDASM+= cerror.S Index: lib/libsys/powerpc/sys/cerror.S =================================================================== --- lib/libsys/powerpc/sys/cerror.S +++ lib/libsys/powerpc/sys/cerror.S @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003 Peter Wemm + * Copyright (c) 2002 Peter Grehan. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,26 +23,35 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/* $NetBSD: cerror.S,v 1.5 2000/01/27 14:58:48 kleink Exp $ */ #include __FBSDID("$FreeBSD$"); + +#include "SYS.h" -#include + .globl HIDENAME(cerror) + .globl CNAME(__error) -/* - * This has to be magic to handle the multiple returns. - * Otherwise, the setcontext() syscall will return here and we'll - * pop off the return address and go to the *setcontext* call. - */ - WEAK_REFERENCE(__sys_getcontext, _getcontext) - WEAK_REFERENCE(__sys_getcontext, getcontext) -ENTRY(__sys_getcontext) - movl (%esp),%ecx /* save getcontext return address */ - mov $SYS_getcontext,%eax - KERNCALL - jb HIDENAME(cerror) - addl $4,%esp /* remove stale (setcontext) return address */ - jmp *%ecx /* restore return address */ -END(__sys_getcontext) + /* + * The __error() function is thread aware. For non-threaded + * programs and the initial threaded in threaded programs, + * it returns a pointer to the global errno variable. + */ +HIDENAME(cerror): + mflr %r0 + stwu %r1,-16(%r1) /* allocate new stack frame */ + stw %r0,20(%r1) /* and save lr, r31 */ + stw %r31,8(%r1) + mr %r31,%r3 /* stash errval in callee-saved register */ + bl PIC_PLT(CNAME(__error)) + stw %r31,0(%r3) /* store errval into &errno */ + lwz %r0,20(%r1) + lwz %r31,8(%r1) + mtlr %r0 + la %r1,16(%r1) + li %r3,-1 + li %r4,-1 + blr /* return to callers caller */ .section .note.GNU-stack,"",%progbits Index: lib/libsys/powerpc64/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/powerpc64/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +SYM_MAPS+=${LIBSYS_SRCTOP}/powerpc64/Symbol.map Index: lib/libsys/powerpc64/SYS.h =================================================================== --- /dev/null +++ lib/libsys/powerpc64/SYS.h @@ -0,0 +1,96 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2002 Benno Rice. All rights reserved. + * Copyright (c) 2002 David E. O'Brien. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $ + * $FreeBSD$ + */ + +#include +#include + +#define _SYSCALL(name) \ + .text; \ + .align 2; \ + li 0,(SYS_##name); \ + sc + +#define SYSCALL(name) \ + .text; \ + .align 2; \ +2: mflr %r0; \ + std %r0,16(%r1); \ + stdu %r1,-48(%r1); \ + bl CNAME(HIDENAME(cerror)); \ + nop; \ + addi %r1,%r1,48; \ + ld %r0,16(%r1); \ + mtlr %r0; \ + blr; \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bso 2b + +#define PSEUDO(name) \ + .text; \ + .align 2; \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bnslr; \ + mflr %r0; \ + std %r0,16(%r1); \ + stdu %r1,-48(%r1); \ + bl CNAME(HIDENAME(cerror)); \ + nop; \ + addi %r1,%r1,48; \ + ld %r0,16(%r1); \ + mtlr %r0; \ + blr; + +#define RSYSCALL(name) \ + .text; \ + .align 2; \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bnslr; \ + \ + mflr %r0; \ + std %r0,16(%r1); \ + stdu %r1,-48(%r1); \ + bl CNAME(HIDENAME(cerror)); \ + nop; \ + addi %r1,%r1,48; \ + ld %r0,16(%r1); \ + mtlr %r0; \ + blr; Index: lib/libsys/powerpc64/Symbol.map =================================================================== --- lib/libsys/powerpc64/Symbol.map +++ lib/libsys/powerpc64/Symbol.map @@ -11,27 +11,14 @@ /* PSEUDO syscalls */ _exit; - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; + brk; + sbrk; vfork; - makecontext; }; FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; }; Index: lib/libsys/powerpc64/sys/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/powerpc64/sys/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +MDASM+= cerror.S Index: lib/libsys/powerpc64/sys/cerror.S =================================================================== --- lib/libsys/powerpc64/sys/cerror.S +++ lib/libsys/powerpc64/sys/cerror.S @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003 Peter Wemm + * Copyright (c) 2002 Peter Grehan. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,26 +23,38 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/* $NetBSD: cerror.S,v 1.5 2000/01/27 14:58:48 kleink Exp $ */ #include __FBSDID("$FreeBSD$"); + +#include "SYS.h" -#include + .globl HIDENAME(cerror) + .globl CNAME(__error) -/* - * This has to be magic to handle the multiple returns. - * Otherwise, the setcontext() syscall will return here and we'll - * pop off the return address and go to the *setcontext* call. - */ - WEAK_REFERENCE(__sys_getcontext, _getcontext) - WEAK_REFERENCE(__sys_getcontext, getcontext) -ENTRY(__sys_getcontext) - movq (%rsp),%rsi /* save getcontext return address */ - mov $SYS_getcontext,%rax - KERNCALL - jb HIDENAME(cerror) - addq $8,%rsp /* remove stale (setcontext) return address */ - jmp *%rsi /* restore return address */ -END(__sys_getcontext) + /* + * The __error() function is thread aware. For non-threaded + * programs and the initial threaded in threaded programs, + * it returns a pointer to the global errno variable. + */ +ENTRY_NOPROF(HIDENAME(cerror)) + mflr %r0 + std %r0,16(%r1) /* save lr */ + stdu %r1,-64(%r1) /* allocate new stack frame */ + std %r31,48(%r1) + + mr %r31,%r3 /* stash errval in callee-saved register */ + bl CNAME(__error) + nop + stw %r31,0(%r3) /* store errval into &errno */ + + ld %r31,48(%r1) + ld %r1,0(%r1) + ld %r0,16(%r1) + mtlr %r0 + li %r3,-1 + li %r4,-1 + blr .section .note.GNU-stack,"",%progbits Index: lib/libsys/powerpcspe/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/powerpcspe/Makefile.inc @@ -0,0 +1,5 @@ +# $FreeBSD$ + +CFLAGS+= -I${LIBSYS_SRCTOP}/powerpc + +SYM_MAPS+=${LIBSYS_SRCTOP}/powerpc/Symbol.map Index: lib/libsys/powerpcspe/sys/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/powerpcspe/sys/Makefile.inc @@ -0,0 +1,4 @@ +# $FreeBSD$ + +.PATH: ${LIBSYS_SRCTOP}/powerpc/sys +.sinclude "${LIBSYS_SRCTOP}/powerpc/sys/Makefile.inc" Index: lib/libsys/riscv/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/riscv/Makefile.inc @@ -0,0 +1,6 @@ +# $FreeBSD$ +# +# Machine dependent definitions for the RISC-V architecture. +# + +SYM_MAPS+=${LIBSYS_SRCTOP}/riscv/Symbol.map Index: lib/libsys/riscv/SYS.h =================================================================== --- lib/libsys/riscv/SYS.h +++ lib/libsys/riscv/SYS.h @@ -1,7 +1,16 @@ /*- * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015 Ruslan Bukin * All rights reserved. * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -23,20 +32,41 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $FreeBSD$ */ +#include #include -__FBSDID("$FreeBSD$"); -ENTRY(cerror) - .hidden cerror - sub sp, sp, #16 - stp x0, lr, [sp] - bl _C_LABEL(__error) - ldp x1, lr, [sp] - str w1, [x0] - movn x0, #0 - movn x1, #0 - add sp, sp, #16 - ret -END(cerror) +#define _SYSCALL(name) \ + li t0, SYS_ ## name; \ + ecall + +#define SYSCALL(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + ret; \ +END(__sys_##name) + +#define PSEUDO(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bnez t0, 1f; \ + ret; \ +1: la t1, cerror; \ + jr t1; \ +END(__sys_##name) + +#define RSYSCALL(name) \ +ENTRY(__sys_##name); \ + WEAK_REFERENCE(__sys_##name, name); \ + WEAK_REFERENCE(__sys_##name, _##name); \ + _SYSCALL(name); \ + bnez t0, 1f; \ + ret; \ +1: la t1, cerror; \ + jr t1; \ +END(__sys_##name) Index: lib/libsys/riscv/sys/Makefile.inc =================================================================== --- lib/libsys/riscv/sys/Makefile.inc +++ lib/libsys/riscv/sys/Makefile.inc @@ -1,8 +1,8 @@ # $FreeBSD$ -SRCS+= __vdso_gettc.c - -MDASM= Ovfork.S cerror.S syscall.S +MDASM= cerror.S \ + syscall.S \ + vfork.S # Don't generate default code for these syscalls: NOASM+= sbrk.o vfork.o Index: lib/libsys/riscv/sys/cerror.S =================================================================== --- lib/libsys/riscv/sys/cerror.S +++ lib/libsys/riscv/sys/cerror.S @@ -1,7 +1,15 @@ /*- - * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015 Ruslan Bukin * All rights reserved. * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,21 +30,21 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * */ #include __FBSDID("$FreeBSD$"); ENTRY(cerror) - .hidden cerror - sub sp, sp, #16 - stp x0, lr, [sp] - bl _C_LABEL(__error) - ldp x1, lr, [sp] - str w1, [x0] - movn x0, #0 - movn x1, #0 - add sp, sp, #16 + addi sp, sp, -16 + sd a0, 0(sp) + sd ra, 8(sp) + call _C_LABEL(__error) + ld a1, 0(sp) + ld ra, 8(sp) + sw a1, 0(a0) + li a0, -1 + li a1, -1 + addi sp, sp, 16 ret END(cerror) Index: lib/libsys/riscv/sys/syscall.S =================================================================== --- lib/libsys/riscv/sys/syscall.S +++ lib/libsys/riscv/sys/syscall.S @@ -1,9 +1,14 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2015 Ruslan Bukin * All rights reserved. * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Index: lib/libsys/riscv/sys/vfork.S =================================================================== --- lib/libsys/riscv/sys/vfork.S +++ lib/libsys/riscv/sys/vfork.S @@ -1,7 +1,15 @@ /*- - * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015 Ruslan Bukin * All rights reserved. * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,7 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * */ #include @@ -32,11 +39,15 @@ ENTRY(__sys_vfork) WEAK_REFERENCE(__sys_vfork, vfork) WEAK_REFERENCE(__sys_vfork, _vfork) - mov x2, lr + mv a2, ra + _SYSCALL(vfork) - b.cs cerror - sub x1, x1, #1 - and x0, x0, x1 - mov lr, x2 + bnez t0, 1f + addi a1, a1, -1 + and a0, a0, a1 + mv ra, a2 + ret +1: la t1, cerror + jr t1 END(__sys_vfork) Index: lib/libsys/sparc64/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/sparc64/Makefile.inc @@ -0,0 +1,6 @@ +# $FreeBSD$ +# +# Machine dependent definitions for the ultra sparc architecture. +# + +SYM_MAPS+=${LIBSYS_SRCTOP}/sparc64/Symbol.map Index: lib/libsys/sparc64/SYS.h =================================================================== --- lib/libsys/sparc64/SYS.h +++ lib/libsys/sparc64/SYS.h @@ -32,27 +32,56 @@ * SUCH DAMAGE. * * @(#)SYS.h 5.5 (Berkeley) 5/7/91 + * from: FreeBSD: src/lib/libc/i386/SYS.h,v 1.20 2001/01/29 * $FreeBSD$ */ #include + #include +#include + +#define ERROR() \ + mov %o7, %g1 ; \ + call HIDENAME(cerror) ; \ + mov %g1, %o7 -#define SYSCALL(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror) +#define _SYSENTRY(x) \ +ENTRY(__CONCAT(__sys_,x)) ; \ + .weak CNAME(x) ; \ + .type CNAME(x),@function ; \ + .set CNAME(x),CNAME(__CONCAT(__sys_,x)) ; \ + .weak CNAME(__CONCAT(_,x)) ; \ + .type CNAME(__CONCAT(_,x)), @function ; \ + .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)) -#define RSYSCALL(name) SYSCALL(name); ret; END(__sys_##name) +#define _SYSEND(x) \ + .size CNAME(__CONCAT(__sys_,x)), . - CNAME(__CONCAT(__sys_,x)) ; \ + .size CNAME(__CONCAT(_,x)), . - CNAME(__CONCAT(__sys_,x)) ; \ + .size CNAME(__CONCAT(,x)), . - CNAME(__CONCAT(__sys_,x)) -#define PSEUDO(name) ENTRY(__sys_##name); \ - WEAK_REFERENCE(__sys_##name, _##name); \ - mov $SYS_##name,%eax; KERNCALL; \ - jb HIDENAME(cerror); ret; \ - END(__sys_##name) +#define _SYSCALL(x) \ + mov __CONCAT(SYS_,x), %g1 ; \ + ta %xcc, ST_SYSCALL ; \ + bcc,a,pt %xcc, 1f ; \ + nop ; \ + ERROR() ; \ +1: -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x +#define RSYSCALL(x) \ +_SYSENTRY(x) ; \ + _SYSCALL(x) ; \ + retl ; \ + nop ; \ + _SYSEND(x) -#define KERNCALL int $0x80 +#define PSEUDO(x) \ +ENTRY(__CONCAT(__sys_,x)) ; \ + .weak CNAME(__CONCAT(_,x)) ; \ + .type CNAME(__CONCAT(_,x)),@function ; \ + .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)) ; \ + _SYSCALL(x) ; \ + retl ; \ + nop ; \ + .size CNAME(__CONCAT(__sys_,x)), . - CNAME(__CONCAT(__sys_,x)) ; \ + .size CNAME(__CONCAT(_,x)), . - CNAME(__CONCAT(__sys_,x)) Index: lib/libsys/sparc64/Symbol.map =================================================================== --- lib/libsys/sparc64/Symbol.map +++ lib/libsys/sparc64/Symbol.map @@ -11,27 +11,26 @@ /* PSEUDO syscalls */ _exit; - _setjmp; - _longjmp; - fabs; - __flt_rounds; - fpgetmask; - fpsetmask; - __infinity; - __nan; - setjmp; - longjmp; - sigsetjmp; - siglongjmp; - htonl; - htons; - ntohl; - ntohs; + brk; + sbrk; vfork; - makecontext; + + __sparc_utrap_install; }; FBSDprivate_1.0 { - _set_tp; - __makecontext; + /* PSEUDO syscalls */ + __sys_getlogin; + _getlogin; + __sys_exit; + + __sys_brk; + _brk; + __sys_sbrk; + _sbrk; + __sys_vfork; + _vfork; + + /* used in src/lib/csu/sparc64/crt1.c */ + __sparc_utrap_setup; }; Index: lib/libsys/sparc64/sys/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/sparc64/sys/Makefile.inc @@ -0,0 +1,13 @@ +# $FreeBSD$ + +SRCS+= __sparc_sigtramp_setup.c \ + __sparc_utrap.c \ + __sparc_utrap_align.c \ + __sparc_utrap_emul.c \ + __sparc_utrap_fp_disabled.S \ + __sparc_utrap_gen.S \ + __sparc_utrap_install.c \ + __sparc_utrap_setup.c \ + sigcode.S + +MDASM+= cerror.S sigaction1.S Index: lib/libsys/sparc64/sys/__sparc_sigtramp_setup.c =================================================================== --- lib/libsys/sparc64/sys/__sparc_sigtramp_setup.c +++ lib/libsys/sparc64/sys/__sparc_sigtramp_setup.c @@ -1,9 +1,8 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. + * Copyright (c) 2002 Jake Burkholder. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,9 +26,23 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include "SYS.h" +#include + +#include +#include + +#include + +extern char __sigtramp[]; + +static const struct sparc_sigtramp_install_args sia = { __sigtramp, NULL }; + +void +__sparc_sigtramp_setup(void) +{ -RSYSCALL(syscall) + sysarch(SPARC_SIGTRAMP_INSTALL, (void *)&sia); +} Index: lib/libsys/sparc64/sys/__sparc_utrap.c =================================================================== --- /dev/null +++ lib/libsys/sparc64/sys/__sparc_utrap.c @@ -0,0 +1,143 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2001 Jake Burkholder. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "fpu_extern.h" +#include "__sparc_utrap_private.h" + +extern ssize_t __sys_write(int, const void *, size_t); +extern int __sys_kill(pid_t, int); +extern pid_t __sys_getpid(void); + +static const char *utrap_msg[] = { + "reserved", + "instruction access exception", + "instruction access error", + "instruction access protection", + "illtrap instruction", + "illegal instruction", + "privileged opcode", + "floating point disabled", + "floating point exception ieee 754", + "floating point exception other", + "tag overflow", + "division by zero", + "data access exception", + "data access error", + "data access protection", + "memory address not aligned", + "privileged action", + "async data error", + "trap instruction 16", + "trap instruction 17", + "trap instruction 18", + "trap instruction 19", + "trap instruction 20", + "trap instruction 21", + "trap instruction 22", + "trap instruction 23", + "trap instruction 24", + "trap instruction 25", + "trap instruction 26", + "trap instruction 27", + "trap instruction 28", + "trap instruction 29", + "trap instruction 30", + "trap instruction 31", +}; + +void +__sparc_utrap(struct utrapframe *uf) +{ + int sig; + + switch (uf->uf_type) { + case UT_FP_EXCEPTION_IEEE_754: + case UT_FP_EXCEPTION_OTHER: + sig = __fpu_exception(uf); + break; + case UT_ILLEGAL_INSTRUCTION: + sig = __emul_insn(uf); + break; + case UT_MEM_ADDRESS_NOT_ALIGNED: + sig = __unaligned_fixup(uf); + break; + default: + break; + } + if (sig) { + __utrap_write("__sparc_utrap: fatal "); + __utrap_write(utrap_msg[uf->uf_type]); + __utrap_write("\n"); + __utrap_kill_self(sig); + } + UF_DONE(uf); +} + +void +__utrap_write(const char *str) +{ + int berrno; + + berrno = errno; + __sys_write(STDERR_FILENO, str, strlen(str)); + errno = berrno; +} + +void +__utrap_kill_self(int sig) +{ + int berrno; + + berrno = errno; + __sys_kill(__sys_getpid(), sig); + errno = berrno; +} + +void +__utrap_panic(const char *msg) +{ + + __utrap_write(msg); + __utrap_write("\n"); + __utrap_kill_self(SIGKILL); +} Index: lib/libsys/sparc64/sys/__sparc_utrap_align.c =================================================================== --- /dev/null +++ lib/libsys/sparc64/sys/__sparc_utrap_align.c @@ -0,0 +1,119 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2002 Jake Burkholder. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include + +#include "__sparc_utrap_private.h" + +static u_long +__unaligned_load(u_char *p, int size) +{ + u_long val; + int i; + + val = 0; + for (i = 0; i < size; i++) + val = (val << 8) | p[i]; + return (val); +} + +static void +__unaligned_store(u_char *p, u_long val, int size) +{ + int i; + + for (i = 0; i < size; i++) + p[i] = val >> ((size - i - 1) * 8); +} + +int +__unaligned_fixup(struct utrapframe *uf) +{ + u_char *addr; + u_long val; + u_int insn; + int sig; + + sig = 0; + addr = (u_char *)uf->uf_sfar; + insn = *(u_int *)uf->uf_pc; + flushw(); + switch (IF_OP(insn)) { + case IOP_LDST: + switch (IF_F3_OP3(insn)) { + case INS3_LDUH: + val = __unaligned_load(addr, 2); + __emul_store_reg(uf, IF_F3_RD(insn), val); + break; + case INS3_LDUW: + val = __unaligned_load(addr, 4); + __emul_store_reg(uf, IF_F3_RD(insn), val); + break; + case INS3_LDX: + val = __unaligned_load(addr, 8); + __emul_store_reg(uf, IF_F3_RD(insn), val); + break; + case INS3_LDSH: + val = __unaligned_load(addr, 2); + __emul_store_reg(uf, IF_F3_RD(insn), + IF_SEXT(val, 16)); + break; + case INS3_LDSW: + val = __unaligned_load(addr, 4); + __emul_store_reg(uf, IF_F3_RD(insn), + IF_SEXT(val, 32)); + break; + case INS3_STH: + val = __emul_fetch_reg(uf, IF_F3_RD(insn)); + __unaligned_store(addr, val, 2); + break; + case INS3_STW: + val = __emul_fetch_reg(uf, IF_F3_RD(insn)); + __unaligned_store(addr, val, 4); + break; + case INS3_STX: + val = __emul_fetch_reg(uf, IF_F3_RD(insn)); + __unaligned_store(addr, val, 8); + break; + default: + sig = SIGILL; + break; + } + break; + default: + sig = SIGILL; + break; + } + return (sig); +} Index: lib/libsys/sparc64/sys/__sparc_utrap_emul.c =================================================================== --- /dev/null +++ lib/libsys/sparc64/sys/__sparc_utrap_emul.c @@ -0,0 +1,157 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2001 by Thomas Moestl . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include + +#include "__sparc_utrap_private.h" +#include "fpu_reg.h" + +int +__emul_insn(struct utrapframe *uf) +{ + u_long reg, res; + u_long *addr; + u_int insn; + int sig; + int rd; + int i; + + sig = 0; + insn = *(u_int *)uf->uf_pc; + flushw(); + switch (IF_OP(insn)) { + case IOP_MISC: + switch (IF_F3_OP3(insn)) { + case INS2_POPC: + if (IF_F3_RS1(insn) != 0) { + sig = SIGILL; + break; + } + reg = __emul_f3_op2(uf, insn); + for (i = 0; i < 64; i++) + res += (reg >> i) & 1; + __emul_store_reg(uf, IF_F3_RD(insn), res); + break; + default: + sig = SIGILL; + break; + } + break; + case IOP_LDST: + switch (IF_F3_OP3(insn)) { + case INS3_LDQF: + rd = INSFPdq_RN(IF_F3_RD(insn)); + addr = (u_long *)__emul_f3_memop_addr(uf, insn); + __fpu_setreg64(rd, addr[0]); + __fpu_setreg64(rd + 2, addr[1]); + break; + case INS3_STQF: + rd = INSFPdq_RN(IF_F3_RD(insn)); + addr = (u_long *)__emul_f3_memop_addr(uf, insn); + addr[0] = __fpu_getreg64(rd); + addr[1] = __fpu_getreg64(rd + 2); + break; + default: + sig = SIGILL; + break; + } + break; + default: + sig = SIGILL; + break; + } + return (sig); +} + +u_long +__emul_fetch_reg(struct utrapframe *uf, int reg) +{ + struct frame *frm; + + if (reg == IREG_G0) + return (0); + else if (reg < IREG_O0) /* global */ + return (uf->uf_global[reg]); + else if (reg < IREG_L0) /* out */ + return (uf->uf_out[reg - IREG_O0]); + else { /* local, in */ + /* + * The in registers are immediately after the locals in + * the frame. + */ + frm = (struct frame *)(uf->uf_out[6] + SPOFF); + return (frm->fr_local[reg - IREG_L0]); + } +} + +void +__emul_store_reg(struct utrapframe *uf, int reg, u_long val) +{ + struct frame *frm; + + if (reg == IREG_G0) + return; + if (reg < IREG_O0) /* global */ + uf->uf_global[reg] = val; + else if (reg < IREG_L0) /* out */ + uf->uf_out[reg - IREG_O0] = val; + else { + /* + * The in registers are immediately after the locals in + * the frame. + */ + frm = (struct frame *)(uf->uf_out[6] + SPOFF); + frm->fr_local[reg - IREG_L0] = val; + } +} + +u_long +__emul_f3_op2(struct utrapframe *uf, u_int insn) +{ + + if (IF_F3_I(insn) != 0) + return (IF_SIMM(insn, 13)); + else + return (__emul_fetch_reg(uf, IF_F3_RS2(insn))); +} + +u_long +__emul_f3_memop_addr(struct utrapframe *uf, u_int insn) +{ + u_long addr; + + addr = __emul_f3_op2(uf, insn) + __emul_fetch_reg(uf, IF_F3_RS1(insn)); + return (addr); +} Index: lib/libsys/sparc64/sys/__sparc_utrap_fp_disabled.S =================================================================== --- lib/libsys/sparc64/sys/__sparc_utrap_fp_disabled.S +++ lib/libsys/sparc64/sys/__sparc_utrap_fp_disabled.S @@ -1,10 +1,7 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2001 Jake Burkholder. * All rights reserved. * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -30,6 +27,10 @@ #include __FBSDID("$FreeBSD$"); -#include "SYS.h" +#include -RSYSCALL(syscall) +ENTRY(__sparc_utrap_fp_disabled) + ta %xcc, ST_FP_RESTORE + jmpl %l6, %g0 + return %l7 +END(__sparc_utrap_fp_disabled) Index: lib/libsys/sparc64/sys/__sparc_utrap_gen.S =================================================================== --- /dev/null +++ lib/libsys/sparc64/sys/__sparc_utrap_gen.S @@ -0,0 +1,107 @@ +/*- + * Copyright (c) 2001 Jake Burkholder. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + + .register %g2, #ignore + .register %g3, #ignore + .register %g6, #ignore + .register %g7, #ignore + +#include +#include + +#include "assym.s" + +ENTRY(__sparc_utrap_gen) + sub %sp, UF_SIZEOF, %sp + + stx %o0, [%sp + SPOFF + CCFSZ + UF_TYPE] + stx %o3, [%sp + SPOFF + CCFSZ + UF_TAR] + stx %o4, [%sp + SPOFF + CCFSZ + UF_SFAR] + stx %o5, [%sp + SPOFF + CCFSZ + UF_SFSR] + + stx %l4, [%sp + SPOFF + CCFSZ + UF_FSR] + stx %l5, [%sp + SPOFF + CCFSZ + UF_STATE] + stx %l6, [%sp + SPOFF + CCFSZ + UF_PC] + stx %l7, [%sp + SPOFF + CCFSZ + UF_NPC] + + stx %g1, [%sp + SPOFF + CCFSZ + UF_G1] + stx %g2, [%sp + SPOFF + CCFSZ + UF_G2] + stx %g3, [%sp + SPOFF + CCFSZ + UF_G3] + stx %g4, [%sp + SPOFF + CCFSZ + UF_G4] + stx %g5, [%sp + SPOFF + CCFSZ + UF_G5] + stx %g6, [%sp + SPOFF + CCFSZ + UF_G6] + stx %g7, [%sp + SPOFF + CCFSZ + UF_G7] + + stx %i0, [%sp + SPOFF + CCFSZ + UF_O0] + stx %i1, [%sp + SPOFF + CCFSZ + UF_O1] + stx %i2, [%sp + SPOFF + CCFSZ + UF_O2] + stx %i3, [%sp + SPOFF + CCFSZ + UF_O3] + stx %i4, [%sp + SPOFF + CCFSZ + UF_O4] + stx %i5, [%sp + SPOFF + CCFSZ + UF_O5] + stx %i6, [%sp + SPOFF + CCFSZ + UF_O6] + stx %i7, [%sp + SPOFF + CCFSZ + UF_O7] + + rd %y, %l6 + + call __sparc_utrap + add %sp, SPOFF + CCFSZ, %o0 + + wr %l6, 0, %y + + ldx [%sp + SPOFF + CCFSZ + UF_G1], %g1 + ldx [%sp + SPOFF + CCFSZ + UF_G2], %g2 + ldx [%sp + SPOFF + CCFSZ + UF_G3], %g3 + ldx [%sp + SPOFF + CCFSZ + UF_G4], %g4 + ldx [%sp + SPOFF + CCFSZ + UF_G5], %g5 + ldx [%sp + SPOFF + CCFSZ + UF_G6], %g6 + ldx [%sp + SPOFF + CCFSZ + UF_G7], %g7 + + ldx [%sp + SPOFF + CCFSZ + UF_O0], %i0 + ldx [%sp + SPOFF + CCFSZ + UF_O1], %i1 + ldx [%sp + SPOFF + CCFSZ + UF_O2], %i2 + ldx [%sp + SPOFF + CCFSZ + UF_O3], %i3 + ldx [%sp + SPOFF + CCFSZ + UF_O4], %i4 + ldx [%sp + SPOFF + CCFSZ + UF_O5], %i5 + ldx [%sp + SPOFF + CCFSZ + UF_O6], %i6 + ldx [%sp + SPOFF + CCFSZ + UF_O7], %i7 + + ldx [%sp + SPOFF + CCFSZ + UF_STATE], %l5 + ! Restore %asi and %ccr from the passed tstate + srlx %l5, TSTATE_CCR_SHIFT, %l4 + and %l4, CCR_MASK, %l4 + wr %l4, 0, %ccr + srlx %l5, TSTATE_ASI_SHIFT, %l4 + and %l4, ASI_MASK, %l4 + wr %l4, 0, %asi + ldx [%sp + SPOFF + CCFSZ + UF_PC], %l6 + ldx [%sp + SPOFF + CCFSZ + UF_NPC], %l7 + + jmpl %l6, %g0 + return %l7 +END(__sparc_utrap_gen) Index: lib/libsys/sparc64/sys/__sparc_utrap_install.c =================================================================== --- lib/libsys/sparc64/sys/__sparc_utrap_install.c +++ lib/libsys/sparc64/sys/__sparc_utrap_install.c @@ -1,9 +1,8 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. + * Copyright (c) 2001 Jake Burkholder. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,9 +26,26 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include "SYS.h" +#include +#include + +int +__sparc_utrap_install(utrap_entry_t type, utrap_handler_t new_precise, + utrap_handler_t new_deferred, utrap_handler_t *old_precise, + utrap_handler_t *old_deferred) +{ + struct sparc_utrap_install_args uia; + struct sparc_utrap_args ua[1]; -RSYSCALL(syscall) + ua[0].type = type; + ua[0].new_precise = new_precise; + ua[0].new_deferred = new_deferred; + ua[0].old_precise = old_precise; + ua[0].old_deferred = old_deferred; + uia.num = 1; + uia.handlers = ua; + return (sysarch(SPARC_UTRAP_INSTALL, &uia)); +} Index: lib/libsys/sparc64/sys/__sparc_utrap_private.h =================================================================== --- lib/libsys/sparc64/sys/__sparc_utrap_private.h +++ lib/libsys/sparc64/sys/__sparc_utrap_private.h @@ -1,9 +1,8 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. + * Copyright (c) 2001 Jake Burkholder. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,11 +24,45 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ -#include -__FBSDID("$FreeBSD$"); +#ifndef ___SPARC_UTRAP_PRIVATE_H_ +#define ___SPARC_UTRAP_PRIVATE_H_ + +#define UF_DONE(uf) do { \ + uf->uf_pc = uf->uf_npc; \ + uf->uf_npc = uf->uf_pc + 4; \ +} while (0) + +struct utrapframe { + u_long uf_global[8]; + u_long uf_out[8]; + u_long uf_pc; + u_long uf_npc; + u_long uf_sfar; + u_long uf_sfsr; + u_long uf_tar; + u_long uf_type; + u_long uf_state; + u_long uf_fsr; +}; + +extern char __sparc_utrap_fp_disabled[]; +extern char __sparc_utrap_gen[]; + +int __emul_insn(struct utrapframe *uf); +u_long __emul_fetch_reg(struct utrapframe *uf, int reg); +void __emul_store_reg(struct utrapframe *uf, int reg, u_long val); +u_long __emul_f3_op2(struct utrapframe *uf, u_int insn); +u_long __emul_f3_memop_addr(struct utrapframe *uf, u_int insn); +int __unaligned_fixup(struct utrapframe *uf); + +void __sparc_utrap(struct utrapframe *); -#include "SYS.h" +void __utrap_write(const char *); +void __utrap_kill_self(int); +void __utrap_panic(const char *); -RSYSCALL(syscall) +#endif Index: lib/libsys/sparc64/sys/__sparc_utrap_setup.c =================================================================== --- lib/libsys/sparc64/sys/__sparc_utrap_setup.c +++ lib/libsys/sparc64/sys/__sparc_utrap_setup.c @@ -1,9 +1,8 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. + * Copyright (c) 2001 Jake Burkholder. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,9 +26,33 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include "SYS.h" +#include + +#include +#include + +#include "__sparc_utrap_private.h" + +static const struct sparc_utrap_args ua[] = { + { UT_FP_DISABLED, __sparc_utrap_fp_disabled, NULL, NULL, NULL }, + { UT_FP_EXCEPTION_IEEE_754, __sparc_utrap_gen, NULL, NULL, NULL }, + { UT_FP_EXCEPTION_OTHER, __sparc_utrap_gen, NULL, NULL, NULL }, + { UT_ILLEGAL_INSTRUCTION, __sparc_utrap_gen, NULL, NULL, NULL }, + { UT_MEM_ADDRESS_NOT_ALIGNED, __sparc_utrap_gen, NULL, NULL, NULL }, +}; + +static const struct sparc_utrap_install_args uia[] = { + { nitems(ua), ua } +}; + +void __sparc_utrap_setup(void); + +void +__sparc_utrap_setup(void) +{ -RSYSCALL(syscall) + sysarch(SPARC_UTRAP_INSTALL, (void *)&uia); +} Index: lib/libsys/sparc64/sys/assym.s =================================================================== --- /dev/null +++ lib/libsys/sparc64/sys/assym.s @@ -0,0 +1,39 @@ +/* + * Offsets into structures used from asm. Must be kept in sync with + * appropriate headers. + * + * $FreeBSD$ + */ + +#define FPRS_FEF 0x4 + +#define CCR_MASK 0xff +#define ASI_MASK 0xff + +#define UF_G0 0x0 +#define UF_G1 0x8 +#define UF_G2 0x10 +#define UF_G3 0x18 +#define UF_G4 0x20 +#define UF_G5 0x28 +#define UF_G6 0x30 +#define UF_G7 0x38 +#define UF_O0 0x40 +#define UF_O1 0x48 +#define UF_O2 0x50 +#define UF_O3 0x58 +#define UF_O4 0x60 +#define UF_O5 0x68 +#define UF_O6 0x70 +#define UF_O7 0x78 +#define UF_PC 0x80 +#define UF_NPC 0x88 +#define UF_SFAR 0x90 +#define UF_SFSR 0x98 +#define UF_TAR 0xa0 +#define UF_TYPE 0xa8 +#define UF_STATE 0xb0 +#define UF_FSR 0xb8 +#define UF_SIZEOF 0xc0 + +#define SF_UC 0x0 Index: lib/libsys/sparc64/sys/cerror.S =================================================================== --- lib/libsys/sparc64/sys/cerror.S +++ lib/libsys/sparc64/sys/cerror.S @@ -28,18 +28,19 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * from: FreeBSD: src/lib/libc/i386/sys/cerror.S,v 1.11 2001/08/13 */ -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)cerror.s 5.1 (Berkeley) 4/23/90" -#endif /* SYSLIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); #include "SYS.h" - .globl HIDENAME(cerror) - .hidden HIDENAME(cerror) + .text + .align 16 + .globl HIDENAME(cerror) + .type HIDENAME(cerror),@function /* * The __error() function is thread aware. For non-threaded @@ -47,14 +48,12 @@ * it returns a pointer to the global errno variable. */ .globl CNAME(__error) - .type CNAME(__error),@function HIDENAME(cerror): - pushq %rax - call PIC_PLT(CNAME(__error)) - popq %rcx - movl %ecx,(%rax) - movq $-1,%rax - movq $-1,%rdx + save %sp, -CCFSZ, %sp + call CNAME(__error) + nop + stw %i0, [%o0] + mov -1, %i0 ret - - .section .note.GNU-stack,"",%progbits + restore %g0, -1, %o1 +END(HIDENAME(cerror)) Index: lib/libsys/sparc64/sys/sigaction1.S =================================================================== --- lib/libsys/sparc64/sys/sigaction1.S +++ lib/libsys/sparc64/sys/sigaction1.S @@ -1,10 +1,7 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2002 Jake Burkholder. * All rights reserved. * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -32,4 +29,22 @@ #include "SYS.h" -RSYSCALL(syscall) + WEAK_REFERENCE(__sys_sigaction, _sigaction) +ENTRY(__sys_sigaction) + PIC_PROLOGUE(%o3, %o4) + SET(sigcode_installed, %o4, %o3) + lduw [%o3], %o4 + brnz,a,pt %o4, 1f + nop + save %sp, -CCFSZ, %sp + call __sparc_sigtramp_setup + nop + restore + mov 1, %o4 + stw %o4, [%o3] +1: _SYSCALL(sigaction) + retl + nop +END(__sys_sigaction) + + .comm sigcode_installed, 4, 4 Index: lib/libsys/sparc64/sys/sigcode.S =================================================================== --- lib/libsys/sparc64/sys/sigcode.S +++ lib/libsys/sparc64/sys/sigcode.S @@ -1,10 +1,7 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2002 Jake Burkholder. * All rights reserved. * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -30,6 +27,14 @@ #include __FBSDID("$FreeBSD$"); -#include "SYS.h" +#include "assym.s" -RSYSCALL(syscall) +ENTRY(__sigtramp) + call %o4 + nop + call sigreturn + add %sp, SPOFF + CCFSZ + SF_UC, %o0 + call exit + mov 1, %o0 + illtrap +END(__sigtramp) Index: lib/libsys/sys/Makefile.inc =================================================================== --- /dev/null +++ lib/libsys/sys/Makefile.inc @@ -0,0 +1,135 @@ +# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 +# $FreeBSD$ + +# sys sources +.PATH: ${LIBSYS_SRCTOP}/${LIBSYS_ARCH}/sys ${LIBSYS_SRCTOP}/sys \ + ${LIBC_SRCTOP}/sys + +# Include the generated makefile containing the *complete* list +# of syscall names in MIASM. +.include "${SRCTOP}/sys/sys/syscall.mk" + +# Include machine dependent definitions. +# +# MDASM names override the default syscall names in MIASM. +# NOASM will prevent the default syscall code from being generated. +# PSEUDO generates _() and __sys_() symbols, but not (). +# +# While historically machine dependent, all architectures have the following +# declarations in common: +# +NOASM= break.o \ + exit.o \ + getlogin.o \ + sstk.o \ + yield.o +PSEUDO= _exit.o \ + _getlogin.o +.sinclude "${LIBSYS_SRCTOP}/${LIBSYS_ARCH}/sys/Makefile.inc" + +NOASM+= clock_gettime.o gettimeofday.o +PSEUDO+= _clock_gettime.o _gettimeofday.o + +# Sources common to both syscall interfaces: +SRCS+= \ + __error.c \ + +NOASM+= fstat.o fstatat.o fstatfs.o getfsstat.o statfs.o +PSEUDO+= _fstat.o _fstatat.o _fstatfs.o _getfsstat.o _statfs.o + +NOASM+= getdirentries.o +PSEUDO+= _getdirentries.o + +INTERPOSED = \ + accept \ + accept4 \ + aio_suspend \ + clock_nanosleep \ + close \ + connect \ + fcntl \ + fdatasync \ + fsync \ + fork \ + kevent \ + msync \ + nanosleep \ + open \ + openat \ + poll \ + ppoll \ + pselect \ + ptrace \ + read \ + readv \ + recvfrom \ + recvmsg \ + select \ + sendmsg \ + sendto \ + setcontext \ + sigprocmask \ + sigsuspend \ + sigtimedwait \ + sigwait \ + sigwaitinfo \ + swapcontext \ + wait4 \ + wait6 \ + write \ + writev + +.if ${MACHINE_CPUARCH} == "sparc64" +SRCS+= sigaction.c +NOASM+= sigaction.o +.else +INTERPOSED+= sigaction +.endif + +NOASM+= ${INTERPOSED:S/$/.o/} +PSEUDO+= ${INTERPOSED:C/^.*$/_&.o/} + +# Add machine dependent asm sources: +SRCS+=${MDASM} + +# Look though the complete list of syscalls (MIASM) for names that are +# not defined with machine dependent implementations (MDASM) and are +# not declared for no generation of default code (NOASM). Add each +# syscall that satisfies these conditions to the ASM list. +.for _asm in ${MIASM} +.if (${MDASM:R:M${_asm:R}} == "") +.if (${NOASM:R:M${_asm:R}} == "") +ASM+=$(_asm) +.endif +.endif +.endfor + +SASM= ${ASM:S/.o/.S/} + +SPSEUDO= ${PSEUDO:S/.o/.S/} + +SRCS+= ${SASM} ${SPSEUDO} + +SYM_MAPS+= ${LIBSYS_SRCTOP}/sys/Symbol.map + +# Generated files +CLEANFILES+= ${SASM} ${SPSEUDO} + +.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \ + ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_ARCH:Marmv[67]*} +NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n' +.else +NOTE_GNU_STACK='' +.endif + +${SASM}: + printf '#include "compat.h"\n' > ${.TARGET} + printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' >> ${.TARGET} + printf ${NOTE_GNU_STACK} >>${.TARGET} + +${SPSEUDO}: + printf '#include "compat.h"\n' > ${.TARGET} + printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \ + >> ${.TARGET} + printf ${NOTE_GNU_STACK} >>${.TARGET} + Index: lib/libsys/sys/Symbol.map =================================================================== --- /dev/null +++ lib/libsys/sys/Symbol.map @@ -0,0 +1,1032 @@ +/* + * $FreeBSD$ + */ + +/* + * It'd be nice to automatically generate the syscall symbols, but we + * don't know to what version they will eventually belong to, so for now + * it has to be manual. + */ +FBSD_1.0 { + __acl_aclcheck_fd; + __acl_aclcheck_file; + __acl_aclcheck_link; + __acl_delete_fd; + __acl_delete_file; + __acl_delete_link; + __acl_get_fd; + __acl_get_file; + __acl_get_link; + __acl_set_fd; + __acl_set_file; + __acl_set_link; + __getcwd; + __mac_execve; + __mac_get_fd; + __mac_get_file; + __mac_get_link; + __mac_get_pid; + __mac_get_proc; + __mac_set_fd; + __mac_set_file; + __mac_set_link; + __mac_set_proc; + __setugid; + __syscall; + __sysctl; + _umtx_op; + abort2; + accept; + access; + acct; + adjtime; + aio_cancel; + aio_error; + aio_fsync; + aio_read; + aio_return; + aio_suspend; + aio_waitcomplete; + aio_write; + audit; + auditctl; + auditon; + bind; + chdir; + chflags; + chmod; + chown; + chroot; + clock_getres; + clock_gettime; + clock_settime; + close; + connect; + dup; + dup2; + eaccess; + execve; + extattr_delete_fd; + extattr_delete_file; + extattr_delete_link; + extattr_get_fd; + extattr_get_file; + extattr_get_link; + extattr_list_fd; + extattr_list_file; + extattr_list_link; + extattr_set_fd; + extattr_set_file; + extattr_set_link; + extattrctl; + fchdir; + fchflags; + fchmod; + fchown; + fcntl; + fhopen; + flock; + fork; + fpathconf; + fsync; + futimes; + getaudit; + getaudit_addr; + getauid; + getcontext; + getdtablesize; + getegid; + geteuid; + getfh; + getgid; + getgroups; + getitimer; + getpeername; + getpgid; + getpgrp; + getpid; + getppid; + getpriority; + getresgid; + getresuid; + getrlimit; + getrusage; + getsid; + getsockname; + getsockopt; + gettimeofday; + getuid; + ioctl; + issetugid; + jail; + jail_attach; + kenv; + kill; + kldfind; + kldfirstmod; + kldload; + kldnext; + kldstat; + kldsym; + kldunload; + kldunloadf; + kqueue; + kmq_notify; /* Do we want these to be public interfaces? */ + kmq_open; /* librt uses them to provide mq_xxx. */ + kmq_setattr; + kmq_timedreceive; + kmq_timedsend; + kmq_unlink; + ksem_close; + ksem_destroy; + ksem_getvalue; + ksem_init; + ksem_open; + ksem_post; + ksem_timedwait; + ksem_trywait; + ksem_unlink; + ksem_wait; + ktrace; + lchflags; + lchmod; + lchown; + lgetfh; + link; + lio_listio; + listen; + lutimes; + mac_syscall; + madvise; + mincore; + minherit; + mkdir; + mkfifo; + mlock; + mlockall; + modfind; + modfnext; + modnext; + modstat; + mount; + mprotect; + msgget; + msgrcv; + msgsnd; + msgsys; + msync; + munlock; + munlockall; + munmap; + nanosleep; + netbsd_lchown; + netbsd_msync; + nfssvc; + nmount; + ntp_adjtime; + ntp_gettime; + open; + pathconf; + pipe; + poll; + posix_openpt; + preadv; + profil; + pselect; + ptrace; + pwritev; + quotactl; + read; + readlink; + readv; + reboot; + recvfrom; + recvmsg; + rename; + revoke; + rfork; + rmdir; + rtprio; + rtprio_thread; + sched_get_priority_max; + sched_get_priority_min; + sched_getparam; + sched_getscheduler; + sched_rr_get_interval; + sched_setparam; + sched_setscheduler; + sched_yield; + select; + semget; + semop; + semsys; + sendfile; + sendmsg; + sendto; + setaudit; + setaudit_addr; + setauid; + setegid; + seteuid; + setgid; + setgroups; + setitimer; + setlogin; + setpgid; + setpriority; + setregid; + setresgid; + setresuid; + setreuid; + setrlimit; + setsid; + setsockopt; + settimeofday; + setuid; + shm_open; + shm_unlink; + shmat; + shmdt; + shmget; + shmsys; + shutdown; + sigaction; + sigaltstack; + sigpending; + sigprocmask; + sigqueue; + sigreturn; + sigsuspend; + sigtimedwait; + sigwait; + sigwaitinfo; + socket; + socketpair; + swapoff; + swapon; + symlink; + sync; + sysarch; + syscall; + thr_create; + thr_exit; + thr_kill; + thr_kill2; + thr_new; + thr_self; + thr_set_name; + thr_suspend; + thr_wake; + ktimer_create; /* Do we want these to be public interfaces? */ + ktimer_delete; /* librt uses them to provide timer_xxx. */ + ktimer_getoverrun; + ktimer_gettime; + ktimer_settime; + umask; + undelete; + unlink; + unmount; + utimes; + utrace; + uuidgen; + vadvise; + wait4; + write; + writev; + + __error; + ftruncate; + lseek; + mmap; + pread; + pwrite; + truncate; +}; + +FBSD_1.1 { + __semctl; + closefrom; + cpuset; + cpuset_getid; + cpuset_setid; + cpuset_getaffinity; + cpuset_setaffinity; + faccessat; + fchmodat; + fchownat; + fexecve; + futimesat; + jail_get; + jail_set; + jail_remove; + linkat; + lpathconf; + mkdirat; + mkfifoat; + msgctl; + readlinkat; + renameat; + setfib; + shmctl; + symlinkat; + unlinkat; +}; + +FBSD_1.2 { + cap_enter; + cap_getmode; + getloginclass; + pdfork; + pdgetpid; + pdkill; + posix_fallocate; + rctl_get_racct; + rctl_get_rules; + rctl_get_limits; + rctl_add_rule; + rctl_remove_rule; + setloginclass; +}; + +FBSD_1.3 { + accept4; + aio_mlock; + bindat; + cap_fcntls_get; + cap_fcntls_limit; + cap_ioctls_get; + cap_ioctls_limit; + __cap_rights_get; + cap_rights_limit; + cap_sandboxed; + chflagsat; + clock_getcpuclockid2; + connectat; + ffclock_getcounter; + ffclock_getestimate; + ffclock_setestimate; + pipe2; + posix_fadvise; + procctl; + wait6; +}; + +FBSD_1.4 { + futimens; + ppoll; + utimensat; + numa_setaffinity; + numa_getaffinity; + sendmmsg; + recvmmsg; +}; + +FBSD_1.5 { + clock_nanosleep; + fdatasync; + fhstat; + fhstatfs; + fstat; + fstatat; + fstatfs; + getdents; + getdirentries; + getfsstat; + getrandom; + kevent; + lstat; + mknod; + mknodat; + stat; + statfs; + cpuset_getdomain; + cpuset_setdomain; +}; + +FBSDprivate_1.0 { + ___acl_aclcheck_fd; + __sys___acl_aclcheck_fd; + ___acl_aclcheck_file; + __sys___acl_aclcheck_file; + ___acl_aclcheck_link; + __sys___acl_aclcheck_link; + ___acl_delete_fd; + __sys___acl_delete_fd; + ___acl_delete_file; + __sys___acl_delete_file; + ___acl_delete_link; + __sys___acl_delete_link; + ___acl_get_fd; + __sys___acl_get_fd; + ___acl_get_file; + __sys___acl_get_file; + ___acl_get_link; + __sys___acl_get_link; + ___acl_set_fd; + __sys___acl_set_fd; + ___acl_set_file; + __sys___acl_set_file; + ___acl_set_link; + __sys___acl_set_link; + ___getcwd; + __sys___getcwd; + ___mac_execve; + __sys___mac_execve; + ___mac_get_fd; + __sys___mac_get_fd; + ___mac_get_file; + __sys___mac_get_file; + ___mac_get_link; + __sys___mac_get_link; + ___mac_get_pid; + __sys___mac_get_pid; + ___mac_get_proc; + __sys___mac_get_proc; + ___mac_set_fd; + __sys___mac_set_fd; + ___mac_set_file; + __sys___mac_set_file; + ___mac_set_link; + __sys___mac_set_link; + ___mac_set_proc; + __sys___mac_set_proc; + ___semctl; + __sys___semctl; + ___setugid; + __sys___setugid; + ___syscall; + __sys___syscall; + ___sysctl; + __sys___sysctl; + __umtx_op; + __sys__umtx_op; + _abort2; + __sys_abort2; + _accept; + __sys_accept; + _accept4; + __sys_accept4; + _access; + __sys_access; + _acct; + __sys_acct; + _adjtime; + __sys_adjtime; + __sys_aio_cancel; + __sys_aio_error; + __sys_aio_fsync; + __sys_aio_read; + __sys_aio_return; + __sys_aio_suspend; + __sys_aio_waitcomplete; + __sys_aio_write; + _audit; + __sys_audit; + _auditctl; + __sys_auditctl; + _auditon; + __sys_auditon; + _bind; + __sys_bind; + _chdir; + __sys_chdir; + _chflags; + __sys_chflags; + _chmod; + __sys_chmod; + _chown; + __sys_chown; + _chroot; + __sys_chroot; + _clock_getcpuclockid2; + __sys_clock_getcpuclockid2; + _clock_getres; + __sys_clock_getres; + _clock_gettime; + __sys_clock_gettime; + __sys_clock_nanosleep; + _clock_settime; + __sys_clock_settime; + _close; + __sys_close; + _closefrom; + __sys_closefrom; + _connect; + __sys_connect; + _cpuset; + __sys_cpuset; + _cpuset_getid; + __sys_cpuset_getid; + _cpuset_setid; + __sys_cpuset_setid; + _cpuset_getaffinity; + __sys_cpuset_getaffinity; + _cpuset_setaffinity; + __sys_cpuset_setaffinity; + _dup; + __sys_dup; + _dup2; + __sys_dup2; + _eaccess; + __sys_eaccess; + _execve; + __sys_execve; + _extattr_delete_fd; + __sys_extattr_delete_fd; + _extattr_delete_file; + __sys_extattr_delete_file; + _extattr_delete_link; + __sys_extattr_delete_link; + _extattr_get_fd; + __sys_extattr_get_fd; + _extattr_get_file; + __sys_extattr_get_file; + _extattr_get_link; + __sys_extattr_get_link; + _extattr_list_fd; + __sys_extattr_list_fd; + _extattr_list_file; + __sys_extattr_list_file; + _extattr_list_link; + __sys_extattr_list_link; + _extattr_set_fd; + __sys_extattr_set_fd; + _extattr_set_file; + __sys_extattr_set_file; + _extattr_set_link; + __sys_extattr_set_link; + _extattrctl; + __sys_extattrctl; + _fchdir; + __sys_fchdir; + _fchflags; + __sys_fchflags; + _fchmod; + __sys_fchmod; + _fchown; + __sys_fchown; + _fcntl; + __sys_fcntl; + __fcntl_compat; + _fhopen; + __sys_fhopen; + _fhstat; + __sys_fhstat; + _fhstatfs; + __sys_fhstatfs; + _flock; + __sys_flock; + _fork; + __sys_fork; + _fpathconf; + __sys_fpathconf; + _fstat; + __sys_fstat; + _fstatfs; + __sys_fstatfs; + _fsync; + __sys_fsync; + _fdatasync; + __sys_fdatasync; + _futimes; + __sys_futimes; + _getaudit; + __sys_getaudit; + _getaudit_addr; + __sys_getaudit_addr; + _getauid; + __sys_getauid; + _getcontext; + __sys_getcontext; + _getdirentries; + __sys_getdirentries; + _getdtablesize; + __sys_getdtablesize; + _getegid; + __sys_getegid; + _geteuid; + __sys_geteuid; + _getfh; + __sys_getfh; + _getfsstat; + __sys_getfsstat; + _getgid; + __sys_getgid; + _getgroups; + __sys_getgroups; + _getitimer; + __sys_getitimer; + _getpeername; + __sys_getpeername; + _getpgid; + __sys_getpgid; + _getpgrp; + __sys_getpgrp; + _getpid; + __sys_getpid; + _getppid; + __sys_getppid; + _getpriority; + __sys_getpriority; + _getresgid; + __sys_getresgid; + _getresuid; + __sys_getresuid; + _getrlimit; + __sys_getrlimit; + _getrusage; + __sys_getrusage; + _getsid; + __sys_getsid; + _getsockname; + __sys_getsockname; + _getsockopt; + __sys_getsockopt; + _gettimeofday; + __sys_gettimeofday; + _getuid; + __sys_getuid; + _ioctl; + __sys_ioctl; + _issetugid; + __sys_issetugid; + _jail; + __sys_jail; + _jail_attach; + __sys_jail_attach; + _kenv; + __sys_kenv; + _kevent; + __sys_kevent; + _kill; + __sys_kill; + _kldfind; + __sys_kldfind; + _kldfirstmod; + __sys_kldfirstmod; + _kldload; + __sys_kldload; + _kldnext; + __sys_kldnext; + _kldstat; + __sys_kldstat; + _kldsym; + __sys_kldsym; + _kldunload; + __sys_kldunload; + _kldunloadf; + __sys_kldunloadf; + _kmq_notify; + __sys_kmq_notify; + _kmq_open; + __sys_kmq_open; + _kmq_setattr; + __sys_kmq_setattr; + _kmq_timedreceive; + __sys_kmq_timedreceive; + _kmq_timedsend; + __sys_kmq_timedsend; + _kmq_unlink; + __sys_kmq_unlink; + _kqueue; + __sys_kqueue; + _ksem_close; + __sys_ksem_close; + _ksem_destroy; + __sys_ksem_destroy; + _ksem_getvalue; + __sys_ksem_getvalue; + _ksem_init; + __sys_ksem_init; + _ksem_open; + __sys_ksem_open; + _ksem_post; + __sys_ksem_post; + _ksem_timedwait; + __sys_ksem_timedwait; + _ksem_trywait; + __sys_ksem_trywait; + _ksem_unlink; + __sys_ksem_unlink; + _ksem_wait; + __sys_ksem_wait; + _ktrace; + __sys_ktrace; + _lchflags; + __sys_lchflags; + _lchmod; + __sys_lchmod; + _lchown; + __sys_lchown; + _lgetfh; + __sys_lgetfh; + _link; + __sys_link; + __sys_lio_listio; + _listen; + __sys_listen; + _lutimes; + __sys_lutimes; + _mac_syscall; + __sys_mac_syscall; + _madvise; + __sys_madvise; + _mincore; + __sys_mincore; + _minherit; + __sys_minherit; + _mkdir; + __sys_mkdir; + _mkfifo; + __sys_mkfifo; + _mknod; + __sys_mknod; + _mlock; + __sys_mlock; + _mlockall; + __sys_mlockall; + _modfind; + __sys_modfind; + _modfnext; + __sys_modfnext; + _modnext; + __sys_modnext; + _modstat; + __sys_modstat; + _mount; + __sys_mount; + _mprotect; + __sys_mprotect; + _msgctl; + __sys_msgctl; + _msgget; + __sys_msgget; + _msgrcv; + __sys_msgrcv; + _msgsnd; + __sys_msgsnd; + _msgsys; + __sys_msgsys; + _msync; + __sys_msync; + _munlock; + __sys_munlock; + _munlockall; + __sys_munlockall; + _munmap; + __sys_munmap; + _nanosleep; + __sys_nanosleep; + _netbsd_lchown; + __sys_netbsd_lchown; + _netbsd_msync; + __sys_netbsd_msync; + _nfssvc; + __sys_nfssvc; + _nmount; + __sys_nmount; + _ntp_adjtime; + __sys_ntp_adjtime; + _ntp_gettime; + __sys_ntp_gettime; + _open; + __sys_open; + _openat; + __sys_openat; + _pathconf; + __sys_pathconf; + _pipe; + __sys_pipe; + _poll; + __sys_poll; + _ppoll; + __sys_ppoll; + _preadv; + __sys_preadv; + _procctl; + __sys_procctl; + _profil; + __sys_profil; + _pselect; + __sys_pselect; + _ptrace; + __sys_ptrace; + _pwritev; + __sys_pwritev; + _quotactl; + __sys_quotactl; + _read; + __sys_read; + _readlink; + __sys_readlink; + _readv; + __sys_readv; + _reboot; + __sys_reboot; + _recvfrom; + __sys_recvfrom; + _recvmsg; + __sys_recvmsg; + _rename; + __sys_rename; + _revoke; + __sys_revoke; + _rfork; + __sys_rfork; + _rmdir; + __sys_rmdir; + _rtprio; + __sys_rtprio; + _rtprio_thread; + __sys_rtprio_thread; + _sched_get_priority_max; + __sys_sched_get_priority_max; + _sched_get_priority_min; + __sys_sched_get_priority_min; + _sched_getparam; + __sys_sched_getparam; + _sched_getscheduler; + __sys_sched_getscheduler; + _sched_rr_get_interval; + __sys_sched_rr_get_interval; + _sched_setparam; + __sys_sched_setparam; + _sched_setscheduler; + __sys_sched_setscheduler; + _sched_yield; + __sys_sched_yield; + _select; + __sys_select; + _semget; + __sys_semget; + _semop; + __sys_semop; + _semsys; + __sys_semsys; + _sendfile; + __sys_sendfile; + _sendmsg; + __sys_sendmsg; + _sendto; + __sys_sendto; + _setaudit; + __sys_setaudit; + _setaudit_addr; + __sys_setaudit_addr; + _setauid; + __sys_setauid; + _setcontext; + __sys_setcontext; + _setegid; + __sys_setegid; + _seteuid; + __sys_seteuid; + _setgid; + __sys_setgid; + _setgroups; + __sys_setgroups; + _setitimer; + __sys_setitimer; + _setlogin; + __sys_setlogin; + _setpgid; + __sys_setpgid; + _setpriority; + __sys_setpriority; + _setregid; + __sys_setregid; + _setresgid; + __sys_setresgid; + _setresuid; + __sys_setresuid; + _setreuid; + __sys_setreuid; + _setrlimit; + __sys_setrlimit; + _setsid; + __sys_setsid; + _setsockopt; + __sys_setsockopt; + _settimeofday; + __sys_settimeofday; + _setuid; + __sys_setuid; + _shm_open; + __sys_shm_open; + _shm_unlink; + __sys_shm_unlink; + _shmat; + __sys_shmat; + _shmctl; + __sys_shmctl; + _shmdt; + __sys_shmdt; + _shmget; + __sys_shmget; + _shmsys; + __sys_shmsys; + _shutdown; + __sys_shutdown; + _sigaction; + __sys_sigaction; + _sigaltstack; + __sys_sigaltstack; + _sigpending; + __sys_sigpending; + _sigprocmask; + __sys_sigprocmask; + _sigqueue; + __sys_sigqueue; + _sigreturn; + __sys_sigreturn; + _sigsuspend; + __sys_sigsuspend; + _sigtimedwait; + __sys_sigtimedwait; + _sigwait; + __sigwait; + __sys_sigwait; + _sigwaitinfo; + __sys_sigwaitinfo; + _socket; + __sys_socket; + _socketpair; + __sys_socketpair; + _statfs; + __sys_statfs; + _swapcontext; + __sys_swapcontext; + _swapoff; + __sys_swapoff; + _swapon; + __sys_swapon; + _symlink; + __sys_symlink; + _sync; + __sys_sync; + _sysarch; + __sys_sysarch; + _syscall; + __sys_syscall; + _thr_create; + __sys_thr_create; + _thr_exit; + __sys_thr_exit; + _thr_kill; + __sys_thr_kill; + _thr_kill2; + __sys_thr_kill2; + _thr_new; + __sys_thr_new; + _thr_self; + __sys_thr_self; + _thr_set_name; + __sys_thr_set_name; + _thr_suspend; + __sys_thr_suspend; + _thr_wake; + __sys_thr_wake; + _ktimer_create; + __sys_ktimer_create; + _ktimer_delete; + __sys_ktimer_delete; + _ktimer_getoverrun; + __sys_ktimer_getoverrun; + _ktimer_gettime; + __sys_ktimer_gettime; + _ktimer_settime; + __sys_ktimer_settime; + _umask; + __sys_umask; + _undelete; + __sys_undelete; + _unlink; + __sys_unlink; + _unmount; + __sys_unmount; + _utimes; + __sys_utimes; + _utrace; + __sys_utrace; + _uuidgen; + __sys_uuidgen; + _vadvise; + __sys_vadvise; + _wait4; + __sys_wait4; + _wait6; + __sys_wait6; + _write; + __sys_write; + _writev; + __sys_writev; + __set_error_selector; + nlm_syscall; + gssd_syscall; + __libc_interposing_slot; + __libc_sigwait; + _cpuset_getdomain; + __sys_cpuset_getdomain; + _cpuset_setdomain; + __sys_cpuset_setdomain; +}; Index: share/mk/bsd.lib.mk =================================================================== --- share/mk/bsd.lib.mk +++ share/mk/bsd.lib.mk @@ -81,7 +81,7 @@ # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries # .pico used for PIC object files # .nossppico used for NOSSP PIC object files -.SUFFIXES: .out .o .bc .ll .po .pico .nossppico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln +.SUFFIXES: .out .o .bc .ll .po .pico .spico .nossppico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln .if !defined(PICFLAG) .if ${MACHINE_CPUARCH} == "sparc64" @@ -101,8 +101,12 @@ ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} +.c.spico: + ${CC} ${PICFLAG} -DSTATIC -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + .c.nossppico: - ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS:C/^-fstack-protector.*$//} ${CFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET} + ${CC} ${PICFLAG} -DSTATIC -DPIC ${SHARED_CFLAGS:C/^-fstack-protector.*$//} ${CFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} .cc.po .C.po .cpp.po .cxx.po: @@ -111,8 +115,11 @@ .cc.pico .C.pico .cpp.pico .cxx.pico: ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} +.cc.spico .C.spico .cpp.spico .cxx.spico: + ${CXX} ${PICFLAG} -DSTATIC -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} + .cc.nossppico .C.nossppico .cpp.nossppico .cxx.nossppico: - ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS:C/^-fstack-protector.*$//} ${CXXFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET} + ${CXX} ${PICFLAG} -DSTATIC -DPIC ${SHARED_CXXFLAGS:C/^-fstack-protector.*$//} ${CXXFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET} .f.po: ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} @@ -122,11 +129,15 @@ ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} ${CTFCONVERT_CMD} +.f.spico: + ${FC} ${PICFLAG} -DSTATIC -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + .f.nossppico: - ${FC} ${PICFLAG} -DPIC ${FFLAGS:C/^-fstack-protector.*$//} -o ${.TARGET} -c ${.IMPSRC} + ${FC} ${PICFLAG} -DSTATIC -DPIC ${FFLAGS:C/^-fstack-protector.*$//} -o ${.TARGET} -c ${.IMPSRC} ${CTFCONVERT_CMD} -.s.po .s.pico .s.nossppico: +.s.po .s.pico .s.spico .s.nossppico: ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} ${CTFCONVERT_CMD} @@ -140,8 +151,13 @@ ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} +.asm.spico: + ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DSTATIC -DPIC \ + ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + .asm.nossppico: - ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \ + ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DSTATIC -DPIC \ ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} @@ -155,8 +171,13 @@ -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} +.S.spico: + ${CC:N${CCACHE_BIN}} ${PICFLAG} -DSTATIC -DPIC ${CFLAGS} ${ACFLAGS} \ + -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + .S.nossppico: - ${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} \ + ${CC:N${CCACHE_BIN}} ${PICFLAG} -DSTATIC -DPIC ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} \ -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} @@ -235,12 +256,16 @@ CLEANFILES+= lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll .endif -.if defined(SHLIB_NAME) || \ - defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) +.if defined(SHLIB_NAME) SOBJS+= ${OBJS:.o=.pico} DEPENDOBJS+= ${SOBJS} CLEANFILES+= ${SOBJS} .endif +.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) +SPICOBJS+= ${OBJS:.o=.spico} +DEPENDOBJS+= ${SPICOBJS} +CLEANFILES+= ${SPICOBJS} +.endif .if defined(SHLIB_NAME) _LIBS+= ${SHLIB_NAME} @@ -302,10 +327,10 @@ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" _LIBS+= lib${LIB_PRIVATE}${LIB}_pic.a -lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS} +lib${LIB_PRIVATE}${LIB}_pic.a: ${SPICOBJS} @${ECHO} building special pic ${LIB} library @rm -f ${.TARGET} - ${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD} + ${AR} ${ARFLAGS} ${.TARGET} ${SPICOBJS} ${ARADD} ${RANLIB} ${RANLIBFLAGS} ${.TARGET} .endif @@ -461,12 +486,16 @@ OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.po+= ${_S} .endfor .endif -.if defined(SHLIB_NAME) || \ - defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) +.if defined(SHLIB_NAME) .for _S in ${SRCS:N*.[hly]} OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+= ${_S} .endfor .endif +.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) +.for _S in ${SRCS:N*.[hly]} +OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.spico+= ${_S} +.endfor +.endif .if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) .for _S in ${SRCS:N*.[hly]} OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.nossppico+= ${_S} Index: share/mk/bsd.libnames.mk =================================================================== --- share/mk/bsd.libnames.mk +++ share/mk/bsd.libnames.mk @@ -141,6 +141,7 @@ LIBSSP_NONSHARED?= ${LIBDESTDIR}${LIBDIR_BASE}/libssp_nonshared.a LIBSTDCPLUSPLUS?= ${LIBDESTDIR}${LIBDIR_BASE}/libstdc++.a LIBSTDTHREADS?= ${LIBDESTDIR}${LIBDIR_BASE}/libstdthreads.a +LIBSYS?= ${LIBDESTDIR}${LIBDIR_BASE}/libsys.a LIBSYSDECODE?= ${LIBDESTDIR}${LIBDIR_BASE}/libsysdecode.a LIBTACPLUS?= ${LIBDESTDIR}${LIBDIR_BASE}/libtacplus.a LIBTERMCAP?= ${LIBDESTDIR}${LIBDIR_BASE}/libtermcap.a Index: share/mk/local.dirdeps.mk =================================================================== --- share/mk/local.dirdeps.mk +++ share/mk/local.dirdeps.mk @@ -157,6 +157,7 @@ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ + lib/libsys \ lib/libcompiler_rt \ # libgcc is needed as well but is added later. Index: share/mk/src.libnames.mk =================================================================== --- share/mk/src.libnames.mk +++ share/mk/src.libnames.mk @@ -164,6 +164,7 @@ ssp_nonshared \ stdthreads \ supcplusplus \ + sys \ sysdecode \ tacplus \ termcap \ @@ -319,10 +320,11 @@ _DP_xo= util # The libc dependencies are not strictly needed but are defined to make the # assert happy. -_DP_c= compiler_rt +_DP_c= sys compiler_rt .if ${MK_SSP} != "no" _DP_c+= ssp_nonshared .endif +_DP_sys= compiler_rt _DP_stdthreads= pthread _DP_tacplus= md _DP_panel= ncurses