1// Copyright 2020 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5//go:build openbsd && !mips64 6 7package syscall 8 9import ( 10 "internal/abi" 11) 12 13var dupTrampoline = abi.FuncPCABI0(libc_dup3_trampoline) 14 15func init() { 16 execveOpenBSD = execve 17} 18 19func syscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { 20 // OpenBSD 7.5+ no longer supports indirect syscalls. A number of Go 21 // packages make use of syscall.Syscall with SYS_IOCTL since it is 22 // not well supported by golang.org/x/sys/unix. Reroute this system 23 // call number to the respective libc stub so that it continues to 24 // work for the time being. See #63900 for further details. 25 if trap == SYS_IOCTL { 26 return syscallX(abi.FuncPCABI0(libc_ioctl_trampoline), a1, a2, a3) 27 } 28 return 0, 0, ENOSYS 29} 30 31func syscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { 32 // OpenBSD 7.5+ no longer supports indirect syscalls. A number of Go 33 // packages make use of syscall.Syscall with SYS___SYSCTL since it is 34 // not well supported by golang.org/x/sys/unix. Reroute this system 35 // call number to the respective libc stub so that it continues to 36 // work for the time being. See #63900 for further details. 37 if trap == SYS___SYSCTL { 38 return syscall6X(abi.FuncPCABI0(libc_sysctl_trampoline), a1, a2, a3, a4, a5, a6) 39 } 40 return 0, 0, ENOSYS 41} 42 43func rawSyscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { 44 return 0, 0, ENOSYS 45} 46 47func rawSyscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { 48 return 0, 0, ENOSYS 49} 50 51func syscall9Internal(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) { 52 return 0, 0, ENOSYS 53} 54 55// Implemented in the runtime package (runtime/sys_openbsd3.go) 56func syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 57func syscallX(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 58func syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 59func syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 60func syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno) 61func syscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno) 62func rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 63func rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 64func rawSyscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 65func rawSyscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno) 66 67func syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) { 68 return syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0) 69} 70func syscall9X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) { 71 return syscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0) 72} 73 74//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_read 75//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_lseek 76//sys getcwd(buf []byte) (n int, err error) 77//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) 78//sysnb fork() (pid int, err error) 79//sysnb execve(path *byte, argv **byte, envp **byte) (err error) 80//sysnb exit(res int) (err error) 81//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) 82//sysnb getentropy(p []byte) (err error) 83//sys fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 84//sys unlinkat(fd int, path string, flags int) (err error) 85//sys openat(fd int, path string, flags int, perm uint32) (fdret int, err error) 86