xref: /linux/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl (revision 2a6b6c9a226279b4f6668450ddb21ae655558087)
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
12gcc=$1
13hostcc=$2
14incpath=$3
15input=$4
16
17if ! test -r $input; then
18	echo "Could not read input file" >&2
19	exit 1
20fi
21
22create_sc_table()
23{
24	local sc nr max_nr
25
26	while read sc nr; do
27		printf "%s\n" "	[$nr] = \"$sc\","
28		max_nr=$nr
29	done
30
31	echo "#define SYSCALLTBL_ARM64_MAX_ID $max_nr"
32}
33
34create_table()
35{
36	echo "#include \"$input\""
37	echo "static const char *const syscalltbl_arm64[] = {"
38	create_sc_table
39	echo "};"
40}
41
42$gcc -E -dM -x c -I $incpath/include/uapi $input \
43	|awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
44		sub("^#define __NR(3264)?_", "");
45		print | "sort -k2 -n"}' \
46	|create_table
47