@@ -25,67 +25,16 @@ PATH_TO_X86_TEST_TABLE="$ROOT_DIR/src/syscall_table/test_x86_64.rs"
25
25
PATH_TO_AARCH64_TEST_TABLE=" $ROOT_DIR /src/syscall_table/test_aarch64.rs"
26
26
PATH_TO_RISCV64_TEST_TABLE=" $ROOT_DIR /src/syscall_table/test_riscv64.rs"
27
27
28
- generate_syscall_list_x86_64 () {
29
- # the table for x86_64 is nicely formatted here:
30
- # linux/arch/x86/entry/syscalls/syscall_64.tbl
31
- echo $( cat linux/arch/x86/entry/syscalls/syscall_64.tbl | grep -v " ^#" | \
32
- grep -v -e ' ^$' | awk ' {print $2,$3,$1}' | grep -v " ^x32" | \
33
- awk ' {print "(\""$2"\", "$3"),"}' | \
34
- sort -d)
28
+ install_header () {
29
+ make -C " $KERNEL_DIR /linux" ARCH=" $1 " INSTALL_HDR_PATH=" $1 -headers" headers_install & > /dev/null
30
+ echo $KERNEL_DIR /linux/$1 -headers/include/asm/unistd_64.h
35
31
}
36
32
37
- generate_syscall_list_aarch64 () {
38
- # filter for substituting `#define`s that point to other macros;
39
- # values taken from linux/include/uapi/asm-generic/unistd.h
40
- replace+=' s/__NR3264_fadvise64/223/;'
41
- replace+=' s/__NR3264_fcntl/25/;'
42
- replace+=' s/__NR3264_fstatat/79/;'
43
- replace+=' s/__NR3264_fstatfs/44/;'
44
- replace+=' s/__NR3264_fstat/80/;'
45
- replace+=' s/__NR3264_ftruncate/46/;'
46
- replace+=' s/__NR3264_lseek/62/;'
47
- replace+=' s/__NR3264_sendfile/71/;'
48
- replace+=' s/__NR3264_statfs/43/;'
49
- replace+=' s/__NR3264_truncate/45/;'
50
- replace+=' s/__NR3264_mmap/222/;'
51
-
52
- echo " $1 " > $path_to_rust_file
53
-
54
- # the aarch64 syscall table is not located in a .tbl file, like x86;
55
- # we run gcc's pre-processor to extract the numeric constants from header
56
- # files.
57
- echo $( gcc -Ilinux/include/uapi -E -dM -D__ARCH_WANT_RENAMEAT\
58
- -D__BITS_PER_LONG=64 linux/arch/arm64/include/uapi/asm/unistd.h | \
59
- grep " #define __NR_" | grep -v " __NR_syscalls" | \
60
- grep -v " __NR_arch_specific_syscall" | awk -F ' __NR_' ' {print $2}' | \
61
- sed $replace | awk ' { print "(\""$1"\", "$2")," }' | sort -d)
62
- }
63
-
64
- generate_syscall_list_riscv64 () {
65
- # filter for substituting `#define`s that point to other macros;
66
- # values taken from linux/include/uapi/asm-generic/unistd.h
67
- replace+=' s/__NR3264_fadvise64/223/;'
68
- replace+=' s/__NR3264_fcntl/25/;'
69
- replace+=' s/__NR3264_fstatat/79/;'
70
- replace+=' s/__NR3264_fstatfs/44/;'
71
- replace+=' s/__NR3264_fstat/80/;'
72
- replace+=' s/__NR3264_ftruncate/46/;'
73
- replace+=' s/__NR3264_lseek/62/;'
74
- replace+=' s/__NR3264_sendfile/71/;'
75
- replace+=' s/__NR3264_statfs/43/;'
76
- replace+=' s/__NR3264_truncate/45/;'
77
- replace+=' s/__NR3264_mmap/222/;'
78
-
79
- echo " $1 " > $path_to_rust_file
80
-
81
- # the riscv64 syscall table is not located in a .tbl file, like x86;
82
- # we run gcc's pre-processor to extract the numeric constants from header
83
- # files.
84
- echo $( gcc -Ilinux/include/uapi -E -dM \
85
- -D__BITS_PER_LONG=64 linux/arch/riscv/include/uapi/asm/unistd.h | \
86
- grep " #define __NR_" | grep -v " __NR_syscalls" | \
87
- grep -v " __NR_arch_specific_syscall" | awk -F ' __NR_' ' {print $2}' | \
88
- sed $replace | awk ' { print "(\""$1"\", "$2")," }' | sort -d)
33
+ generate_syscall_list () {
34
+ syscall_header=$( install_header $1 )
35
+ echo $( cat ${syscall_header} | grep " #define __NR_" | \
36
+ grep -v " __NR_syscalls" | grep -v " __NR_arch_specific_syscall" | \
37
+ awk -F ' __NR_' ' {print $2}' | awk ' { print "(\""$1"\", "$2")," }' | sort -d)
89
38
}
90
39
91
40
write_rust_syscall_table () {
@@ -94,11 +43,11 @@ write_rust_syscall_table() {
94
43
path_to_rust_file=$3
95
44
96
45
if [ " $platform " == " x86_64" ]; then
97
- syscall_list=$( generate_syscall_list_x86_64 )
46
+ syscall_list=$( generate_syscall_list x86_64 )
98
47
elif [ " $platform " == " aarch64" ]; then
99
- syscall_list=$( generate_syscall_list_aarch64 )
48
+ syscall_list=$( generate_syscall_list arm64 )
100
49
elif [ " $platform " == " riscv64" ]; then
101
- syscall_list=$( generate_syscall_list_riscv64 )
50
+ syscall_list=$( generate_syscall_list riscv )
102
51
else
103
52
die " Invalid platform"
104
53
fi
0 commit comments