xref: /freebsd/lib/libsys/Makefile.sys (revision 783d3ff6d7fae619db8a7990b8a6387de0c677b5)
1# Implement symbols common to libc and libsys.
2#
3# When dynamically linked, the libc symbols are filtered by the actual
4# implementations in libsys.  When statically linked, both libc and
5# libsys contain full implementations to preserve the API of libc.a.
6#
7# The following variable are programmer-defined:
8#
9# MDASM		Override the default syscall implementation in MIASM
10#		(from syscall.mk below).  Each entry is a source file
11#		name (e.g., vfork.S).
12#		Generally defined in <arch>/Makefile.sys.
13# NOASM		Don't generate system call stubs.  Each entry is an
14#		object file name (e.g., yeild.o).  Don't add more of these.
15# PSEUDO	Generate _<sys> and __sys_<sys> symbols, but not <sys>.
16#		Each entry is a bare syscall name (e.g., "clock_gettime").
17# INTERPOSED	Like PSEUDO, but <sys>.c is added to SRCS.
18#		Used for syscalls intercepted by the threading library.
19#
20.PATH: ${LIBSYS_SRCTOP}/${LIBC_ARCH} ${LIBSYS_SRCTOP}
21
22# Include the generated makefile containing the *complete* list
23# of syscall names in MIASM.
24.include "${SRCTOP}/sys/sys/syscall.mk"
25
26# Include machine dependent definitions.
27.include "${LIBSYS_SRCTOP}/${LIBC_ARCH}/Makefile.sys"
28.if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64"
29.include "${LIBSYS_SRCTOP}/x86/Makefile.sys"
30.endif
31
32SRCS+= clock_gettime.c gettimeofday.c __vdso_gettimeofday.c
33
34# Sources common to both syscall interfaces:
35SRCS+=	\
36	__error.c \
37	__getosreldate.c \
38	getpagesize.c \
39	getpagesizes.c \
40	interposing_table.c \
41	libsys_sigwait.c
42
43.if ${LIB} == "c"
44# Trapping stubs in dynamic libc to be filtered by libsys.
45SOBJS+=	libc_stubs.pico
46
47# Link the full implementation of ELF auxargs for static libc.
48STATICOBJS+=	auxv.o
49.endif
50
51NOASM=	yield.o
52
53PSEUDO= \
54	clock_gettime \
55	exit \
56	getlogin \
57	gettimeofday \
58	sched_getcpu
59
60INTERPOSED = \
61	accept \
62	accept4 \
63	aio_suspend \
64	clock_nanosleep \
65	close \
66	connect \
67	fcntl \
68	fdatasync \
69	fsync \
70	fork \
71	kevent \
72	msync \
73	nanosleep \
74	open \
75	openat \
76	pdfork \
77	poll \
78	ppoll \
79	pselect \
80	ptrace \
81	read \
82	readv \
83	recvfrom \
84	recvmsg \
85	select \
86	sendmsg \
87	sendto \
88	setcontext \
89	sigaction \
90	sigprocmask \
91	sigsuspend \
92	sigtimedwait \
93	sigwait \
94	sigwaitinfo \
95	swapcontext \
96	wait4 \
97	wait6 \
98	write \
99	writev
100
101PSEUDO+=	${INTERPOSED}
102
103# Add machine dependent asm sources:
104SRCS+=${MDASM}
105
106# Look though the complete list of syscalls (MIASM) for names that are
107# not defined with machine dependent implementations (MDASM), not declared
108# without a trival <sys> symbol (PSEUDO).  Add each syscall that satisfies
109# these conditions to the ASM list.
110.for _asm in ${MIASM}
111.if !${MDASM:R:M${_asm:R}} && !${NOASM:R:M${_asm:R}} && !${PSEUDO:M${_asm:R}}
112ASM+=$(_asm)
113.endif
114.endfor
115
116SASM=	${ASM:S/.o/.S/}
117
118SPSEUDO= ${PSEUDO:C/^.*$/_&.S/}
119
120SRCS+=	${SASM} ${SPSEUDO}
121
122SYM_MAPS+=	${LIBSYS_SRCTOP}/syscalls.map
123SYM_MAPS+=	${LIBSYS_SRCTOP}/Symbol.sys.map
124.if exists(${LIBSYS_SRCTOP}/${LIBC_ARCH}/Symbol.sys.map)
125SYM_MAPS+=	${LIBSYS_SRCTOP}/${LIBC_ARCH}/Symbol.sys.map
126.endif
127
128# Generated files
129CLEANFILES+=	${SASM} ${SPSEUDO}
130
131.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \
132    ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm"
133NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n'
134.else
135NOTE_GNU_STACK=''
136.endif
137.if ${MACHINE_CPUARCH} == "aarch64"
138FEATURE_NOTE='\#include <sys/elf_common.h>\nGNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)\n'
139.else
140FEATURE_NOTE=''
141.endif
142
143${SASM}:
144	printf '/* %sgenerated by libc/sys/Makefile.inc */\n' @ > ${.TARGET}
145	printf '#include "compat.h"\n' >> ${.TARGET}
146	printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' >> ${.TARGET}
147	printf  ${NOTE_GNU_STACK} >>${.TARGET}
148	printf  ${FEATURE_NOTE} >> ${.TARGET}
149
150${SPSEUDO}:
151	printf '/* %sgenerated by libc/sys/Makefile.inc */\n' @ > ${.TARGET}
152	printf '#include "compat.h"\n' >> ${.TARGET}
153	printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \
154	    >> ${.TARGET}
155	printf ${NOTE_GNU_STACK} >>${.TARGET}
156	printf ${FEATURE_NOTE} >> ${.TARGET}
157
158.if ${LIB} == "sys"
159MAN+=	abort2.2 \
160	accept.2 \
161	access.2 \
162	acct.2 \
163	adjtime.2 \
164	aio_cancel.2 \
165	aio_error.2 \
166	aio_fsync.2 \
167	aio_mlock.2 \
168	aio_read.2 \
169	aio_return.2 \
170	aio_suspend.2 \
171	aio_waitcomplete.2 \
172	aio_write.2 \
173	auxv.3 \
174	bind.2 \
175	bindat.2 \
176	brk.2 \
177	cap_enter.2 \
178	cap_fcntls_limit.2 \
179	cap_ioctls_limit.2 \
180	cap_rights_limit.2 \
181	chdir.2 \
182	chflags.2 \
183	chmod.2 \
184	chown.2 \
185	chroot.2 \
186	clock_gettime.2 \
187	close.2 \
188	closefrom.2 \
189	connect.2 \
190	connectat.2 \
191	copy_file_range.2 \
192	cpuset.2 \
193	cpuset_getaffinity.2 \
194	cpuset_getdomain.2 \
195	creat.2 \
196	dup.2 \
197	eventfd.2 \
198	execve.2 \
199	_exit.2 \
200	extattr_get_file.2 \
201	fcntl.2 \
202	ffclock.2 \
203	fhlink.2 \
204	fhopen.2 \
205	fhreadlink.2 \
206	flock.2 \
207	fork.2 \
208	fspacectl.2 \
209	fsync.2 \
210	getdirentries.2 \
211	getdtablesize.2 \
212	getfh.2 \
213	getfsstat.2 \
214	getgid.2 \
215	getgroups.2 \
216	getitimer.2 \
217	getlogin.2 \
218	getloginclass.2 \
219	getpeername.2 \
220	getpgrp.2 \
221	getpid.2 \
222	getpriority.2 \
223	getrandom.2 \
224	getrlimit.2 \
225	getrusage.2 \
226	getsid.2 \
227	getsockname.2 \
228	getsockopt.2 \
229	gettimeofday.2 \
230	getuid.2 \
231	intro.2 \
232	ioctl.2 \
233	issetugid.2 \
234	jail.2 \
235	kcmp.2 \
236	kenv.2 \
237	kill.2 \
238	kldfind.2 \
239	kldfirstmod.2 \
240	kldload.2 \
241	kldnext.2 \
242	kldstat.2 \
243	kldsym.2 \
244	kldunload.2 \
245	kqueue.2 \
246	ktrace.2 \
247	link.2 \
248	lio_listio.2 \
249	listen.2 \
250	lseek.2 \
251	madvise.2 \
252	mincore.2 \
253	minherit.2 \
254	mkdir.2 \
255	mkfifo.2 \
256	mknod.2 \
257	mlock.2 \
258	mlockall.2 \
259	mmap.2 \
260	modfind.2 \
261	modnext.2 \
262	modstat.2 \
263	mount.2 \
264	mprotect.2 \
265	mq_close.2 \
266	mq_getattr.2 \
267	mq_notify.2 \
268	mq_open.2 \
269	mq_receive.2 \
270	mq_send.2 \
271	mq_setattr.2 \
272	mq_unlink.2 \
273	msgctl.2 \
274	msgget.2 \
275	msgrcv.2 \
276	msgsnd.2 \
277	msync.2 \
278	munmap.2 \
279	nanosleep.2 \
280	nfssvc.2 \
281	ntp_adjtime.2 \
282	open.2 \
283	pathconf.2 \
284	pdfork.2 \
285	pipe.2 \
286	poll.2 \
287	posix_fadvise.2 \
288	posix_fallocate.2 \
289	posix_openpt.2 \
290	procctl.2 \
291	profil.2 \
292	pselect.2 \
293	ptrace.2 \
294	quotactl.2 \
295	rctl_add_rule.2 \
296	read.2 \
297	readlink.2 \
298	reboot.2 \
299	recv.2 \
300	rename.2 \
301	revoke.2 \
302	rfork.2 \
303	rmdir.2 \
304	rtprio.2 \
305	sched_get_priority_max.2 \
306	sched_setparam.2 \
307	sched_setscheduler.2 \
308	sched_yield.2 \
309	sctp_generic_recvmsg.2 \
310	sctp_generic_sendmsg.2 \
311	sctp_peeloff.2 \
312	select.2 \
313	semctl.2 \
314	semget.2 \
315	semop.2 \
316	send.2 \
317	setfib.2 \
318	sendfile.2 \
319	setgroups.2 \
320	setpgid.2 \
321	setregid.2 \
322	setresuid.2 \
323	setreuid.2 \
324	setsid.2 \
325	setuid.2 \
326	shmat.2 \
327	shmctl.2 \
328	shmget.2 \
329	shm_open.2 \
330	shutdown.2 \
331	sigaction.2 \
332	sigaltstack.2 \
333	sigfastblock.2 \
334	sigpending.2 \
335	sigprocmask.2 \
336	sigqueue.2 \
337	sigreturn.2 \
338	sigstack.2 \
339	sigsuspend.2 \
340	sigwait.2 \
341	sigwaitinfo.2 \
342	socket.2 \
343	socketpair.2 \
344	stat.2 \
345	statfs.2 \
346	swapon.2 \
347	symlink.2 \
348	sync.2 \
349	sysarch.2 \
350	syscall.2 \
351	thr_exit.2 \
352	thr_kill.2 \
353	thr_new.2 \
354	thr_self.2 \
355	thr_set_name.2 \
356	thr_suspend.2 \
357	thr_wake.2 \
358	timer_create.2 \
359	timer_delete.2 \
360	timer_settime.2 \
361	timerfd.2 \
362	truncate.2 \
363	umask.2 \
364	undelete.2 \
365	unlink.2 \
366	utimensat.2 \
367	utimes.2 \
368	utrace.2 \
369	uuidgen.2 \
370	vfork.2 \
371	wait.2 \
372	write.2 \
373	_umtx_op.2
374
375MAN+= \
376	getpagesize.3 \
377	getpagesizes.3 \
378	lockf.3 \
379	rfork_thread.3 \
380	sleep.3 \
381	usleep.3
382
383MLINKS+=aio_read.2 aio_readv.2 \
384	aio_read.2 aio_read2.2
385MLINKS+=aio_write.2 aio_writev.2 \
386	aio_write.2 aio_write2.2
387MLINKS+=accept.2 accept4.2
388MLINKS+=access.2 eaccess.2 \
389	access.2 faccessat.2
390MLINKS+=auxv.3 elf_aux_info.3
391MLINKS+=brk.2 sbrk.2
392MLINKS+=cap_enter.2 cap_getmode.2
393MLINKS+=cap_fcntls_limit.2 cap_fcntls_get.2
394MLINKS+=cap_ioctls_limit.2 cap_ioctls_get.2
395MLINKS+=chdir.2 fchdir.2
396MLINKS+=chflags.2 chflagsat.2 \
397	chflags.2 fchflags.2 \
398	chflags.2 lchflags.2
399MLINKS+=chmod.2 fchmod.2 \
400	chmod.2 fchmodat.2 \
401	chmod.2 lchmod.2
402MLINKS+=chown.2 fchown.2 \
403	chown.2 fchownat.2 \
404	chown.2 lchown.2
405MLINKS+=clock_gettime.2 clock_getres.2 \
406	clock_gettime.2 clock_settime.2
407MLINKS+=closefrom.2 close_range.2
408MLINKS+=nanosleep.2 clock_nanosleep.2
409MLINKS+=cpuset.2 cpuset_getid.2 \
410	cpuset.2 cpuset_setid.2
411MLINKS+=cpuset_getaffinity.2 cpuset_setaffinity.2
412MLINKS+=cpuset_getdomain.2 cpuset_setdomain.2
413MLINKS+=dup.2 dup2.2
414MLINKS+=eventfd.2 eventfd_read.3 \
415	eventfd.2 eventfd_write.3
416MLINKS+=execve.2 fexecve.2
417MLINKS+=extattr_get_file.2 extattr.2 \
418	extattr_get_file.2 extattr_delete_fd.2 \
419	extattr_get_file.2 extattr_delete_file.2 \
420	extattr_get_file.2 extattr_delete_link.2 \
421	extattr_get_file.2 extattr_get_fd.2 \
422	extattr_get_file.2 extattr_get_link.2 \
423	extattr_get_file.2 extattr_list_fd.2 \
424	extattr_get_file.2 extattr_list_file.2 \
425	extattr_get_file.2 extattr_list_link.2 \
426	extattr_get_file.2 extattr_set_fd.2 \
427	extattr_get_file.2 extattr_set_file.2 \
428	extattr_get_file.2 extattr_set_link.2
429MLINKS+=ffclock.2 ffclock_getcounter.2 \
430	ffclock.2 ffclock_getestimate.2 \
431	ffclock.2 ffclock_setestimate.2
432MLINKS+=fhlink.2 fhlinkat.2
433MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2
434MLINKS+=fork.2 _Fork.2
435MLINKS+=fsync.2 fdatasync.2
436MLINKS+=getdirentries.2 getdents.2
437MLINKS+=getfh.2 lgetfh.2 \
438	getfh.2 getfhat.2
439MLINKS+=getgid.2 getegid.2
440MLINKS+=getitimer.2 setitimer.2
441MLINKS+=getlogin.2 getlogin_r.3
442MLINKS+=getlogin.2 setlogin.2
443MLINKS+=getloginclass.2 setloginclass.2
444MLINKS+=getpgrp.2 getpgid.2
445MLINKS+=getpid.2 getppid.2
446MLINKS+=getpriority.2 setpriority.2
447MLINKS+=getrlimit.2 setrlimit.2
448MLINKS+=getsockopt.2 setsockopt.2
449MLINKS+=gettimeofday.2 settimeofday.2
450MLINKS+=getuid.2 geteuid.2
451MLINKS+=intro.2 errno.2
452MLINKS+=jail.2 jail_attach.2 \
453	jail.2 jail_get.2 \
454	jail.2 jail_remove.2 \
455	jail.2 jail_set.2
456MLINKS+=kldunload.2 kldunloadf.2
457MLINKS+=kqueue.2 kevent.2 \
458	kqueue.2 kqueuex.2 \
459	kqueue.2 EV_SET.3
460MLINKS+=link.2 linkat.2
461MLINKS+=madvise.2 posix_madvise.2
462MLINKS+=mkdir.2 mkdirat.2
463MLINKS+=mkfifo.2 mkfifoat.2
464MLINKS+=mknod.2 mknodat.2
465MLINKS+=mlock.2 munlock.2
466MLINKS+=mlockall.2 munlockall.2
467MLINKS+=modnext.2 modfnext.2
468MLINKS+=mount.2 nmount.2 \
469	mount.2 unmount.2
470MLINKS+=mq_receive.2 mq_timedreceive.2
471MLINKS+=mq_send.2 mq_timedsend.2
472MLINKS+=ntp_adjtime.2 ntp_gettime.2
473MLINKS+=open.2 openat.2
474MLINKS+=pathconf.2 fpathconf.2
475MLINKS+=pathconf.2 lpathconf.2
476MLINKS+=pdfork.2 pdgetpid.2\
477	pdfork.2 pdkill.2
478MLINKS+=pipe.2 pipe2.2
479MLINKS+=poll.2 ppoll.2
480MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \
481	rctl_add_rule.2 rctl_get_racct.2 \
482	rctl_add_rule.2 rctl_get_rules.2 \
483	rctl_add_rule.2 rctl_remove_rule.2
484MLINKS+=read.2 pread.2 \
485	read.2 preadv.2 \
486	read.2 readv.2
487MLINKS+=readlink.2 readlinkat.2
488MLINKS+=recv.2 recvfrom.2 \
489	recv.2 recvmsg.2
490MLINKS+=rename.2 renameat.2
491MLINKS+=rtprio.2 rtprio_thread.2
492MLINKS+=sched_get_priority_max.2 sched_get_priority_min.2 \
493	sched_get_priority_max.2 sched_rr_get_interval.2
494MLINKS+=sched_setparam.2 sched_getparam.2
495MLINKS+=sched_setscheduler.2 sched_getscheduler.2
496MLINKS+=sctp_generic_sendmsg.2 sctp_generic_sendmsg_iov.2
497MLINKS+=select.2 FD_CLR.3 \
498	select.2 FD_ISSET.3 \
499	select.2 FD_SET.3 \
500	select.2 FD_ZERO.3
501MLINKS+=send.2 sendmsg.2 \
502	send.2 sendto.2
503MLINKS+=setpgid.2 setpgrp.2
504MLINKS+=setresuid.2 getresgid.2 \
505	setresuid.2 getresuid.2 \
506	setresuid.2 setresgid.2
507MLINKS+=setuid.2 setegid.2 \
508	setuid.2 seteuid.2 \
509	setuid.2 setgid.2
510MLINKS+=shmat.2 shmdt.2
511MLINKS+=shm_open.2 memfd_create.3 \
512	shm_open.2 shm_create_largepage.3 \
513	shm_open.2 shm_unlink.2 \
514	shm_open.2 shm_rename.2
515MLINKS+=sigwaitinfo.2 sigtimedwait.2
516MLINKS+=stat.2 fstat.2 \
517	stat.2 fstatat.2 \
518	stat.2 lstat.2
519MLINKS+=statfs.2 fstatfs.2
520MLINKS+=swapon.2 swapoff.2
521MLINKS+=symlink.2 symlinkat.2
522MLINKS+=syscall.2 __syscall.2
523MLINKS+=timer_settime.2 timer_getoverrun.2 \
524	timer_settime.2 timer_gettime.2
525MLINKS+=timerfd.2 timerfd_create.2 \
526	timerfd.2 timerfd_gettime.2 \
527	timerfd.2 timerfd_settime.2
528MLINKS+=thr_kill.2 thr_kill2.2
529MLINKS+=truncate.2 ftruncate.2
530MLINKS+=unlink.2 unlinkat.2
531MLINKS+=unlink.2 funlinkat.2
532MLINKS+=utimensat.2 futimens.2
533MLINKS+=utimes.2 futimes.2 \
534	utimes.2 futimesat.2 \
535	utimes.2 lutimes.2
536MLINKS+=wait.2 wait3.2 \
537	wait.2 wait4.2 \
538	wait.2 waitpid.2 \
539	wait.2 waitid.2 \
540	wait.2 wait6.2
541MLINKS+=write.2 pwrite.2 \
542	write.2 pwritev.2 \
543	write.2 writev.2
544.endif # ${LIB} == "sys"
545