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