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