summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2021-11-01 10:06:57 -0600
committerTom Hromatka <tom.hromatka@oracle.com>2021-11-01 10:07:08 -0600
commit060a677ea5de077a7ae9f82b7142d388a1a336b6 (patch)
tree35b082b67217c62f7c80346daef4aadd9f0ff398 /src
parent68cc5bf3d85ddedbd9a43a44389c3593b517e6c5 (diff)
downloadlibseccomp-060a677ea5de077a7ae9f82b7142d388a1a336b6.tar.gz
arch: move the ARCH_DEF() calls into the arch/ABI specific files
This should make it easier to ensure we have arch/ABIs added properly to libseccomp. Signed-off-by: Paul Moore <paul@paul-moore.com> Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/arch-aarch64.c3
-rw-r--r--src/arch-arm.c3
-rw-r--r--src/arch-mips.c2
-rw-r--r--src/arch-mips64.c3
-rw-r--r--src/arch-mips64n32.c3
-rw-r--r--src/arch-parisc.c3
-rw-r--r--src/arch-parisc64.c3
-rw-r--r--src/arch-ppc.c2
-rw-r--r--src/arch-ppc64.c2
-rw-r--r--src/arch-riscv64.c3
-rw-r--r--src/arch-s390.c2
-rw-r--r--src/arch-s390x.c2
-rw-r--r--src/arch-sh.c2
-rw-r--r--src/arch-x32.c3
-rw-r--r--src/arch-x86.c2
-rw-r--r--src/arch-x86_64.c3
-rw-r--r--src/arch.h15
-rw-r--r--src/syscalls.c31
18 files changed, 56 insertions, 31 deletions
diff --git a/src/arch-aarch64.c b/src/arch-aarch64.c
index b2d76c6..9b12b43 100644
--- a/src/arch-aarch64.c
+++ b/src/arch-aarch64.c
@@ -25,6 +25,9 @@
#include "arch.h"
#include "arch-aarch64.h"
+#include "syscalls.h"
+
+ARCH_DEF(aarch64)
const struct arch_def arch_def_aarch64 = {
.token = SCMP_ARCH_AARCH64,
diff --git a/src/arch-arm.c b/src/arch-arm.c
index 732940e..c389815 100644
--- a/src/arch-arm.c
+++ b/src/arch-arm.c
@@ -25,6 +25,7 @@
#include "arch.h"
#include "arch-arm.h"
+#include "syscalls.h"
#define __SCMP_NR_OABI_SYSCALL_BASE 0x900000
#define __SCMP_ARM_NR_BASE 0x0f0000
@@ -78,6 +79,8 @@ const char *arm_syscall_resolve_num_munge(const struct arch_def *arch, int num)
return arch->syscall_resolve_num_raw(num);
}
+ARCH_DEF(arm)
+
const struct arch_def arch_def_arm = {
.token = SCMP_ARCH_ARM,
.token_bpf = AUDIT_ARCH_ARM,
diff --git a/src/arch-mips.c b/src/arch-mips.c
index 7cc425a..5a12a11 100644
--- a/src/arch-mips.c
+++ b/src/arch-mips.c
@@ -75,6 +75,8 @@ const char *mips_syscall_resolve_num_raw(int num)
return mips_syscall_resolve_num(num);
}
+ARCH_DEF(mips)
+
const struct arch_def arch_def_mips = {
.token = SCMP_ARCH_MIPS,
.token_bpf = AUDIT_ARCH_MIPS,
diff --git a/src/arch-mips64.c b/src/arch-mips64.c
index d0f72b8..ca7027b 100644
--- a/src/arch-mips64.c
+++ b/src/arch-mips64.c
@@ -24,6 +24,7 @@
#include "arch.h"
#include "arch-mips64.h"
+#include "syscalls.h"
/* 64 ABI */
#define __SCMP_NR_BASE 5000
@@ -70,6 +71,8 @@ const char *mips64_syscall_resolve_num_munge(const struct arch_def *arch,
return arch->syscall_resolve_num_raw(num);
}
+ARCH_DEF(mips64)
+
const struct arch_def arch_def_mips64 = {
.token = SCMP_ARCH_MIPS64,
.token_bpf = AUDIT_ARCH_MIPS64,
diff --git a/src/arch-mips64n32.c b/src/arch-mips64n32.c
index 532c8f3..c23cfc3 100644
--- a/src/arch-mips64n32.c
+++ b/src/arch-mips64n32.c
@@ -26,6 +26,7 @@
#include "arch.h"
#include "arch-mips64n32.h"
+#include "syscalls.h"
/* N32 ABI */
#define __SCMP_NR_BASE 6000
@@ -72,6 +73,8 @@ const char *mips64n32_syscall_resolve_num_munge(const struct arch_def *arch,
return mips64n32_syscall_resolve_num(num);
}
+ARCH_DEF(mips64n32)
+
const struct arch_def arch_def_mips64n32 = {
.token = SCMP_ARCH_MIPS64N32,
.token_bpf = AUDIT_ARCH_MIPS64N32,
diff --git a/src/arch-parisc.c b/src/arch-parisc.c
index 4440a04..9a200fe 100644
--- a/src/arch-parisc.c
+++ b/src/arch-parisc.c
@@ -9,6 +9,9 @@
#include "arch.h"
#include "arch-parisc.h"
+#include "syscalls.h"
+
+ARCH_DEF(parisc)
const struct arch_def arch_def_parisc = {
.token = SCMP_ARCH_PARISC,
diff --git a/src/arch-parisc64.c b/src/arch-parisc64.c
index d2d85e6..2446407 100644
--- a/src/arch-parisc64.c
+++ b/src/arch-parisc64.c
@@ -9,6 +9,9 @@
#include "arch.h"
#include "arch-parisc64.h"
+#include "syscalls.h"
+
+ARCH_DEF(parisc64)
const struct arch_def arch_def_parisc64 = {
.token = SCMP_ARCH_PARISC64,
diff --git a/src/arch-ppc.c b/src/arch-ppc.c
index 0c97bf5..8fdad6f 100644
--- a/src/arch-ppc.c
+++ b/src/arch-ppc.c
@@ -34,6 +34,8 @@
#define __ppc_NR_socketcall 102
#define __ppc_NR_ipc 117
+ARCH_DEF(ppc)
+
const struct arch_def arch_def_ppc = {
.token = SCMP_ARCH_PPC,
.token_bpf = AUDIT_ARCH_PPC,
diff --git a/src/arch-ppc64.c b/src/arch-ppc64.c
index 27f31a5..a2c88b3 100644
--- a/src/arch-ppc64.c
+++ b/src/arch-ppc64.c
@@ -34,6 +34,8 @@
#define __ppc64_NR_socketcall 102
#define __ppc64_NR_ipc 117
+ARCH_DEF(ppc64)
+
const struct arch_def arch_def_ppc64 = {
.token = SCMP_ARCH_PPC64,
.token_bpf = AUDIT_ARCH_PPC64,
diff --git a/src/arch-riscv64.c b/src/arch-riscv64.c
index df4f5c8..eb16b1e 100644
--- a/src/arch-riscv64.c
+++ b/src/arch-riscv64.c
@@ -18,6 +18,9 @@
#include "arch.h"
#include "arch-riscv64.h"
+#include "syscalls.h"
+
+ARCH_DEF(riscv64)
const struct arch_def arch_def_riscv64 = {
.token = SCMP_ARCH_RISCV64,
diff --git a/src/arch-s390.c b/src/arch-s390.c
index f2c8fda..cbcc769 100644
--- a/src/arch-s390.c
+++ b/src/arch-s390.c
@@ -17,6 +17,8 @@
#define __s390_NR_socketcall 102
#define __s390_NR_ipc 117
+ARCH_DEF(s390)
+
const struct arch_def arch_def_s390 = {
.token = SCMP_ARCH_S390,
.token_bpf = AUDIT_ARCH_S390,
diff --git a/src/arch-s390x.c b/src/arch-s390x.c
index ddae21b..0f0f619 100644
--- a/src/arch-s390x.c
+++ b/src/arch-s390x.c
@@ -17,6 +17,8 @@
#define __s390x_NR_socketcall 102
#define __s390x_NR_ipc 117
+ARCH_DEF(s390x)
+
const struct arch_def arch_def_s390x = {
.token = SCMP_ARCH_S390X,
.token_bpf = AUDIT_ARCH_S390X,
diff --git a/src/arch-sh.c b/src/arch-sh.c
index f40fcb8..4a52a41 100644
--- a/src/arch-sh.c
+++ b/src/arch-sh.c
@@ -26,6 +26,8 @@
#define __sh_NR_socketcall 102
#define __sh_NR_ipc 117
+ARCH_DEF(sh)
+
const struct arch_def arch_def_sheb = {
.token = SCMP_ARCH_SHEB,
.token_bpf = AUDIT_ARCH_SH,
diff --git a/src/arch-x32.c b/src/arch-x32.c
index 0a73923..cca6940 100644
--- a/src/arch-x32.c
+++ b/src/arch-x32.c
@@ -25,6 +25,7 @@
#include "arch.h"
#include "arch-x32.h"
+#include "syscalls.h"
/**
* Resolve a syscall name to a number
@@ -68,6 +69,8 @@ const char *x32_syscall_resolve_num_munge(const struct arch_def *arch,
return arch->syscall_resolve_num_raw(num);
}
+ARCH_DEF(x32)
+
const struct arch_def arch_def_x32 = {
.token = SCMP_ARCH_X32,
/* NOTE: this seems odd but the kernel treats x32 like x86_64 here */
diff --git a/src/arch-x86.c b/src/arch-x86.c
index af33137..f086ab0 100644
--- a/src/arch-x86.c
+++ b/src/arch-x86.c
@@ -33,6 +33,8 @@
#define __x86_NR_socketcall 102
#define __x86_NR_ipc 117
+ARCH_DEF(x86)
+
const struct arch_def arch_def_x86 = {
.token = SCMP_ARCH_X86,
.token_bpf = AUDIT_ARCH_I386,
diff --git a/src/arch-x86_64.c b/src/arch-x86_64.c
index 9c0e5ac..5825612 100644
--- a/src/arch-x86_64.c
+++ b/src/arch-x86_64.c
@@ -25,6 +25,9 @@
#include "arch.h"
#include "arch-x86_64.h"
+#include "syscalls.h"
+
+ARCH_DEF(x86_64)
const struct arch_def arch_def_x86_64 = {
.token = SCMP_ARCH_X86_64,
diff --git a/src/arch.h b/src/arch.h
index b6484f9..9816274 100644
--- a/src/arch.h
+++ b/src/arch.h
@@ -74,6 +74,21 @@ extern const struct arch_def *arch_def_native;
const char *NAME##_syscall_resolve_num(int num); \
const struct arch_syscall_def *NAME##_syscall_iterate(unsigned int spot);
+/* macro to define the arch specific structures and functions */
+#define ARCH_DEF(NAME) \
+ int NAME##_syscall_resolve_name(const char *name) \
+ { \
+ return syscall_resolve_name(name, OFFSET_ARCH(NAME)); \
+ } \
+ const char *NAME##_syscall_resolve_num(int num) \
+ { \
+ return syscall_resolve_num(num, OFFSET_ARCH(NAME)); \
+ } \
+ const struct arch_syscall_def *NAME##_syscall_iterate(unsigned int spot) \
+ { \
+ return syscall_iterate(spot, OFFSET_ARCH(NAME)); \
+ }
+
/* syscall name/num mapping */
struct arch_syscall_def {
const char *name;
diff --git a/src/syscalls.c b/src/syscalls.c
index faddff0..4e3d0e8 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -29,37 +29,6 @@
#include "arch.h"
#include "syscalls.h"
-#define ARCH_DEF(NAME) \
- int NAME##_syscall_resolve_name(const char *name) \
- { \
- return syscall_resolve_name(name, OFFSET_ARCH(NAME)); \
- } \
- const char *NAME##_syscall_resolve_num(int num) \
- { \
- return syscall_resolve_num(num, OFFSET_ARCH(NAME)); \
- } \
- const struct arch_syscall_def *NAME##_syscall_iterate(unsigned int spot) \
- { \
- return syscall_iterate(spot, OFFSET_ARCH(NAME)); \
- }
-
-ARCH_DEF(x86_64)
-ARCH_DEF(arm)
-ARCH_DEF(aarch64)
-ARCH_DEF(mips64n32)
-ARCH_DEF(mips64)
-ARCH_DEF(mips)
-ARCH_DEF(parisc)
-ARCH_DEF(parisc64)
-ARCH_DEF(ppc64)
-ARCH_DEF(ppc)
-ARCH_DEF(s390)
-ARCH_DEF(s390x)
-ARCH_DEF(sh)
-ARCH_DEF(x32)
-ARCH_DEF(x86)
-ARCH_DEF(riscv64)
-
/**
* Resolve a syscall name to a number
* @param arch the arch definition