summaryrefslogtreecommitdiff
path: root/src/arch.c
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2014-02-09 07:51:04 -0500
committerPaul Moore <pmoore@redhat.com>2014-02-09 07:57:22 -0500
commit61fee77783fd458739eb6104f13d53bddfa389ac (patch)
treeef0e746763e57e742412d8e1c6266c89f9986084 /src/arch.c
parent206da04b8b2366d9efb963569bb89fe82ed2d1ba (diff)
downloadlibseccomp-61fee77783fd458739eb6104f13d53bddfa389ac.tar.gz
all: resolve issues caused by big endian systems
There are two major issues resolved in this patch: proper support for generating BPF on big endian systems, and ensuring we build the BPF correctly when the host system does not share the same endianess as the target platform. Relevant discussion in LKML regarding BPF on big endian systems: https://lkml.org/lkml/2012/4/8/87 Inspired by an earlier patch from Markos Chandras. Signed-off-by: Paul Moore <pmoore@redhat.com>
Diffstat (limited to 'src/arch.c')
-rw-r--r--src/arch.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/arch.c b/src/arch.c
index 47a539d..e71f3a1 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -158,6 +158,32 @@ int arch_arg_offset_hi(const struct arch_def *arch, unsigned int arg)
}
/**
+ * Determine the argument offset
+ * @param arch the architecture definition
+ * @param arg the argument number
+ *
+ * Determine the correct offset for the given argument based on the
+ * architecture definition. Returns the offset on success, negative values on
+ * failure.
+ *
+ */
+int arch_arg_offset(const struct arch_def *arch, unsigned int arg)
+{
+ switch (arch->token) {
+ case SCMP_ARCH_X86:
+ return x86_arg_offset(arg);
+ case SCMP_ARCH_X86_64:
+ return x86_64_arg_offset(arg);
+ case SCMP_ARCH_X32:
+ return x32_arg_offset(arg);
+ case SCMP_ARCH_ARM:
+ return arm_arg_offset(arg);
+ default:
+ return -EDOM;
+ }
+}
+
+/**
* Resolve a syscall name to a number
* @param arch the architecture definition
* @param name the syscall name