xref: /freebsd/lib/libsys/Makefile.sys (revision d6bc31f92991b6d67da54868f3563278015389ca)
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	libsys_sigwait.c
41
42.if ${LIB} == "c"
43# Trapping stubs in dynamic libc to be filtered by libsys.
44SOBJS+=	libc_stubs.pico
45
46# Link the full implementation of ELF auxargs for static libc.
47STATICOBJS+=	auxv.o
48
49STATICOBJS+=	interposing_table.o
50.endif
51
52PSEUDO= \
53	__realpathat \
54	clock_gettime \
55	getlogin \
56	gettimeofday \
57	sched_getcpu
58
59INTERPOSED = \
60	accept \
61	accept4 \
62	aio_suspend \
63	clock_nanosleep \
64	close \
65	connect \
66	fcntl \
67	fdatasync \
68	fsync \
69	fork \
70	kevent \
71	msync \
72	nanosleep \
73	open \
74	openat \
75	pdfork \
76	pdwait \
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
131NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n'
132.if ${MACHINE_CPUARCH} == "aarch64"
133FEATURE_NOTE='\#include <sys/elf_common.h>\nGNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)\n'
134.else
135FEATURE_NOTE=''
136.endif
137
138# Add this file as a dependency of the generated assembly along with
139# the two included files compat.h and SYS.h.  Depending on this Makefile
140# will cause some needless regenerations, but handles both changes in
141# generated assembly and movement between MIASM and PSEUDO/INTERPOSED.
142# The dependency on compat.h and SYS.h should properly be on the
143# <foo>.S-><foo>.o rules, but there are too many .o variants for it to
144# be easy and touching the geneated source files has the same effect in
145# practice.
146__makefile_sys:=	${.PARSEDIR}/${.PARSEFILE}
147__asm_deps=	${__makefile_sys} \
148		${LIBC_SRCTOP}/include/compat.h \
149		${LIBSYS_SRCTOP}/${LIBC_ARCH}/SYS.h
150
151${SASM}: ${__asm_deps}
152	printf '/* %sgenerated by libsys/Makefile.sys */\n' @ > ${.TARGET}
153	printf '#include "compat.h"\n' >> ${.TARGET}
154	printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' >> ${.TARGET}
155	printf  ${NOTE_GNU_STACK} >>${.TARGET}
156	printf  ${FEATURE_NOTE} >> ${.TARGET}
157
158${SPSEUDO}: ${__asm_deps}
159	printf '/* %sgenerated by libsys/Makefile.sys */\n' @ > ${.TARGET}
160	printf '#include "compat.h"\n' >> ${.TARGET}
161	printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \
162	    >> ${.TARGET}
163	printf ${NOTE_GNU_STACK} >>${.TARGET}
164	printf ${FEATURE_NOTE} >> ${.TARGET}
165
166.if ${LIB} == "sys"
167MAN+=	abort2.2 \
168	accept.2 \
169	access.2 \
170	acct.2 \
171	adjtime.2 \
172	aio_cancel.2 \
173	aio_error.2 \
174	aio_fsync.2 \
175	aio_mlock.2 \
176	aio_read.2 \
177	aio_return.2 \
178	aio_suspend.2 \
179	aio_waitcomplete.2 \
180	aio_write.2 \
181	auxv.3 \
182	bind.2 \
183	bindat.2 \
184	brk.2 \
185	cap_enter.2 \
186	cap_fcntls_limit.2 \
187	cap_ioctls_limit.2 \
188	cap_rights_limit.2 \
189	chdir.2 \
190	chflags.2 \
191	chmod.2 \
192	chown.2 \
193	chroot.2 \
194	clock_gettime.2 \
195	close.2 \
196	closefrom.2 \
197	connect.2 \
198	connectat.2 \
199	copy_file_range.2 \
200	cpuset.2 \
201	cpuset_getaffinity.2 \
202	cpuset_getdomain.2 \
203	creat.2 \
204	dup.2 \
205	eventfd.2 \
206	execve.2 \
207	_exit.2 \
208	extattr_get_file.2 \
209	fcntl.2 \
210	ffclock.2 \
211	fhlink.2 \
212	fhopen.2 \
213	fhreadlink.2 \
214	flock.2 \
215	fork.2 \
216	fspacectl.2 \
217	fsync.2 \
218	getdirentries.2 \
219	getdtablesize.2 \
220	getfh.2 \
221	getfsstat.2 \
222	getgid.2 \
223	getgroups.2 \
224	getitimer.2 \
225	getlogin.2 \
226	getloginclass.2 \
227	getpeername.2 \
228	getpgrp.2 \
229	getpid.2 \
230	getpriority.2 \
231	getrandom.2 \
232	getrlimit.2 \
233	getrlimitusage.2 \
234	getrusage.2 \
235	getsid.2 \
236	getsockname.2 \
237	getsockopt.2 \
238	gettimeofday.2 \
239	getuid.2 \
240	inotify.2 \
241	intro.2 \
242	ioctl.2 \
243	issetugid.2 \
244	jail.2 \
245	kcmp.2 \
246	kenv.2 \
247	kexec_load.2 \
248	kill.2 \
249	kldfind.2 \
250	kldfirstmod.2 \
251	kldload.2 \
252	kldnext.2 \
253	kldstat.2 \
254	kldsym.2 \
255	kldunload.2 \
256	kqueue.2 \
257	ktrace.2 \
258	link.2 \
259	lio_listio.2 \
260	listen.2 \
261	lseek.2 \
262	madvise.2 \
263	membarrier.2 \
264	mincore.2 \
265	minherit.2 \
266	mkdir.2 \
267	mkfifo.2 \
268	mknod.2 \
269	mlock.2 \
270	mlockall.2 \
271	mmap.2 \
272	modfind.2 \
273	modnext.2 \
274	modstat.2 \
275	mount.2 \
276	mprotect.2 \
277	mq_close.2 \
278	mq_getattr.2 \
279	mq_notify.2 \
280	mq_open.2 \
281	mq_receive.2 \
282	mq_send.2 \
283	mq_setattr.2 \
284	mq_unlink.2 \
285	msgctl.2 \
286	msgget.2 \
287	msgrcv.2 \
288	msgsnd.2 \
289	msync.2 \
290	munmap.2 \
291	nanosleep.2 \
292	nfssvc.2 \
293	ntp_adjtime.2 \
294	open.2 \
295	pathconf.2 \
296	pdfork.2 \
297	pipe.2 \
298	poll.2 \
299	posix_fadvise.2 \
300	posix_fallocate.2 \
301	posix_openpt.2 \
302	procctl.2 \
303	profil.2 \
304	pselect.2 \
305	ptrace.2 \
306	quotactl.2 \
307	rctl_add_rule.2 \
308	read.2 \
309	readlink.2 \
310	reboot.2 \
311	recv.2 \
312	rename.2 \
313	revoke.2 \
314	rfork.2 \
315	rmdir.2 \
316	rtprio.2 \
317	sched_get_priority_max.2 \
318	sched_getcpu.3 \
319	sched_setparam.2 \
320	sched_setscheduler.2 \
321	sched_yield.2 \
322	sctp_generic_recvmsg.2 \
323	sctp_generic_sendmsg.2 \
324	sctp_peeloff.2 \
325	select.2 \
326	semctl.2 \
327	semget.2 \
328	semop.2 \
329	send.2 \
330	setcred.2 \
331	setfib.2 \
332	sendfile.2 \
333	setgroups.2 \
334	setpgid.2 \
335	setregid.2 \
336	setresuid.2 \
337	setreuid.2 \
338	setsid.2 \
339	setuid.2 \
340	shmat.2 \
341	shmctl.2 \
342	shmget.2 \
343	shm_open.2 \
344	shutdown.2 \
345	sigaction.2 \
346	sigaltstack.2 \
347	sigfastblock.2 \
348	sigpending.2 \
349	sigprocmask.2 \
350	sigqueue.2 \
351	sigreturn.2 \
352	sigstack.2 \
353	sigsuspend.2 \
354	sigwait.2 \
355	sigwaitinfo.2 \
356	socket.2 \
357	socketpair.2 \
358	stat.2 \
359	statfs.2 \
360	swapon.2 \
361	symlink.2 \
362	sync.2 \
363	sysarch.2 \
364	syscall.2 \
365	thr_exit.2 \
366	thr_kill.2 \
367	thr_new.2 \
368	thr_self.2 \
369	thr_set_name.2 \
370	thr_suspend.2 \
371	thr_wake.2 \
372	timer_create.2 \
373	timer_delete.2 \
374	timer_settime.2 \
375	timerfd.2 \
376	truncate.2 \
377	umask.2 \
378	undelete.2 \
379	unlink.2 \
380	utimensat.2 \
381	utimes.2 \
382	utrace.2 \
383	uuidgen.2 \
384	vfork.2 \
385	wait.2 \
386	write.2 \
387	_umtx_op.2
388
389MAN+= \
390	getpagesize.3 \
391	getpagesizes.3 \
392	lockf.3 \
393	rfork_thread.3 \
394	sleep.3 \
395	usleep.3
396
397MLINKS+=aio_read.2 aio_readv.2 \
398	aio_read.2 aio_read2.2
399MLINKS+=aio_write.2 aio_writev.2 \
400	aio_write.2 aio_write2.2
401MLINKS+=accept.2 accept4.2
402MLINKS+=access.2 eaccess.2 \
403	access.2 faccessat.2
404MLINKS+=auxv.3 elf_aux_info.3
405MLINKS+=brk.2 sbrk.2
406MLINKS+=cap_enter.2 cap_getmode.2
407MLINKS+=cap_fcntls_limit.2 cap_fcntls_get.2
408MLINKS+=cap_ioctls_limit.2 cap_ioctls_get.2
409MLINKS+=chdir.2 fchdir.2
410MLINKS+=chflags.2 chflagsat.2 \
411	chflags.2 fchflags.2 \
412	chflags.2 lchflags.2
413MLINKS+=chmod.2 fchmod.2 \
414	chmod.2 fchmodat.2 \
415	chmod.2 lchmod.2
416MLINKS+=chown.2 fchown.2 \
417	chown.2 fchownat.2 \
418	chown.2 lchown.2
419MLINKS+=chroot.2 fchroot.2
420MLINKS+=clock_gettime.2 clock_getres.2 \
421	clock_gettime.2 clock_settime.2
422MLINKS+=closefrom.2 close_range.2
423MLINKS+=nanosleep.2 clock_nanosleep.2
424MLINKS+=cpuset.2 cpuset_getid.2 \
425	cpuset.2 cpuset_setid.2
426MLINKS+=cpuset_getaffinity.2 cpuset_setaffinity.2
427MLINKS+=cpuset_getdomain.2 cpuset_setdomain.2
428MLINKS+=dup.2 dup2.2
429MLINKS+=eventfd.2 eventfd_read.3 \
430	eventfd.2 eventfd_write.3
431MLINKS+=execve.2 fexecve.2
432MLINKS+=extattr_get_file.2 extattr.2 \
433	extattr_get_file.2 extattr_delete_fd.2 \
434	extattr_get_file.2 extattr_delete_file.2 \
435	extattr_get_file.2 extattr_delete_link.2 \
436	extattr_get_file.2 extattr_get_fd.2 \
437	extattr_get_file.2 extattr_get_link.2 \
438	extattr_get_file.2 extattr_list_fd.2 \
439	extattr_get_file.2 extattr_list_file.2 \
440	extattr_get_file.2 extattr_list_link.2 \
441	extattr_get_file.2 extattr_set_fd.2 \
442	extattr_get_file.2 extattr_set_file.2 \
443	extattr_get_file.2 extattr_set_link.2
444MLINKS+=ffclock.2 ffclock_getcounter.2 \
445	ffclock.2 ffclock_getestimate.2 \
446	ffclock.2 ffclock_setestimate.2
447MLINKS+=fhlink.2 fhlinkat.2
448MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2
449MLINKS+=fork.2 _Fork.2
450MLINKS+=fsync.2 fdatasync.2
451MLINKS+=getdirentries.2 getdents.2
452MLINKS+=getfh.2 lgetfh.2 \
453	getfh.2 getfhat.2
454MLINKS+=getgid.2 getegid.2
455MLINKS+=getitimer.2 setitimer.2
456MLINKS+=getlogin.2 getlogin_r.3
457MLINKS+=getlogin.2 setlogin.2
458MLINKS+=getloginclass.2 setloginclass.2
459MLINKS+=getpgrp.2 getpgid.2
460MLINKS+=getpid.2 getppid.2
461MLINKS+=getpriority.2 setpriority.2
462MLINKS+=getrlimit.2 setrlimit.2
463MLINKS+=getsockopt.2 setsockopt.2
464MLINKS+=gettimeofday.2 settimeofday.2
465MLINKS+=getuid.2 geteuid.2
466MLINKS+=inotify.2 inotify_init.2 \
467	inotify.2 inotify_init1.2 \
468	inotify.2 inotify_add_watch.2 \
469	inotify.2 inotify_add_watch_at.2 \
470	inotify.2 inotify_rm_watch.2
471MLINKS+=intro.2 errno.2
472MLINKS+=jail.2 jail_attach.2 \
473	jail.2 jail_get.2 \
474	jail.2 jail_remove.2 \
475	jail.2 jail_set.2 \
476	jail.2 jail_attach_jd.2 \
477	jail.2 jail_remove_jd.2
478MLINKS+=kldunload.2 kldunloadf.2
479MLINKS+=kqueue.2 kevent.2 \
480	kqueue.2 kqueue1.2 \
481	kqueue.2 kqueuex.2 \
482	kqueue.2 EV_SET.3
483MLINKS+=link.2 linkat.2
484MLINKS+=madvise.2 posix_madvise.2
485MLINKS+=mkdir.2 mkdirat.2
486MLINKS+=mkfifo.2 mkfifoat.2
487MLINKS+=mknod.2 mknodat.2
488MLINKS+=mlock.2 munlock.2
489MLINKS+=mlockall.2 munlockall.2
490MLINKS+=modnext.2 modfnext.2
491MLINKS+=mount.2 nmount.2 \
492	mount.2 unmount.2
493MLINKS+=mq_receive.2 mq_timedreceive.2
494MLINKS+=mq_send.2 mq_timedsend.2
495MLINKS+=ntp_adjtime.2 ntp_gettime.2
496MLINKS+=open.2 openat.2
497MLINKS+=pathconf.2 fpathconf.2
498MLINKS+=pathconf.2 lpathconf.2
499MLINKS+=pdfork.2 pdgetpid.2 \
500	pdfork.2 pdkill.2 \
501	pdfork.2 pdrfork.2 \
502	pdfork.2 pdwait.2
503MLINKS+=pipe.2 pipe2.2
504MLINKS+=poll.2 ppoll.2
505MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \
506	rctl_add_rule.2 rctl_get_racct.2 \
507	rctl_add_rule.2 rctl_get_rules.2 \
508	rctl_add_rule.2 rctl_remove_rule.2
509MLINKS+=read.2 pread.2 \
510	read.2 preadv.2 \
511	read.2 readv.2
512MLINKS+=readlink.2 readlinkat.2
513MLINKS+=recv.2 recvfrom.2 \
514	recv.2 recvmmsg.2 \
515	recv.2 recvmsg.2
516MLINKS+=rename.2 renameat.2
517MLINKS+=rtprio.2 rtprio_thread.2
518MLINKS+=sched_get_priority_max.2 sched_get_priority_min.2 \
519	sched_get_priority_max.2 sched_rr_get_interval.2
520MLINKS+=sched_setparam.2 sched_getparam.2
521MLINKS+=sched_setscheduler.2 sched_getscheduler.2
522MLINKS+=sctp_generic_sendmsg.2 sctp_generic_sendmsg_iov.2
523MLINKS+=select.2 FD_CLR.3 \
524	select.2 FD_ISSET.3 \
525	select.2 FD_SET.3 \
526	select.2 FD_ZERO.3
527MLINKS+=send.2 sendmmsg.2 \
528	send.2 sendmsg.2 \
529	send.2 sendto.2
530MLINKS+=setpgid.2 setpgrp.2
531MLINKS+=setresuid.2 getresgid.2 \
532	setresuid.2 getresuid.2 \
533	setresuid.2 setresgid.2
534MLINKS+=setuid.2 setegid.2 \
535	setuid.2 seteuid.2 \
536	setuid.2 setgid.2
537MLINKS+=shmat.2 shmdt.2
538MLINKS+=shm_open.2 memfd_create.3 \
539	shm_open.2 shm_create_largepage.3 \
540	shm_open.2 shm_unlink.2 \
541	shm_open.2 shm_rename.2
542MLINKS+=sigwaitinfo.2 sigtimedwait.2
543MLINKS+=stat.2 fstat.2 \
544	stat.2 fstatat.2 \
545	stat.2 lstat.2
546MLINKS+=statfs.2 fstatfs.2
547MLINKS+=swapon.2 swapoff.2
548MLINKS+=symlink.2 symlinkat.2
549MLINKS+=syscall.2 __syscall.2
550MLINKS+=timer_settime.2 timer_getoverrun.2 \
551	timer_settime.2 timer_gettime.2
552MLINKS+=timerfd.2 timerfd_create.2 \
553	timerfd.2 timerfd_gettime.2 \
554	timerfd.2 timerfd_settime.2
555MLINKS+=thr_kill.2 thr_kill2.2
556MLINKS+=truncate.2 ftruncate.2
557MLINKS+=unlink.2 unlinkat.2
558MLINKS+=unlink.2 funlinkat.2
559MLINKS+=utimensat.2 futimens.2
560MLINKS+=utimes.2 futimes.2 \
561	utimes.2 futimesat.2 \
562	utimes.2 lutimes.2
563MLINKS+=wait.2 wait3.2 \
564	wait.2 wait4.2 \
565	wait.2 waitpid.2 \
566	wait.2 waitid.2 \
567	wait.2 wait6.2
568MLINKS+=write.2 pwrite.2 \
569	write.2 pwritev.2 \
570	write.2 writev.2
571.endif # ${LIB} == "sys"
572