checksyscalls.sh 5.6 KB

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