aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Steuck <greg@nest.cx>2023-04-25 13:24:12 +0100
committerGreg Steuck <blackgnezdo@gmail.com>2023-04-27 09:52:01 -0700
commit59e959932704c7a500e97fda11bbae7ccca50020 (patch)
tree6f039e16d3d73d0a3a0338978087e5921cd13da5
parent7f8ba655dedec95f92e7725acbbc86562df20a80 (diff)
sys/targets: switch openbsd to SyscallNumbers: false
This relies on sendsyslog in sys/syslog.h which will be in OpenBSD HEAD soon.
-rw-r--r--executor/common_bsd.h25
-rw-r--r--executor/executor_bsd.h4
-rw-r--r--pkg/csource/generated.go22
-rw-r--r--sys/targets/targets.go2
4 files changed, 49 insertions, 4 deletions
diff --git a/executor/common_bsd.h b/executor/common_bsd.h
index 2bfce1826..eac88fd3c 100644
--- a/executor/common_bsd.h
+++ b/executor/common_bsd.h
@@ -11,6 +11,24 @@
#include <string.h>
#include <sys/syscall.h>
+#if GOOS_openbsd
+// Needed syscall libc stubs.
+#include <dirent.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <sys/event.h>
+#include <sys/ioctl.h>
+#include <sys/ktrace.h>
+#include <sys/mman.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <sys/shm.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/syslog.h>
+#endif // GOOS_openbsd
+
#if GOOS_netbsd
#if SYZ_EXECUTOR || __NR_syz_usb_connect
@@ -91,9 +109,12 @@ static int fault_injected(int fd)
#endif
-#if GOOS_openbsd || GOOS_darwin
+#if GOOS_openbsd
+#define CAST
+#endif // GOOS_openbsd
+#if GOOS_darwin
#define __syscall syscall
-#endif // GOOS_openbsd || GOOS_darwin
+#endif // GOOS_darwin
#if GOOS_openbsd && (SYZ_EXECUTOR || __NR_syz_open_pts)
#include <termios.h>
diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h
index 1af99f4fc..d88922417 100644
--- a/executor/executor_bsd.h
+++ b/executor/executor_bsd.h
@@ -47,7 +47,11 @@ static intptr_t execute_syscall(const call_t* c, intptr_t a[kMaxArgs])
{
if (c->call)
return c->call(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
+#if GOOS_openbsd
+ failmsg("no call", "missing target for %s", c->name);
+#else
return __syscall(c->sys_nr, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
+#endif
}
static void cover_open(cover_t* cov, bool extra)
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 204d6d2ee..84565a4fe 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -490,6 +490,23 @@ void child()
#include <string.h>
#include <sys/syscall.h>
+#if GOOS_openbsd
+#include <dirent.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <sys/event.h>
+#include <sys/ioctl.h>
+#include <sys/ktrace.h>
+#include <sys/mman.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <sys/shm.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/syslog.h>
+#endif
+
#if GOOS_netbsd
#if SYZ_EXECUTOR || __NR_syz_usb_connect
@@ -1681,7 +1698,10 @@ static int fault_injected(int fd)
#endif
-#if GOOS_openbsd || GOOS_darwin
+#if GOOS_openbsd
+#define CAST
+#endif
+#if GOOS_darwin
#define __syscall syscall
#endif
diff --git a/sys/targets/targets.go b/sys/targets/targets.go
index 67c3161e4..b81b0ce70 100644
--- a/sys/targets/targets.go
+++ b/sys/targets/targets.go
@@ -540,7 +540,7 @@ var oses = map[string]osCommon{
KernelObject: "netbsd.gdb",
},
OpenBSD: {
- SyscallNumbers: true,
+ SyscallNumbers: false,
SyscallPrefix: "SYS_",
ExecutorUsesShmem: true,
ExecutorUsesForkServer: true,