diff options
author | Peter Lundkvist <peter.lundkvist@gmail.com> | 2022-01-23 11:25:04 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2022-01-30 21:40:22 +0000 |
commit | cb0031c47b9d46f3cf84daa90d484af5f9c90e31 (patch) | |
tree | 26e013deccf389fd9d9269cc52ab914e4de0ad9f /make_syscall_h.sh | |
parent | ac2b8b365bdbcbf292f77409d180ec3c0963faf3 (diff) | |
download | procd-cb0031c47b9d46f3cf84daa90d484af5f9c90e31.tar.gz |
procd: seccomp/jail: Fix build error on arm with glibc
This fixes the make_syscall_h.sh script to recognize both
__NR_Linux, used by mips, and __NR_SYSCALL_BASE and
__ARM_NR_BASE used by arm.
Run-tested on arm (ipq806x) and mips (ath79), both with glibc.
Compile-tested and checked resulting syscall_names.h file wuth
glibc: aarch64, powerpc, x86_64, i486
musl: arm, mips
Fixes: FS#4194, FS#4195
Signed-off-by: Peter Lundkvist <peter.lundkvist@gmail.com>
Diffstat (limited to 'make_syscall_h.sh')
-rwxr-xr-x | make_syscall_h.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/make_syscall_h.sh b/make_syscall_h.sh index 18d9131..17e3bc4 100755 --- a/make_syscall_h.sh +++ b/make_syscall_h.sh @@ -13,11 +13,11 @@ CC=$1 echo "#include <asm/unistd.h>" echo "static const char *__syscall_names[] = {" -echo "#include <sys/syscall.h>" | ${CC} -E -dM - | grep '^#define __NR_' | \ - LC_ALL=C sed -r -n -e 's/^\#define[ \t]+__NR_([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_Linux]+)(.*)/ [\2] = "\1",/p' +echo "#include <sys/syscall.h>" | ${CC} -E -dM - | grep '^#define __NR_[a-z0-9_]\+[ \t].*[0-9].*$' | \ + LC_ALL=C sed -r -n -e 's/^\#define[ \t]+__NR_([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_LSYCABE]+)(.*)/ [\2] = "\1",/p' echo "};" -extra_syscalls="$(echo "#include <sys/syscall.h>" | ${CC} -E -dM - | sed -n -e '/^#define __ARM_NR_/ s///p')" +extra_syscalls="$(echo "#include <sys/syscall.h>" | ${CC} -E -dM - | sed -r -n -e 's/^#define __ARM_NR_([a-z0-9_]+)/\1/p')" cat <<EOF static inline const char *syscall_name(unsigned i) { @@ -26,7 +26,7 @@ static inline const char *syscall_name(unsigned i) { switch (i) { EOF echo "$extra_syscalls" | \ - LC_ALL=C sed -r -n -e 's/^([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_Linux]+)(.*)/ case \2: return "\1";/p' + LC_ALL=C sed -r -n -e 's/^([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_LAMBSE]+)(.*)/ case \2: return "\1";/p' cat <<EOF default: return (void*)0; } @@ -40,7 +40,7 @@ static inline int syscall_index(unsigned i) { switch (i) { EOF echo "$extra_syscalls" | \ - LC_ALL=C perl -ne 'print " case $2: return ARRAY_SIZE(__syscall_names) + ", $. - 1, ";\n" if /^([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_Linux]+)(.*)/;' + LC_ALL=C perl -ne 'print " case $2: return ARRAY_SIZE(__syscall_names) + ", $. - 1, ";\n" if /^([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_LAMBSE]+)(.*)/;' cat <<EOF default: return -1; } @@ -54,7 +54,7 @@ static inline int syscall_index_to_number(unsigned i) { switch (i) { EOF echo "$extra_syscalls" | \ - LC_ALL=C perl -ne 'print " case ARRAY_SIZE(__syscall_names) + ", $. - 1, ": return $2;\n" if /^([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_Linux]+)(.*)/;' + LC_ALL=C perl -ne 'print " case ARRAY_SIZE(__syscall_names) + ", $. - 1, ": return $2;\n" if /^([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_LAMBSE]+)(.*)/;' cat <<EOF default: return -1; } |