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