checksyscalls.sh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Check if current architecture are missing any function calls compared
  5. # to i386.
  6. # i386 define a number of legacy system calls that are i386 specific
  7. # and listed below so they are ignored.
  8. #
  9. # Usage:
  10. # checksyscalls.sh gcc gcc-options
  11. #
  12. ignore_list() {
  13. cat << EOF
  14. #include <asm/types.h>
  15. #include <asm/unistd.h>
  16. /* *at */
  17. #define __IGNORE_open /* openat */
  18. #define __IGNORE_link /* linkat */
  19. #define __IGNORE_unlink /* unlinkat */
  20. #define __IGNORE_mknod /* mknodat */
  21. #define __IGNORE_chmod /* fchmodat */
  22. #define __IGNORE_chown /* fchownat */
  23. #define __IGNORE_mkdir /* mkdirat */
  24. #define __IGNORE_rmdir /* unlinkat */
  25. #define __IGNORE_lchown /* fchownat */
  26. #define __IGNORE_access /* faccessat */
  27. #define __IGNORE_rename /* renameat2 */
  28. #define __IGNORE_readlink /* readlinkat */
  29. #define __IGNORE_symlink /* symlinkat */
  30. #define __IGNORE_utimes /* futimesat */
  31. #define __IGNORE_stat /* fstatat */
  32. #define __IGNORE_lstat /* fstatat */
  33. #define __IGNORE_stat64 /* fstatat64 */
  34. #define __IGNORE_lstat64 /* fstatat64 */
  35. #ifndef __ARCH_WANT_SET_GET_RLIMIT
  36. #define __IGNORE_getrlimit /* getrlimit */
  37. #define __IGNORE_setrlimit /* setrlimit */
  38. #endif
  39. /* Missing flags argument */
  40. #define __IGNORE_renameat /* renameat2 */
  41. /* CLOEXEC flag */
  42. #define __IGNORE_pipe /* pipe2 */
  43. #define __IGNORE_dup2 /* dup3 */
  44. #define __IGNORE_epoll_create /* epoll_create1 */
  45. #define __IGNORE_inotify_init /* inotify_init1 */
  46. #define __IGNORE_eventfd /* eventfd2 */
  47. #define __IGNORE_signalfd /* signalfd4 */
  48. /* MMU */
  49. #ifndef CONFIG_MMU
  50. #define __IGNORE_madvise
  51. #define __IGNORE_mbind
  52. #define __IGNORE_mincore
  53. #define __IGNORE_mlock
  54. #define __IGNORE_mlockall
  55. #define __IGNORE_munlock
  56. #define __IGNORE_munlockall
  57. #define __IGNORE_mprotect
  58. #define __IGNORE_msync
  59. #define __IGNORE_migrate_pages
  60. #define __IGNORE_move_pages
  61. #define __IGNORE_remap_file_pages
  62. #define __IGNORE_get_mempolicy
  63. #define __IGNORE_set_mempolicy
  64. #define __IGNORE_swapoff
  65. #define __IGNORE_swapon
  66. #endif
  67. /* System calls for 32-bit kernels only */
  68. #if BITS_PER_LONG == 64
  69. #define __IGNORE_sendfile64
  70. #define __IGNORE_ftruncate64
  71. #define __IGNORE_truncate64
  72. #define __IGNORE_stat64
  73. #define __IGNORE_lstat64
  74. #define __IGNORE_fstat64
  75. #define __IGNORE_fcntl64
  76. #define __IGNORE_fadvise64_64
  77. #define __IGNORE_fstatat64
  78. #define __IGNORE_fstatfs64
  79. #define __IGNORE_statfs64
  80. #define __IGNORE_llseek
  81. #define __IGNORE_mmap2
  82. #define __IGNORE_clock_gettime64
  83. #define __IGNORE_clock_settime64
  84. #define __IGNORE_clock_adjtime64
  85. #define __IGNORE_clock_getres_time64
  86. #define __IGNORE_clock_nanosleep_time64
  87. #define __IGNORE_timer_gettime64
  88. #define __IGNORE_timer_settime64
  89. #define __IGNORE_timerfd_gettime64
  90. #define __IGNORE_timerfd_settime64
  91. #define __IGNORE_utimensat_time64
  92. #define __IGNORE_pselect6_time64
  93. #define __IGNORE_ppoll_time64
  94. #define __IGNORE_io_pgetevents_time64
  95. #define __IGNORE_recvmmsg_time64
  96. #define __IGNORE_mq_timedsend_time64
  97. #define __IGNORE_mq_timedreceive_time64
  98. #define __IGNORE_semtimedop_time64
  99. #define __IGNORE_rt_sigtimedwait_time64
  100. #define __IGNORE_futex_time64
  101. #define __IGNORE_sched_rr_get_interval_time64
  102. #else
  103. #define __IGNORE_sendfile
  104. #define __IGNORE_ftruncate
  105. #define __IGNORE_truncate
  106. #define __IGNORE_stat
  107. #define __IGNORE_lstat
  108. #define __IGNORE_fstat
  109. #define __IGNORE_fcntl
  110. #define __IGNORE_fadvise64
  111. #define __IGNORE_newfstatat
  112. #define __IGNORE_fstatfs
  113. #define __IGNORE_statfs
  114. #define __IGNORE_lseek
  115. #define __IGNORE_mmap
  116. #define __IGNORE_clock_gettime
  117. #define __IGNORE_clock_settime
  118. #define __IGNORE_clock_adjtime
  119. #define __IGNORE_clock_getres
  120. #define __IGNORE_clock_nanosleep
  121. #define __IGNORE_timer_gettime
  122. #define __IGNORE_timer_settime
  123. #define __IGNORE_timerfd_gettime
  124. #define __IGNORE_timerfd_settime
  125. #define __IGNORE_utimensat
  126. #define __IGNORE_pselect6
  127. #define __IGNORE_ppoll
  128. #define __IGNORE_io_pgetevents
  129. #define __IGNORE_recvmmsg
  130. #define __IGNORE_mq_timedsend
  131. #define __IGNORE_mq_timedreceive
  132. #define __IGNORE_semtimedop
  133. #define __IGNORE_rt_sigtimedwait
  134. #define __IGNORE_futex
  135. #define __IGNORE_sched_rr_get_interval
  136. #define __IGNORE_gettimeofday
  137. #define __IGNORE_settimeofday
  138. #define __IGNORE_wait4
  139. #define __IGNORE_adjtimex
  140. #define __IGNORE_nanosleep
  141. #define __IGNORE_io_getevents
  142. #define __IGNORE_recvmmsg
  143. #endif
  144. /* i386-specific or historical system calls */
  145. #define __IGNORE_break
  146. #define __IGNORE_stty
  147. #define __IGNORE_gtty
  148. #define __IGNORE_ftime
  149. #define __IGNORE_prof
  150. #define __IGNORE_lock
  151. #define __IGNORE_mpx
  152. #define __IGNORE_ulimit
  153. #define __IGNORE_profil
  154. #define __IGNORE_ioperm
  155. #define __IGNORE_iopl
  156. #define __IGNORE_idle
  157. #define __IGNORE_modify_ldt
  158. #define __IGNORE_ugetrlimit
  159. #define __IGNORE_vm86
  160. #define __IGNORE_vm86old
  161. #define __IGNORE_set_thread_area
  162. #define __IGNORE_get_thread_area
  163. #define __IGNORE_madvise1
  164. #define __IGNORE_oldstat
  165. #define __IGNORE_oldfstat
  166. #define __IGNORE_oldlstat
  167. #define __IGNORE_oldolduname
  168. #define __IGNORE_olduname
  169. #define __IGNORE_umount
  170. #define __IGNORE_waitpid
  171. #define __IGNORE_stime
  172. #define __IGNORE_nice
  173. #define __IGNORE_signal
  174. #define __IGNORE_sigaction
  175. #define __IGNORE_sgetmask
  176. #define __IGNORE_sigsuspend
  177. #define __IGNORE_sigpending
  178. #define __IGNORE_ssetmask
  179. #define __IGNORE_readdir
  180. #define __IGNORE_socketcall
  181. #define __IGNORE_ipc
  182. #define __IGNORE_sigreturn
  183. #define __IGNORE_sigprocmask
  184. #define __IGNORE_bdflush
  185. #define __IGNORE__llseek
  186. #define __IGNORE__newselect
  187. #define __IGNORE_create_module
  188. #define __IGNORE_query_module
  189. #define __IGNORE_get_kernel_syms
  190. #define __IGNORE_sysfs
  191. #define __IGNORE_uselib
  192. #define __IGNORE__sysctl
  193. #define __IGNORE_arch_prctl
  194. #define __IGNORE_nfsservctl
  195. /* ... including the "new" 32-bit uid syscalls */
  196. #define __IGNORE_lchown32
  197. #define __IGNORE_getuid32
  198. #define __IGNORE_getgid32
  199. #define __IGNORE_geteuid32
  200. #define __IGNORE_getegid32
  201. #define __IGNORE_setreuid32
  202. #define __IGNORE_setregid32
  203. #define __IGNORE_getgroups32
  204. #define __IGNORE_setgroups32
  205. #define __IGNORE_fchown32
  206. #define __IGNORE_setresuid32
  207. #define __IGNORE_getresuid32
  208. #define __IGNORE_setresgid32
  209. #define __IGNORE_getresgid32
  210. #define __IGNORE_chown32
  211. #define __IGNORE_setuid32
  212. #define __IGNORE_setgid32
  213. #define __IGNORE_setfsuid32
  214. #define __IGNORE_setfsgid32
  215. /* these can be expressed using other calls */
  216. #define __IGNORE_alarm /* setitimer */
  217. #define __IGNORE_creat /* open */
  218. #define __IGNORE_fork /* clone */
  219. #define __IGNORE_futimesat /* utimensat */
  220. #define __IGNORE_getpgrp /* getpgid */
  221. #define __IGNORE_getdents /* getdents64 */
  222. #define __IGNORE_pause /* sigsuspend */
  223. #define __IGNORE_poll /* ppoll */
  224. #define __IGNORE_select /* pselect6 */
  225. #define __IGNORE_epoll_wait /* epoll_pwait */
  226. #define __IGNORE_time /* gettimeofday */
  227. #define __IGNORE_uname /* newuname */
  228. #define __IGNORE_ustat /* statfs */
  229. #define __IGNORE_utime /* utimes */
  230. #define __IGNORE_vfork /* clone */
  231. /* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */
  232. #ifdef __NR_sync_file_range2
  233. #define __IGNORE_sync_file_range
  234. #endif
  235. /* Unmerged syscalls for AFS, STREAMS, etc. */
  236. #define __IGNORE_afs_syscall
  237. #define __IGNORE_getpmsg
  238. #define __IGNORE_putpmsg
  239. #define __IGNORE_vserver
  240. EOF
  241. }
  242. syscall_list() {
  243. grep '^[0-9]' "$1" | sort -n |
  244. while read nr abi name entry ; do
  245. echo "#if !defined(__NR_${name}) && !defined(__IGNORE_${name})"
  246. echo "#warning syscall ${name} not implemented"
  247. echo "#endif"
  248. done
  249. }
  250. (ignore_list && syscall_list $(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl) | \
  251. $* -E -x c - > /dev/null