make_syscall_h.sh 614 B

123456789101112131415161718
  1. #!/bin/sh
  2. # syscall reporting example for seccomp
  3. #
  4. # Copyright (c) 2012 The Chromium OS Authors <chromium-os-dev@chromium.org>
  5. # Authors:
  6. # Kees Cook <keescook@chromium.org>
  7. #
  8. # Use of this source code is governed by a BSD-style license that can be
  9. # found in the LICENSE file.
  10. CC=$1
  11. [ -n "$TARGET_CC_NOCACHE" ] && CC=$TARGET_CC_NOCACHE
  12. echo "#include <asm/unistd.h>"
  13. echo "static const char *syscall_names[] = {"
  14. echo "#include <sys/syscall.h>" | ${CC} -E -dM - | grep '^#define __NR_' | \
  15. LC_ALL=C sed -r -n -e 's/^\#define[ \t]+__NR_([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_Linux]+)(.*)/ [\2] = "\1",/p'
  16. echo "};"