mksyscalltbl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Generate system call table for perf. Derived from
  5. # powerpc script.
  6. #
  7. # Copyright IBM Corp. 2017
  8. # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
  9. # Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
  10. # Changed by: Kim Phillips <kim.phillips@arm.com>
  11. gcc=$1
  12. hostcc=$2
  13. incpath=$3
  14. input=$4
  15. if ! test -r $input; then
  16. echo "Could not read input file" >&2
  17. exit 1
  18. fi
  19. create_table_from_c()
  20. {
  21. local sc nr last_sc
  22. create_table_exe=`mktemp /tmp/create-table-XXXXXX`
  23. {
  24. cat <<-_EoHEADER
  25. #include <stdio.h>
  26. #include "$input"
  27. int main(int argc, char *argv[])
  28. {
  29. _EoHEADER
  30. while read sc nr; do
  31. printf "%s\n" " printf(\"\\t[%d] = \\\"$sc\\\",\\n\", __NR_$sc);"
  32. last_sc=$sc
  33. done
  34. printf "%s\n" " printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
  35. printf "}\n"
  36. } | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
  37. $create_table_exe
  38. rm -f $create_table_exe
  39. }
  40. create_table()
  41. {
  42. echo "static const char *syscalltbl_arm64[] = {"
  43. create_table_from_c
  44. echo "};"
  45. }
  46. $gcc -E -dM -x c $input \
  47. |sed -ne 's/^#define __NR_//p' \
  48. |sort -t' ' -k2 -nu \
  49. |create_table