Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Copyright (C) 1991-2019 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, see
  13. # <http://www.gnu.org/licenses/>.
  14. ifndef inhibit-unix-syscalls
  15. # Sysdep dirs unix/... can contain a file syscalls.list,
  16. # which specifies objects to be compiled as simple Unix system calls.
  17. -include $(common-objpfx)sysd-syscalls
  18. ifeq (misc,$(subdir))
  19. sysdep_routines += $(unix-extra-syscalls)
  20. ifdef unix-stub-syscalls
  21. # The system call entry points in this list are supposed to be additional
  22. # functions not overriding any other sysdeps/.../call.c implementation, but
  23. # their system call numbers are unavailable in the kernel headers we're
  24. # using. Instead of a system call stub, these get a function that fails
  25. # with ENOSYS. We just generate a single module defining one function and
  26. # making all these entry point names aliases for it.
  27. sysdep_routines += stub-syscalls
  28. $(objpfx)stub-syscalls.c: $(common-objpfx)sysd-syscalls \
  29. $(..)sysdeps/unix/Makefile
  30. $(make-target-directory)
  31. (for call in $(unix-stub-syscalls); do \
  32. call=$${call%%@*}; \
  33. echo "#define $$call RENAMED_$$call"; \
  34. done; \
  35. echo '#include <errno.h>'; \
  36. echo '#include <shlib-compat.h>'; \
  37. for call in $(unix-stub-syscalls); do \
  38. call=$${call%%@*}; \
  39. echo "#undef $$call"; \
  40. done; \
  41. echo 'long int _no_syscall (void)'; \
  42. echo '{ __set_errno (ENOSYS); return -1L; }'; \
  43. for call in $(unix-stub-syscalls); do \
  44. case $$call in \
  45. *@@*) \
  46. ver=$${call##*@}; call=$${call%%@*}; \
  47. ver=`echo "$$ver" | sed 's/\./_/g'`; \
  48. echo "strong_alias (_no_syscall, __$${call}_$${ver})"; \
  49. echo "versioned_symbol (libc, __$${call}_$${ver}, $$call, $$ver);"\
  50. ;; \
  51. *@*) \
  52. ver=$${call##*@}; call=$${call%%@*}; \
  53. ver=`echo "$$ver" | sed 's/\./_/g'`; \
  54. case $$ver in \
  55. *:*) \
  56. compat_ver=$${ver#*:}; \
  57. ver=$${ver%%:*}; \
  58. compat_cond="SHLIB_COMPAT (libc, $$ver, $$compat_ver)"; \
  59. ;; \
  60. *) \
  61. compat_cond=""; \
  62. ;; \
  63. esac; \
  64. if [ -n "$$compat_cond" ]; then echo "#if $$compat_cond"; fi; \
  65. echo "strong_alias (_no_syscall, __$${call}_$${ver})"; \
  66. echo "compat_symbol (libc, __$${call}_$${ver}, $$call, $$ver);"; \
  67. if [ -n "$$compat_cond" ]; then echo "#endif"; fi; \
  68. ;; \
  69. *) echo "weak_alias (_no_syscall, $$call)"; \
  70. echo "stub_warning ($$call)"; \
  71. echo "weak_alias (_no_syscall, __GI_$$call)" ;; \
  72. esac; \
  73. done) > $@T
  74. mv -f $@T $@
  75. generated += stub-syscalls.c
  76. endif
  77. endif
  78. # This is the end of the pipeline for compiling the syscall stubs.
  79. # The stdin is assembler with cpp using sysdep.h macros.
  80. compile-syscall = $(COMPILE.S) -o $@ -x assembler-with-cpp - \
  81. $(compile-mkdep-flags)
  82. ifndef avoid-generated
  83. $(common-objpfx)sysd-syscalls: $(..)sysdeps/unix/make-syscalls.sh \
  84. $(wildcard $(+sysdep_dirs:%=%/syscalls.list)) \
  85. $(common-objpfx)libc-modules.stmp
  86. for dir in $(+sysdep_dirs); do \
  87. test -f $$dir/syscalls.list && \
  88. { sysdirs='$(sysdirs)' \
  89. asm_CPP='$(COMPILE.S) -E -x assembler-with-cpp' \
  90. $(SHELL) $(dir $<)$(notdir $<) $$dir || exit 1; }; \
  91. test $$dir = $(..)sysdeps/unix && break; \
  92. done > $@T
  93. mv -f $@T $@
  94. endif
  95. $(common-objpfx)s-%.d: $(..)sysdeps/unix/s-%.S \
  96. $(wildcard $(+sysdep_dirs:%=%/syscalls.list))
  97. $(+make-deps)
  98. postclean-generated += sysd-syscalls
  99. endif