├── .gitignore ├── COPYING ├── INSTALL ├── Makefile ├── README ├── config.h ├── config.mk ├── configure ├── doc ├── README ├── buildroot.txt ├── builtin.txt ├── console.txt ├── daemons.txt ├── dependencies.txt ├── dietlibc.txt ├── direct.txt ├── failure.txt ├── init.txt ├── initctl.txt ├── initdir.txt ├── initrec.txt ├── inittab.txt ├── libc.txt ├── limits.txt ├── memory.txt ├── mininit.txt ├── misc.txt ├── others.txt ├── qemu.txt ├── runsrv.txt ├── slippery.txt ├── sublevels.txt ├── syscalls.txt ├── syslog.txt └── sysvinit.txt ├── etc ├── initdir │ ├── README │ ├── sys │ │ └── mountvfs │ ├── xftp │ └── xinetd~ ├── inittab └── inittab.example ├── init.c ├── init.h ├── init.man ├── init_cmds.c ├── init_conf.c ├── init_conf.h ├── init_conf_arg.c ├── init_conf_dir.c ├── init_conf_key.c ├── init_conf_map.c ├── init_conf_rec.c ├── init_conf_tab.c ├── init_ctrl.c ├── init_dump.c ├── init_find.c ├── init_null.c ├── init_pass.c ├── init_proc.c ├── init_wait.c ├── init_warn.c ├── initdir.man ├── inittab.man ├── libc ├── Makefile ├── README ├── arm │ ├── Makefile │ ├── README │ ├── _start.s │ ├── _syscall.s │ ├── _syscall.sh │ ├── accept.s │ ├── bind.s │ ├── bits │ │ ├── dirent.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── poll.h │ │ ├── rlimit.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── syscall.h │ │ └── types.h │ ├── chdir.s │ ├── chroot.s │ ├── clock_gettime.s │ ├── close.s │ ├── connect.s │ ├── dup2.s │ ├── execve.s │ ├── fcntl.s │ ├── fork.s │ ├── fstat.s │ ├── getdents64.s │ ├── getpid.s │ ├── getsockopt.s │ ├── getuid.s │ ├── ioctl.s │ ├── kill.s │ ├── listen.s │ ├── mmap.s │ ├── mremap.s │ ├── munmap.s │ ├── nanosleep.s │ ├── open.s │ ├── ppoll.s │ ├── read.s │ ├── reboot.s │ ├── send.s │ ├── setfsgid.s │ ├── setfsuid.s │ ├── setitimer.s │ ├── setpriority.s │ ├── setresgid.s │ ├── setresuid.s │ ├── setrlimit.s │ ├── setsid.s │ ├── shutdown.s │ ├── sigaction.s │ ├── sigprocmask.s │ ├── socket.s │ ├── stat.s │ ├── umask.s │ ├── unshare.s │ ├── vfork.s │ ├── waitpid.s │ └── write.s ├── arm64 │ ├── Makefile │ ├── README │ ├── _start.s │ ├── _syscall.s │ ├── _syscall.sh │ ├── accept.s │ ├── bind.s │ ├── bits │ │ ├── dirent.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── poll.h │ │ ├── rlimit.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── syscall.h │ │ └── types.h │ ├── chdir.s │ ├── chroot.s │ ├── clock_gettime.s │ ├── close.s │ ├── connect.s │ ├── dup2.s │ ├── execve.s │ ├── fcntl.s │ ├── fork.s │ ├── fstat.s │ ├── getdents64.s │ ├── getpid.s │ ├── getsockopt.s │ ├── getuid.s │ ├── ioctl.s │ ├── kill.s │ ├── listen.s │ ├── mmap.s │ ├── mremap.s │ ├── munmap.s │ ├── nanosleep.s │ ├── open.s │ ├── ppoll.s │ ├── read.s │ ├── reboot.s │ ├── send.s │ ├── setfsgid.s │ ├── setfsuid.s │ ├── setitimer.s │ ├── setpriority.s │ ├── setresgid.s │ ├── setresuid.s │ ├── setrlimit.s │ ├── setsid.s │ ├── shutdown.s │ ├── sigaction.s │ ├── sigprocmask.s │ ├── socket.s │ ├── stat.s │ ├── umask.s │ ├── unshare.s │ ├── vfork.s │ ├── waitpid.s │ └── write.s ├── atoi.c ├── getenv.c ├── gmtime_r.c ├── include │ ├── dirent.h │ ├── errno.h │ ├── fcntl.h │ ├── inttypes.h │ ├── limits.h │ ├── poll.h │ ├── sched.h │ ├── signal.h │ ├── stdarg.h │ ├── stddef.h │ ├── stdint.h │ ├── stdio.h │ ├── stdlib.h │ ├── string.h │ ├── sys │ │ ├── cdefs.h │ │ ├── fsuid.h │ │ ├── ioctl.h │ │ ├── mman.h │ │ ├── poll.h │ │ ├── reboot.h │ │ ├── resource.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── syscall.h │ │ ├── time.h │ │ ├── types.h │ │ ├── un.h │ │ └── wait.h │ ├── time.h │ └── unistd.h ├── libtest │ ├── Makefile │ ├── README │ ├── errlist.c │ ├── printf.c │ ├── putchar.c │ ├── puts.c │ ├── sleep.c │ └── strerror.c ├── memcmp.c ├── memcpy.c ├── memmove.c ├── memset.c ├── mips │ ├── Makefile │ ├── README │ ├── _start.s │ ├── _syscall.s │ ├── _syscall.sh │ ├── accept.s │ ├── bind.s │ ├── bits │ │ ├── dirent.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── poll.h │ │ ├── rlimit.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── syscall.h │ │ └── types.h │ ├── chdir.s │ ├── chroot.s │ ├── clock_gettime.s │ ├── close.s │ ├── connect.s │ ├── dup2.s │ ├── execve.s │ ├── fcntl.s │ ├── fork.s │ ├── fstat.s │ ├── getdents64.s │ ├── getpid.s │ ├── getsockopt.s │ ├── getuid.s │ ├── ioctl.s │ ├── kill.s │ ├── listen.s │ ├── mmap.s │ ├── mremap.s │ ├── munmap.s │ ├── nanosleep.s │ ├── open.s │ ├── ppoll.s │ ├── read.s │ ├── reboot.s │ ├── send.s │ ├── setfsgid.s │ ├── setfsuid.s │ ├── setitimer.s │ ├── setpriority.s │ ├── setresgid.s │ ├── setresuid.s │ ├── setrlimit.s │ ├── setsid.s │ ├── shutdown.s │ ├── sigaction.s │ ├── sigprocmask.s │ ├── socket.s │ ├── stat.s │ ├── umask.s │ ├── unshare.s │ ├── waitpid.s │ └── write.s ├── raise.c ├── sigaddset.c ├── sigemptyset.c ├── strcat.c ├── strchr.c ├── strcmp.c ├── strcpy.c ├── strlen.c ├── strncpy.c ├── strpbrk.c ├── strsep.c ├── x86 │ ├── Makefile │ ├── README │ ├── _start.s │ ├── _syscall.s │ ├── _syscall.sh │ ├── _syssock.sh │ ├── accept.s │ ├── bind.s │ ├── bits │ │ ├── dirent.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── net.h │ │ ├── poll.h │ │ ├── rlimit.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── syscall.h │ │ └── types.h │ ├── chdir.s │ ├── chroot.s │ ├── clock_gettime.s │ ├── close.s │ ├── connect.s │ ├── dup2.s │ ├── execve.s │ ├── fcntl.s │ ├── fork.s │ ├── fstat.s │ ├── getdents64.s │ ├── getpid.s │ ├── getsockopt.s │ ├── getuid.s │ ├── ioctl.s │ ├── kill.s │ ├── listen.s │ ├── mmap.s │ ├── mremap.s │ ├── munmap.s │ ├── nanosleep.s │ ├── open.s │ ├── ppoll.s │ ├── read.s │ ├── reboot.s │ ├── send.s │ ├── setfsgid.s │ ├── setfsuid.s │ ├── setitimer.s │ ├── setpriority.s │ ├── setresgid.s │ ├── setresuid.s │ ├── setrlimit.s │ ├── setsid.s │ ├── shutdown.s │ ├── sigaction.s │ ├── sigprocmask.s │ ├── socket.s │ ├── socketcall.s │ ├── stat.s │ ├── umask.s │ ├── unshare.s │ ├── vfork.s │ ├── waitpid.s │ └── write.s ├── x86_32 │ ├── Makefile │ ├── README │ ├── _start.s │ ├── _syscall.s │ ├── _syscall.sh │ ├── accept.s │ ├── bind.s │ ├── bits │ │ ├── dirent.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── net.h │ │ ├── poll.h │ │ ├── rlimit.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── syscall.h │ │ └── types.h │ ├── chdir.s │ ├── chroot.s │ ├── clock_gettime.s │ ├── close.s │ ├── connect.s │ ├── dup2.s │ ├── execve.s │ ├── fcntl.s │ ├── fork.s │ ├── fstat.s │ ├── getdents64.s │ ├── getpid.s │ ├── getsockopt.s │ ├── getuid.s │ ├── ioctl.s │ ├── kill.s │ ├── listen.s │ ├── mmap.s │ ├── mremap.s │ ├── munmap.s │ ├── nanosleep.s │ ├── open.s │ ├── ppoll.s │ ├── read.s │ ├── reboot.s │ ├── send.s │ ├── setfsgid.s │ ├── setfsuid.s │ ├── setitimer.s │ ├── setpriority.s │ ├── setresgid.s │ ├── setresuid.s │ ├── setrlimit.s │ ├── setsid.s │ ├── shutdown.s │ ├── sigaction.s │ ├── sigprocmask.s │ ├── socket.s │ ├── stat.s │ ├── umask.s │ ├── unshare.s │ ├── vfork.s │ ├── waitpid.s │ └── write.s └── x86_64 │ ├── Makefile │ ├── README │ ├── _start.s │ ├── _syscall.s │ ├── _syscall.sh │ ├── accept.s │ ├── bind.s │ ├── bits │ ├── dirent.h │ ├── errno.h │ ├── fcntl.h │ ├── ioctl.h │ ├── limits.h │ ├── mman.h │ ├── poll.h │ ├── rlimit.h │ ├── signal.h │ ├── socket.h │ ├── stat.h │ ├── syscall.h │ └── types.h │ ├── chdir.s │ ├── chroot.s │ ├── clock_gettime.s │ ├── close.s │ ├── connect.s │ ├── dup2.s │ ├── execve.s │ ├── fcntl.s │ ├── fork.s │ ├── fstat.s │ ├── getdents64.s │ ├── getpid.s │ ├── getsockopt.s │ ├── getuid.s │ ├── ioctl.s │ ├── kill.s │ ├── listen.s │ ├── mmap.s │ ├── mremap.s │ ├── munmap.s │ ├── nanosleep.s │ ├── open.s │ ├── ppoll.s │ ├── read.s │ ├── reboot.s │ ├── send.s │ ├── setfsgid.s │ ├── setfsuid.s │ ├── setitimer.s │ ├── setpriority.s │ ├── setresgid.s │ ├── setresuid.s │ ├── setrlimit.s │ ├── setsid.s │ ├── shutdown.s │ ├── sigaction.s │ ├── sigprocmask.s │ ├── socket.s │ ├── stat.s │ ├── strcmp.s │ ├── umask.s │ ├── unshare.s │ ├── vfork.s │ ├── waitpid.s │ └── write.s ├── mansubst ├── misc ├── buildroot │ ├── Config.in │ ├── README │ ├── board │ │ └── sninit │ │ │ ├── post_build.sh │ │ │ ├── qemu_aarch64.sh │ │ │ ├── qemu_arm.sh │ │ │ ├── qemu_mips.sh │ │ │ ├── qemu_x86.sh │ │ │ ├── qemu_x86_64.sh │ │ │ ├── root.aarch64 │ │ │ ├── etc │ │ │ │ └── inittab │ │ │ └── setup │ │ │ ├── root.mips │ │ │ └── etc │ │ │ │ └── inittab │ │ │ └── root │ │ │ └── etc │ │ │ └── inittab │ ├── configs │ │ ├── sninit_aarch64_defconfig │ │ ├── sninit_arm_defconfig │ │ ├── sninit_mips_defconfig │ │ ├── sninit_x86_64_defconfig │ │ └── sninit_x86_defconfig │ ├── external.mk │ └── package │ │ └── sninit │ │ ├── Config.in │ │ └── sninit.mk ├── dietlibc │ ├── 0001-ppoll.patch │ ├── 0002-mips-syscall.patch │ ├── 0003-mips-TLS-register.patch │ ├── 0004-mips-fix-ELFINFO-code-in-stackgap.patch │ ├── 0005-arm-syscall.patch │ ├── 0006-mremap-proto-to-match-mremap-2-and-uClibc-glibc-head.patch │ ├── 0007-mips-SOCK_NONBLOCK-is-0200-O_NONBLOCK-is-080.patch │ └── README └── service │ ├── README │ ├── acpid │ ├── atd │ ├── avahi │ ├── bandwidthd │ ├── chrony │ ├── connman │ ├── dbus │ ├── dcron │ ├── dnsmasq │ ├── dropbear │ ├── ejabberd │ ├── exim │ ├── haveged │ ├── iiod │ ├── inadyn │ ├── inputevd │ ├── irqbalance │ ├── kodi │ ├── lighttpd │ ├── mongoose │ ├── mpd │ ├── mysqld │ ├── neard │ ├── netatalk │ ├── netman │ ├── netplug │ ├── nginx │ ├── nmbd │ ├── ntpd │ ├── ofono │ ├── olsrd │ ├── openntpd │ ├── postgresql │ ├── proftpd │ ├── ptpd │ ├── ptpd2 │ ├── pulseaudio │ ├── smbd │ ├── squid │ ├── sshd │ ├── supervisord │ ├── thd │ ├── tinyhttpd │ ├── transmission │ ├── tvheadend │ └── vsftpd ├── run.c ├── run.h ├── run.man ├── sbin ├── Makefile ├── README ├── hwclock ├── logger.c ├── mount ├── net ├── sleep ├── slogdg.c ├── slogst.c ├── trap.c └── umount ├── statictab.c ├── sys.h ├── sys_err_init.c ├── sys_err_run.c ├── sys_err_telinit.c ├── sys_execvp.c ├── sys_getdents.c ├── sys_ppoll.c ├── sys_printf.c ├── sys_unshare.c ├── telinit.c ├── telinit.man └── test ├── Makefile ├── _stub.c ├── _test.c ├── _test.h ├── addenviron.c ├── addinitrec.c ├── addparsedargv.c ├── addstaticargv.c ├── addstring.c ├── conf.c ├── dumprec.c ├── dumpstate.c ├── etc └── initdir │ ├── disabled~ │ ├── plain │ ├── script │ └── symlink ├── fileblock.c ├── fileblock.txt ├── findentry.c ├── initpass_.c ├── initpass_off.c ├── initpass_pri.c ├── initpass_rev.c ├── initpass_sec.c ├── initpass_wku.c ├── itostr.c ├── joincmd.c ├── linknode.c ├── newblock.c ├── parseinitline.c ├── parsesrvfile.c ├── pintlen.c ├── printf.c ├── printfstat.px ├── readinitdir.c ├── rewireptsarray.c ├── rlstr.c ├── setrunflags.c ├── shellneeded.c ├── shouldbeshown.c ├── strerror.c ├── strssep.c ├── toofast.c ├── transferpids.c ├── waitpids.c ├── warn.c ├── xaccept.c ├── xhello.c ├── xopen.c ├── xopenread.c ├── xopenread.txt ├── xppoll.c ├── xprintf.c ├── xreboot.c ├── xsigprocmask.c └── xvfork.c /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | *.[oad] 3 | *.ho 4 | builtin.c 5 | init 6 | telinit 7 | statictab 8 | run 9 | test/proto.c 10 | *.[58] 11 | .*.swp 12 | temp/ 13 | test/* 14 | !test/*.* 15 | test/*.out 16 | test/*.[od] 17 | sbin/trap 18 | sbin/slogdg 19 | sbin/slogst 20 | sbin/logger 21 | sbin/*.log 22 | -------------------------------------------------------------------------------- /doc/dietlibc.txt: -------------------------------------------------------------------------------- 1 | dietlibc configuration notes 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | Certain features in dietlibc can be enabled/disabled with #defines 4 | in dietfeatures.h. Most have little effect on sninit, but some 5 | can be used to reduce its size slightly. 6 | 7 | Use "readelf -s init | sort -k3" to check for bloat. 8 | Common culprit is stackgap(), which is a part of generic 9 | initialization routine in dietlibc. 10 | 11 | 12 | #undef WANT_VALGRIND_SUPPORT 13 | #undef WANT_THREAD_SAFE 14 | #undef WANT_TLS 15 | all three reduce the size of stackgap() 16 | 17 | #undef WANT_GNU_STARTUP_BLOAT 18 | 19 | #undef WANT_FASTER_STRING_ROUTINES 20 | #undef WANT_FULL_POSIX_COMPAT 21 | -------------------------------------------------------------------------------- /etc/initdir/README: -------------------------------------------------------------------------------- 1 | This a sample initdir both possible formats of service files. 2 | 3 | xftp 4 | A shell script (interpreted executable) used as a service 5 | file. Note #! on the first line and #: on the second. 6 | 7 | xinetd~ 8 | A simple service file. The command in the file would 9 | be parsed and stored the same way with lines in inittab. 10 | Tilde means it is disabled and will not be executed. 11 | 12 | README 13 | Just a text file that is neither a script nor a service 14 | file. Its name starts with [A-Z] so init will ignore it 15 | (see skipdirent() in ../../init_conf_dir.c) 16 | 17 | sys/ 18 | An unrelated directory. This, too, will be ignored by init. 19 | In particular, init will not read any files in that directory. 20 | 21 | Note all these files will be executed in ../.. (top source dir) 22 | -------------------------------------------------------------------------------- /etc/initdir/sys/mountvfs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This will not be run unless referenced explicitly in inittab! 4 | 5 | /bin/mount -t proc proc /proc 6 | /bin/mkdir -p /dev/pts 7 | /bin/mkdir -p /dev/shm 8 | -------------------------------------------------------------------------------- /etc/initdir/xftp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #:2435 3 | 4 | exec sbin/trap xftp 5 | -------------------------------------------------------------------------------- /etc/initdir/xinetd~: -------------------------------------------------------------------------------- 1 | #:234 2 | # A non-script service file. 3 | # Comments and empty lines at the start of file are ignored. 4 | 5 | /sbin/xinetd -dontfork 6 | -------------------------------------------------------------------------------- /etc/inittab: -------------------------------------------------------------------------------- 1 | # inittab for in-place testing 2 | 3 | PATH=/bin 4 | VAR=value 5 | 6 | # System boot 7 | mount W sbin/mount -o remount,rw / 8 | hwc R sbin/hwclock 9 | W sbin/net up 10 | 11 | # System shutdown 12 | X sbin/net down 13 | X sbin/umount -a 14 | 15 | # Respawning services (see also initdir/) 16 | syslog L sbin/slogdg sbin/devlog sbin/daemon.log 17 | srv1 S sbin/trap srv1 10 18 | srv2 S sbin/trap srv2 23 19 | srv3 S sbin/trap srv3 20 | 21 | # Sleep modes 22 | R789 sbin/net down 23 | sleep W8 sbin/sleep 2 24 | suspend W9 sbin/sleep 5 25 | X789 sbin/net up 26 | 27 | # vim: ft=conf 28 | -------------------------------------------------------------------------------- /etc/inittab.example: -------------------------------------------------------------------------------- 1 | # Inittab syntax: 2 | # 3 | # VARIABLE=value 4 | # 5 | # code name command arg arg arg ... 6 | 7 | # Environment 8 | PATH=/bin:/sbin:/usr/bin 9 | LOCALE=C 10 | 11 | # System initialization 12 | mount W /sbin/mount -o remount,rw / 13 | umount X /sbin/mount -o remount,ro / 14 | syslog L /sbin/syslogd -n 15 | clock R* /sbin/hwlock -s 16 | 17 | # VTs 18 | su F1 /sbin/sulogin 19 | tty1 F /sbin/agetty --noclear -8 -s 38400 tty1 linux 20 | tty2 F /sbin/agetty -8 -s 38400 tty2 linux 21 | tty3 F /sbin/agetty -8 -s 38400 tty3 linux 22 | tty4 F /sbin/agetty -8 -s 38400 tty4 linux 23 | tty5 F /sbin/agetty -8 -s 38400 tty5 linux 24 | tty6 F /sbin/agetty -8 -s 38400 tty6 linux 25 | -------------------------------------------------------------------------------- /init_find.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "init.h" 3 | 4 | /* This tiny function is called from two wildly different places, 5 | so to keep dependencies sane it was moved to its own file. 6 | 7 | init_conf uses it when transferring pids 8 | init_cmds uses it to start/stop entries 9 | 10 | This function looks for an entry from the primary inittab, cfg->inittab, 11 | the one that initpass() uses. Not the one being assembled in newblock. */ 12 | 13 | struct initrec* findentry(const char* name) 14 | { 15 | struct initrec *p, **pp; 16 | 17 | for(pp = cfg->inittab; (p = *pp); pp++) 18 | if(*p->name && !strcmp(p->name, name)) 19 | return p; 20 | 21 | return NULL; 22 | } 23 | -------------------------------------------------------------------------------- /init_null.c: -------------------------------------------------------------------------------- 1 | /* Null configuration, replaces normal init_conf_* routines with stubs. 2 | This file should be linked *instead* of init_conf_* when run-time 3 | reconfiguration is not needed. Static inittab must be built in, 4 | otherwise init will have no config to run with. */ 5 | 6 | #include "init.h" 7 | 8 | int configure(int strict) 9 | { 10 | if(strict) 11 | warn("init is not configurable"); 12 | return -1; 13 | } 14 | 15 | void setnewconf(void) 16 | { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /libc/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile should not be used. It is here merely to make sure 2 | # make (something).o uses the right CFLAGS, for quick-edit syntax checks. 3 | 4 | /=../ 5 | include $/config.mk 6 | CFLAGS := $(filter-out -flto,$(CFLAGS)) 7 | 8 | default: 9 | @echo ERROR: To build libc, run make libc.a from the top directory. 10 | @false 11 | -------------------------------------------------------------------------------- /libc/arm/_start.s: -------------------------------------------------------------------------------- 1 | .equ NR_exit, 1 2 | 3 | .data 4 | 5 | environ: .word 0 6 | 7 | .type environ,object 8 | .size environ,.-environ 9 | 10 | 11 | .text 12 | .align 4 13 | 14 | .global _start 15 | .global _exit 16 | .global environ 17 | 18 | _start: 19 | 20 | mov fp, #0 /* clear the frame pointer */ 21 | ldr a1, [sp] /* argc */ 22 | add a2, sp, #4 /* argv */ 23 | ldr ip, =environ 24 | add a3, a2, a1, lsl #2 /* &argv[argc] */ 25 | add a3, a3, #4 /* envp */ 26 | str a3, [ip, #0] /* environ = envp */ 27 | bl main 28 | 29 | _exit: 30 | mov r7, #NR_exit 31 | swi 0 /* never returns */ 32 | 33 | .type _start,function 34 | .size _start,_exit-_start 35 | 36 | .type _exit,function 37 | .size _exit,.-_exit 38 | -------------------------------------------------------------------------------- /libc/arm/accept.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_accept, 285 3 | 4 | .text 5 | .global accept 6 | 7 | accept: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_accept 10 | b _syscall 11 | 12 | .type accept,function 13 | .size accept,.-accept 14 | -------------------------------------------------------------------------------- /libc/arm/bind.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_bind, 282 3 | 4 | .text 5 | .global bind 6 | 7 | bind: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_bind 10 | b _syscall 11 | 12 | .type bind,function 13 | .size bind,.-bind 14 | -------------------------------------------------------------------------------- /libc/arm/bits/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_DIRENT_H 2 | #define BITS_DIRENT_H 3 | 4 | #include 5 | 6 | #define DT_UNKNOWN 0 7 | #define DT_FIFO 1 8 | #define DT_CHR 2 9 | #define DT_DIR 4 10 | #define DT_BLK 6 11 | #define DT_REG 8 12 | #define DT_LNK 10 13 | #define DT_SOCK 12 14 | #define DT_WHT 14 15 | 16 | struct dirent64 { 17 | uint64_t d_ino; 18 | int64_t d_off; 19 | uint16_t d_reclen; 20 | unsigned char d_type; 21 | char d_name[256]; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/arm/bits/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_FCNTL_H 2 | #define BITS_FCNTL_H 3 | 4 | /* These are pretty much standard */ 5 | #define O_RDONLY 00 6 | #define O_WRONLY 01 7 | #define O_RDWR 02 8 | 9 | /* These are NOT! */ 10 | #define O_CREAT 0100 /* not fcntl */ 11 | #define O_EXCL 0200 /* not fcntl */ 12 | #define O_NOCTTY 0400 /* not fcntl */ 13 | #define O_TRUNC 01000 /* not fcntl */ 14 | #define O_APPEND 02000 15 | #define O_NONBLOCK 04000 16 | #define O_DIRECTORY 040000 /* must be a directory */ 17 | #define O_NOFOLLOW 0100000 /* don't follow links */ 18 | #define O_DIRECT 0200000 /* direct disk access hint - currently ignored */ 19 | #define O_LARGEFILE 0400000 20 | #define O_NOATIME 01000000 21 | #define O_CLOEXEC 02000000 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libc/arm/bits/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_IOCTL_H 2 | #define BITS_IOCTL_H 3 | 4 | #define TIOCSCTTY 0x540E 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/arm/bits/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_LIMITS_H 2 | #define BITS_LIMITS_H 3 | 4 | #define __WORDSIZE 32 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/arm/bits/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_MMAN_H 2 | #define BITS_MMAN_H 3 | 4 | #define MREMAP_MAYMOVE 1UL 5 | #define MREMAP_FIXED 2UL 6 | 7 | #define PROT_READ 0x1 /* page can be read */ 8 | #define PROT_WRITE 0x2 /* page can be written */ 9 | #define PROT_EXEC 0x4 /* page can be executed */ 10 | #define PROT_NONE 0x0 /* page can not be accessed */ 11 | 12 | #define MAP_SHARED 0x01 /* Share changes */ 13 | #define MAP_PRIVATE 0x02 /* Changes are private */ 14 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ 15 | 16 | #define MAP_FAILED ((void *) -1) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/arm/bits/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_POLL_H 2 | #define SYS_POLL_H 3 | 4 | #define POLLIN (1<<0) 5 | #define POLLPRI (1<<1) 6 | #define POLLOUT (1<<2) 7 | #define POLLERR (1<<3) 8 | #define POLLHUP (1<<4) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/arm/bits/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_SOCKET_H 2 | #define BITS_SOCKET_H 3 | 4 | #define AF_UNIX 1 5 | 6 | #define SOCK_STREAM (1<<0) 7 | #define SOCK_DGRAM (1<<1) 8 | #define SOCK_NONBLOCK (1<<11) 9 | #define SOCK_CLOEXEC (1<<19) 10 | 11 | #define SOL_SOCKET 1 12 | #define SO_PEERCRED 17 13 | 14 | #define SHUT_RD 0 15 | #define SHUT_WR 1 16 | #define SHUT_RDWR 2 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/arm/bits/types.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_TYPES_H 2 | #define BITS_TYPES_H 3 | 4 | typedef signed char int8_t; 5 | typedef signed short int16_t; 6 | typedef int int32_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | 12 | typedef signed long long int64_t; 13 | typedef unsigned long long uint64_t; 14 | 15 | typedef unsigned int size_t; 16 | typedef signed long ssize_t; 17 | typedef signed long off_t; 18 | typedef signed long time_t; 19 | 20 | typedef int32_t pid_t; 21 | typedef uint32_t gid_t; 22 | typedef uint32_t uid_t; 23 | 24 | typedef uint32_t socklen_t; 25 | typedef uint16_t sa_family_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libc/arm/chdir.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chdir, 12 3 | 4 | .text 5 | .global chdir 6 | 7 | chdir: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_chdir 10 | b _syscall 11 | 12 | .type chdir,function 13 | .size chdir,.-chdir 14 | -------------------------------------------------------------------------------- /libc/arm/chroot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chroot, 61 3 | 4 | .text 5 | .global chroot 6 | 7 | chroot: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_chroot 10 | b _syscall 11 | 12 | .type chroot,function 13 | .size chroot,.-chroot 14 | -------------------------------------------------------------------------------- /libc/arm/clock_gettime.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_clock_gettime, 263 3 | 4 | .text 5 | .global clock_gettime 6 | 7 | clock_gettime: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_clock_gettime 10 | b _syscall 11 | 12 | .type clock_gettime,function 13 | .size clock_gettime,.-clock_gettime 14 | -------------------------------------------------------------------------------- /libc/arm/close.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_close, 6 3 | 4 | .text 5 | .global close 6 | 7 | close: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_close 10 | b _syscall 11 | 12 | .type close,function 13 | .size close,.-close 14 | -------------------------------------------------------------------------------- /libc/arm/connect.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_connect, 283 3 | 4 | .text 5 | .global connect 6 | 7 | connect: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_connect 10 | b _syscall 11 | 12 | .type connect,function 13 | .size connect,.-connect 14 | -------------------------------------------------------------------------------- /libc/arm/dup2.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_dup2, 63 3 | 4 | .text 5 | .global dup2 6 | 7 | dup2: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_dup2 10 | b _syscall 11 | 12 | .type dup2,function 13 | .size dup2,.-dup2 14 | -------------------------------------------------------------------------------- /libc/arm/execve.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_execve, 11 3 | 4 | .text 5 | .global execve 6 | 7 | execve: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_execve 10 | b _syscall 11 | 12 | .type execve,function 13 | .size execve,.-execve 14 | -------------------------------------------------------------------------------- /libc/arm/fcntl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fcntl, 55 3 | 4 | .text 5 | .global fcntl 6 | 7 | fcntl: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_fcntl 10 | b _syscall 11 | 12 | .type fcntl,function 13 | .size fcntl,.-fcntl 14 | -------------------------------------------------------------------------------- /libc/arm/fork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fork, 2 3 | 4 | .text 5 | .global fork 6 | 7 | fork: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_fork 10 | b _syscall 11 | 12 | .type fork,function 13 | .size fork,.-fork 14 | -------------------------------------------------------------------------------- /libc/arm/fstat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fstat, 108 3 | 4 | .text 5 | .global fstat 6 | 7 | fstat: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_fstat 10 | b _syscall 11 | 12 | .type fstat,function 13 | .size fstat,.-fstat 14 | -------------------------------------------------------------------------------- /libc/arm/getdents64.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getdents64, 217 3 | 4 | .text 5 | .global getdents64 6 | 7 | getdents64: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_getdents64 10 | b _syscall 11 | 12 | .type getdents64,function 13 | .size getdents64,.-getdents64 14 | -------------------------------------------------------------------------------- /libc/arm/getpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getpid, 20 3 | 4 | .text 5 | .global getpid 6 | 7 | getpid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_getpid 10 | b _syscall 11 | 12 | .type getpid,function 13 | .size getpid,.-getpid 14 | -------------------------------------------------------------------------------- /libc/arm/getsockopt.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getsockopt, 295 3 | 4 | .text 5 | .global getsockopt 6 | 7 | getsockopt: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_getsockopt 10 | b _syscall5 11 | 12 | .type getsockopt,function 13 | .size getsockopt,.-getsockopt 14 | -------------------------------------------------------------------------------- /libc/arm/getuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getuid, 24 3 | 4 | .text 5 | .global getuid 6 | 7 | getuid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_getuid 10 | b _syscall 11 | 12 | .type getuid,function 13 | .size getuid,.-getuid 14 | -------------------------------------------------------------------------------- /libc/arm/ioctl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_ioctl, 54 3 | 4 | .text 5 | .global ioctl 6 | 7 | ioctl: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_ioctl 10 | b _syscall 11 | 12 | .type ioctl,function 13 | .size ioctl,.-ioctl 14 | -------------------------------------------------------------------------------- /libc/arm/kill.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_kill, 37 3 | 4 | .text 5 | .global kill 6 | 7 | kill: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_kill 10 | b _syscall 11 | 12 | .type kill,function 13 | .size kill,.-kill 14 | -------------------------------------------------------------------------------- /libc/arm/listen.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_listen, 284 3 | 4 | .text 5 | .global listen 6 | 7 | listen: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_listen 10 | b _syscall 11 | 12 | .type listen,function 13 | .size listen,.-listen 14 | -------------------------------------------------------------------------------- /libc/arm/mmap.s: -------------------------------------------------------------------------------- 1 | # 2 | # mmap takes 6 parameters - ie more than can be passed in registers via the 3 | # regular syscall interface. Instead, parameters are passed on the stack. 4 | # 5 | # On entry, the compiler will have already placed the fifth and sixth 6 | # parameters on the stack - all we need do here is push the first four and 7 | # call the syscall. 8 | # 9 | 10 | .equ NR_mmap2, 192 11 | 12 | .text 13 | .global mmap 14 | 15 | mmap: 16 | str r5, [sp, #-4]! 17 | ldr r5, [sp, #8] 18 | str r4, [sp, #-4]! 19 | ldr r4, [sp, #8] 20 | mov ip, r7 21 | mov r7, #NR_mmap2 22 | svc 0x00000000 23 | mov r7, ip 24 | ldr r4, [sp], #4 25 | ldr r5, [sp], #4 26 | cmn r0, #4096 27 | mov pc, lr /* return */ 28 | 29 | .type mmap,function 30 | .size mmap,.-mmap 31 | -------------------------------------------------------------------------------- /libc/arm/mremap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mremap, 163 3 | 4 | .text 5 | .global mremap 6 | 7 | mremap: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_mremap 10 | b _syscall5 11 | 12 | .type mremap,function 13 | .size mremap,.-mremap 14 | -------------------------------------------------------------------------------- /libc/arm/munmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_munmap, 91 3 | 4 | .text 5 | .global munmap 6 | 7 | munmap: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_munmap 10 | b _syscall 11 | 12 | .type munmap,function 13 | .size munmap,.-munmap 14 | -------------------------------------------------------------------------------- /libc/arm/nanosleep.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_nanosleep, 162 3 | 4 | .text 5 | .global nanosleep 6 | 7 | nanosleep: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_nanosleep 10 | b _syscall 11 | 12 | .type nanosleep,function 13 | .size nanosleep,.-nanosleep 14 | -------------------------------------------------------------------------------- /libc/arm/open.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_open, 5 3 | 4 | .text 5 | .global open 6 | 7 | open: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_open 10 | b _syscall 11 | 12 | .type open,function 13 | .size open,.-open 14 | -------------------------------------------------------------------------------- /libc/arm/ppoll.s: -------------------------------------------------------------------------------- 1 | .equ NR_ppoll, 336 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .align 4 6 | .global ppoll 7 | 8 | # ppoll has 5th argument not listed in the prototype sizeof(sigset_t). 9 | # An extra .c file would have solved the problem of course, but why bother? 10 | 11 | ppoll: 12 | stmfd sp!,{r4,r5,r7,lr} 13 | ldr r4, =sizeof_sigset_t 14 | ldr r7, =NR_ppoll 15 | b _syscall 16 | 17 | .type ppoll,function 18 | .size ppoll,.-ppoll 19 | -------------------------------------------------------------------------------- /libc/arm/read.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_read, 3 3 | 4 | .text 5 | .global read 6 | 7 | read: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_read 10 | b _syscall 11 | 12 | .type read,function 13 | .size read,.-read 14 | -------------------------------------------------------------------------------- /libc/arm/reboot.s: -------------------------------------------------------------------------------- 1 | .equ NR_reboot, 88 2 | .equ LINUX_REBOOT_MAGIC1, 0xfee1dead 3 | .equ LINUX_REBOOT_MAGIC2, 672274793 4 | 5 | .text 6 | .global reboot 7 | 8 | reboot: 9 | stmfd sp!,{r4,r5,r7,lr} 10 | mov r2, r0 11 | ldr r0, =LINUX_REBOOT_MAGIC1 12 | ldr r1, =LINUX_REBOOT_MAGIC2 13 | ldr r7, =NR_reboot 14 | b _syscall 15 | 16 | .type reboot,function 17 | .size reboot,.-reboot 18 | -------------------------------------------------------------------------------- /libc/arm/send.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_send, 289 3 | 4 | .text 5 | .global send 6 | 7 | send: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_send 10 | b _syscall 11 | 12 | .type send,function 13 | .size send,.-send 14 | -------------------------------------------------------------------------------- /libc/arm/setfsgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsgid, 139 3 | 4 | .text 5 | .global setfsgid 6 | 7 | setfsgid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setfsgid 10 | b _syscall 11 | 12 | .type setfsgid,function 13 | .size setfsgid,.-setfsgid 14 | -------------------------------------------------------------------------------- /libc/arm/setfsuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsuid, 138 3 | 4 | .text 5 | .global setfsuid 6 | 7 | setfsuid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setfsuid 10 | b _syscall 11 | 12 | .type setfsuid,function 13 | .size setfsuid,.-setfsuid 14 | -------------------------------------------------------------------------------- /libc/arm/setitimer.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setitimer, 104 3 | 4 | .text 5 | .global setitimer 6 | 7 | setitimer: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setitimer 10 | b _syscall 11 | 12 | .type setitimer,function 13 | .size setitimer,.-setitimer 14 | -------------------------------------------------------------------------------- /libc/arm/setpriority.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setpriority, 97 3 | 4 | .text 5 | .global setpriority 6 | 7 | setpriority: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setpriority 10 | b _syscall 11 | 12 | .type setpriority,function 13 | .size setpriority,.-setpriority 14 | -------------------------------------------------------------------------------- /libc/arm/setresgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresgid, 170 3 | 4 | .text 5 | .global setresgid 6 | 7 | setresgid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setresgid 10 | b _syscall 11 | 12 | .type setresgid,function 13 | .size setresgid,.-setresgid 14 | -------------------------------------------------------------------------------- /libc/arm/setresuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresuid, 164 3 | 4 | .text 5 | .global setresuid 6 | 7 | setresuid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setresuid 10 | b _syscall 11 | 12 | .type setresuid,function 13 | .size setresuid,.-setresuid 14 | -------------------------------------------------------------------------------- /libc/arm/setrlimit.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setrlimit, 75 3 | 4 | .text 5 | .global setrlimit 6 | 7 | setrlimit: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setrlimit 10 | b _syscall 11 | 12 | .type setrlimit,function 13 | .size setrlimit,.-setrlimit 14 | -------------------------------------------------------------------------------- /libc/arm/setsid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setsid, 66 3 | 4 | .text 5 | .global setsid 6 | 7 | setsid: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_setsid 10 | b _syscall 11 | 12 | .type setsid,function 13 | .size setsid,.-setsid 14 | -------------------------------------------------------------------------------- /libc/arm/shutdown.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_shutdown, 293 3 | 4 | .text 5 | .global shutdown 6 | 7 | shutdown: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_shutdown 10 | b _syscall 11 | 12 | .type shutdown,function 13 | .size shutdown,.-shutdown 14 | -------------------------------------------------------------------------------- /libc/arm/sigaction.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_sigaction, 67 3 | 4 | .text 5 | .global sigaction 6 | 7 | sigaction: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_sigaction 10 | b _syscall 11 | 12 | .type sigaction,function 13 | .size sigaction,.-sigaction 14 | -------------------------------------------------------------------------------- /libc/arm/sigprocmask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_sigprocmask, 126 3 | 4 | .text 5 | .global sigprocmask 6 | 7 | sigprocmask: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_sigprocmask 10 | b _syscall 11 | 12 | .type sigprocmask,function 13 | .size sigprocmask,.-sigprocmask 14 | -------------------------------------------------------------------------------- /libc/arm/socket.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_socket, 281 3 | 4 | .text 5 | .global socket 6 | 7 | socket: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_socket 10 | b _syscall 11 | 12 | .type socket,function 13 | .size socket,.-socket 14 | -------------------------------------------------------------------------------- /libc/arm/stat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_stat, 106 3 | 4 | .text 5 | .global stat 6 | 7 | stat: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_stat 10 | b _syscall 11 | 12 | .type stat,function 13 | .size stat,.-stat 14 | -------------------------------------------------------------------------------- /libc/arm/umask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_umask, 60 3 | 4 | .text 5 | .global umask 6 | 7 | umask: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_umask 10 | b _syscall 11 | 12 | .type umask,function 13 | .size umask,.-umask 14 | -------------------------------------------------------------------------------- /libc/arm/unshare.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_unshare, 337 3 | 4 | .text 5 | .global unshare 6 | 7 | unshare: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_unshare 10 | b _syscall 11 | 12 | .type unshare,function 13 | .size unshare,.-unshare 14 | -------------------------------------------------------------------------------- /libc/arm/vfork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_vfork, 190 3 | 4 | .text 5 | .global vfork 6 | 7 | vfork: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_vfork 10 | b _syscall 11 | 12 | .type vfork,function 13 | .size vfork,.-vfork 14 | -------------------------------------------------------------------------------- /libc/arm/waitpid.s: -------------------------------------------------------------------------------- 1 | # This could have been just 2 | # mov r3, #0 3 | # b wait4 4 | # as it is done in dietlibc, but the thing is, we don't really need wait4. 5 | 6 | .equ NR_wait4, 114 7 | 8 | .text 9 | .align 4 10 | .global waitpid 11 | 12 | waitpid: 13 | mov r3, #0 14 | #wait4: 15 | stmfd sp!,{r4,r5,r7,lr} 16 | ldr r4, [sp,#16] 17 | ldr r5, [sp,#20] 18 | ldr r7, =NR_wait4 19 | b _syscall 20 | 21 | .type waitpid,function 22 | .size waitpid,.-waitpid 23 | -------------------------------------------------------------------------------- /libc/arm/write.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_write, 4 3 | 4 | .text 5 | .global write 6 | 7 | write: 8 | stmfd sp!,{r4,r5,r7,lr} 9 | ldr r7, =NR_write 10 | b _syscall 11 | 12 | .type write,function 13 | .size write,.-write 14 | -------------------------------------------------------------------------------- /libc/arm64/README: -------------------------------------------------------------------------------- 1 | ARMv8 64bit mode, aka Aarch64. 2 | 3 | Toolchains (gcc) prefer aarch64-* while linux kernel uses arm64 4 | for arch name. Since regular 32-bit ARM (aka Aarch32) files are 5 | in arm/ directory, this one is arm64/ for consistency. 6 | The name arm32 gets reserved for Aarch64 with short pointers. 7 | 8 | 9 | ABI is nice and uniform: 10 | 11 | Syscall x8 (x0, x1, x2, x3, x4, x5) -> x0 12 | Function (x0, x1, x2, x3, x4, x5) -> x0 13 | 14 | Stack interaction is not needed at all, parameters are passed 15 | in registers and ret handles lr/pc stuff. 16 | 17 | ARM64 uses asm-generic syscall numbers, with non-flagged 18 | syscalls being deprecated in favor of flagged ones. 19 | (waitpid <- wait4, sigaction <- rt_sigaction, open <- openat etc) 20 | TODO: implement fork <- clone, and document them or something. 21 | -------------------------------------------------------------------------------- /libc/arm64/_start.s: -------------------------------------------------------------------------------- 1 | .equ NR_exit, 93 2 | 3 | .data 4 | 5 | environ: .quad 0 6 | 7 | .type environ,object 8 | .size environ,.-environ 9 | 10 | 11 | .text 12 | .align 4 13 | 14 | .global _start 15 | .global _exit 16 | .global environ 17 | 18 | _start: 19 | mov x30, #0 /* LR */ 20 | mov x29, sp /* FP */ 21 | 22 | ldr x0, [sp] /* argc */ 23 | add x1, sp, #8 /* argv */ 24 | ldr x3, =environ 25 | add x2, x1, x0, lsl #3 /* &argv[argc] */ 26 | add x2, x2, #8 /* envp */ 27 | str x2, [x3, #0] /* environ = envp */ 28 | 29 | bl main 30 | 31 | _exit: 32 | mov x8, #NR_exit 33 | svc 0 34 | hlt 0 /* halt and catch fire */ 35 | 36 | .type _start,function 37 | .size _start,_exit-_start 38 | 39 | .type _exit,function 40 | .size _exit,.-_exit 41 | -------------------------------------------------------------------------------- /libc/arm64/_syscall.s: -------------------------------------------------------------------------------- 1 | .data 2 | .global errno 3 | 4 | errno: .word 0 5 | 6 | .type errno,object 7 | .size errno,.-errno 8 | 9 | 10 | .text 11 | .align 4 12 | 13 | .global _syscall 14 | 15 | _syscall: 16 | svc 0 17 | 18 | add w1, w0, #0x1, lsl #12 19 | cmp w1, #0xfff 20 | b.ls 1f 21 | ret /* no error */ 22 | 23 | 1: adr x1, errno 24 | neg w0, w0 25 | str w0, [x1] 26 | mov x0, #-1 27 | ret /* error */ 28 | 29 | .size _syscall,.-_syscall 30 | .type _syscall,function 31 | -------------------------------------------------------------------------------- /libc/arm64/_syscall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script makes an .s file for a simple syscall 4 | # "Simple" means "requires no argument mangling", i.e. libc header 5 | # prototype matches the actual Linux syscall arguments. 6 | # 7 | # For syscalls that do require mangling, resulting file can be used 8 | # as a template. 9 | # 10 | # See README for the list of non-simple syscalls. 11 | 12 | die() { echo "$@" >&2; exit 1; } 13 | 14 | syscall="$1" 15 | test -z "$syscall" && die "usage: $0 syscall-name" 16 | 17 | nr=$(grep "#define __NR_$syscall\s" bits/syscall.h | sed -e "s/^.*__NR_$syscall\s\+//") 18 | test -z "$nr" && die "Can't find $syscall in bits/syscall.h" 19 | 20 | cat < 5 | 6 | #define DT_UNKNOWN 0 7 | #define DT_FIFO 1 8 | #define DT_CHR 2 9 | #define DT_DIR 4 10 | #define DT_BLK 6 11 | #define DT_REG 8 12 | #define DT_LNK 10 13 | #define DT_SOCK 12 14 | #define DT_WHT 14 15 | 16 | struct dirent64 { 17 | uint64_t d_ino; 18 | int64_t d_off; 19 | uint16_t d_reclen; 20 | unsigned char d_type; 21 | char d_name[256]; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/arm64/bits/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_FCNTL_H 2 | #define BITS_FCNTL_H 3 | 4 | /* These are pretty much standard */ 5 | #define O_RDONLY 00 6 | #define O_WRONLY 01 7 | #define O_RDWR 02 8 | 9 | /* These are NOT! */ 10 | #define O_CREAT 0100 /* not fcntl */ 11 | #define O_EXCL 0200 /* not fcntl */ 12 | #define O_NOCTTY 0400 /* not fcntl */ 13 | #define O_TRUNC 01000 /* not fcntl */ 14 | #define O_APPEND 02000 15 | #define O_NONBLOCK 04000 16 | #define O_DIRECTORY 040000 /* must be a directory */ 17 | #define O_NOFOLLOW 0100000 /* don't follow links */ 18 | #define O_DIRECT 0200000 /* direct disk access hint - currently ignored */ 19 | #define O_LARGEFILE 0400000 20 | #define O_NOATIME 01000000 21 | #define O_CLOEXEC 02000000 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libc/arm64/bits/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_IOCTL_H 2 | #define BITS_IOCTL_H 3 | 4 | #define TIOCSCTTY 0x540E 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/arm64/bits/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_LIMITS_H 2 | #define BITS_LIMITS_H 3 | 4 | #define __WORDSIZE 64 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/arm64/bits/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_MMAN_H 2 | #define BITS_MMAN_H 3 | 4 | #define MREMAP_MAYMOVE 1UL 5 | #define MREMAP_FIXED 2UL 6 | 7 | #define PROT_READ 0x1 /* page can be read */ 8 | #define PROT_WRITE 0x2 /* page can be written */ 9 | #define PROT_EXEC 0x4 /* page can be executed */ 10 | #define PROT_NONE 0x0 /* page can not be accessed */ 11 | 12 | #define MAP_SHARED 0x01 /* Share changes */ 13 | #define MAP_PRIVATE 0x02 /* Changes are private */ 14 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ 15 | 16 | #define MAP_FAILED ((void *) -1) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/arm64/bits/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_POLL_H 2 | #define SYS_POLL_H 3 | 4 | #define POLLIN (1<<0) 5 | #define POLLPRI (1<<1) 6 | #define POLLOUT (1<<2) 7 | #define POLLERR (1<<3) 8 | #define POLLHUP (1<<4) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/arm64/bits/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_SOCKET_H 2 | #define BITS_SOCKET_H 3 | 4 | #define AF_UNIX 1 5 | 6 | #define SOCK_STREAM (1<<0) 7 | #define SOCK_DGRAM (1<<1) 8 | #define SOCK_NONBLOCK (1<<11) 9 | #define SOCK_CLOEXEC (1<<19) 10 | 11 | #define SOL_SOCKET 1 12 | #define SO_PEERCRED 17 13 | 14 | #define SHUT_RD 0 15 | #define SHUT_WR 1 16 | #define SHUT_RDWR 2 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/arm64/bits/types.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_TYPES_H 2 | #define BITS_TYPES_H 3 | 4 | typedef signed char int8_t; 5 | typedef signed short int16_t; 6 | typedef int int32_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | 12 | typedef signed long int64_t; 13 | typedef unsigned long uint64_t; 14 | 15 | typedef unsigned long size_t; 16 | typedef signed long ssize_t; 17 | typedef signed long off_t; 18 | typedef signed long time_t; 19 | 20 | typedef int32_t pid_t; 21 | typedef uint32_t gid_t; 22 | typedef uint32_t uid_t; 23 | 24 | typedef uint32_t socklen_t; 25 | typedef uint16_t sa_family_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libc/arm64/chdir.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chdir, 49 3 | 4 | .text 5 | .global chdir 6 | 7 | chdir: 8 | mov x8, NR_chdir 9 | b _syscall 10 | 11 | .type chdir,function 12 | .size chdir,.-chdir 13 | -------------------------------------------------------------------------------- /libc/arm64/chroot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chroot, 51 3 | 4 | .text 5 | .global chroot 6 | 7 | chroot: 8 | mov x8, NR_chroot 9 | b _syscall 10 | 11 | .type chroot,function 12 | .size chroot,.-chroot 13 | -------------------------------------------------------------------------------- /libc/arm64/clock_gettime.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_clock_gettime, 113 3 | 4 | .text 5 | .global clock_gettime 6 | 7 | clock_gettime: 8 | mov x8, NR_clock_gettime 9 | b _syscall 10 | 11 | .type clock_gettime,function 12 | .size clock_gettime,.-clock_gettime 13 | -------------------------------------------------------------------------------- /libc/arm64/close.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_close, 57 3 | 4 | .text 5 | .global close 6 | 7 | close: 8 | mov x8, NR_close 9 | b _syscall 10 | 11 | .type close,function 12 | .size close,.-close 13 | -------------------------------------------------------------------------------- /libc/arm64/connect.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_connect, 203 3 | 4 | .text 5 | .global connect 6 | 7 | connect: 8 | mov x8, NR_connect 9 | b _syscall 10 | 11 | .type connect,function 12 | .size connect,.-connect 13 | -------------------------------------------------------------------------------- /libc/arm64/dup2.s: -------------------------------------------------------------------------------- 1 | .equ NR_dup3, 24 2 | 3 | .text 4 | .global dup2 5 | 6 | dup2: 7 | mov x2, #0 8 | ldr x8, =NR_dup3 9 | b _syscall 10 | 11 | .type dup2,function 12 | .size dup2,.-dup2 13 | -------------------------------------------------------------------------------- /libc/arm64/execve.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_execve, 221 3 | 4 | .text 5 | .global execve 6 | 7 | execve: 8 | mov x8, NR_execve 9 | b _syscall 10 | 11 | .type execve,function 12 | .size execve,.-execve 13 | -------------------------------------------------------------------------------- /libc/arm64/fcntl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fcntl, 25 3 | 4 | .text 5 | .global fcntl 6 | 7 | fcntl: 8 | mov x8, NR_fcntl 9 | b _syscall 10 | 11 | .type fcntl,function 12 | .size fcntl,.-fcntl 13 | -------------------------------------------------------------------------------- /libc/arm64/fork.s: -------------------------------------------------------------------------------- 1 | /* NR_fork is listed as deprecated on newer arches including arm64 */ 2 | .equ NR_clone, 220 3 | .equ SIGCHLD, 17 4 | 5 | .text 6 | .global fork 7 | 8 | fork: 9 | mov x0, SIGCHLD /* flags */ 10 | mov x1, 0 /* child stack */ 11 | mov x2, 0 /* ptid */ 12 | mov x3, 0 /* pt_regs */ 13 | mov x4, 0 /* ctid */ 14 | mov x8, NR_clone 15 | b _syscall 16 | 17 | .type fork,function 18 | .size fork,.-fork 19 | -------------------------------------------------------------------------------- /libc/arm64/fstat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fstat, 80 3 | 4 | .text 5 | .global fstat 6 | 7 | fstat: 8 | mov x8, NR_fstat 9 | b _syscall 10 | 11 | .type fstat,function 12 | .size fstat,.-fstat 13 | -------------------------------------------------------------------------------- /libc/arm64/getdents64.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getdents64, 61 3 | 4 | .text 5 | .global getdents64 6 | 7 | getdents64: 8 | mov x8, NR_getdents64 9 | b _syscall 10 | 11 | .type getdents64,function 12 | .size getdents64,.-getdents64 13 | -------------------------------------------------------------------------------- /libc/arm64/getpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getpid, 172 3 | 4 | .text 5 | .global getpid 6 | 7 | getpid: 8 | mov x8, NR_getpid 9 | b _syscall 10 | 11 | .type getpid,function 12 | .size getpid,.-getpid 13 | -------------------------------------------------------------------------------- /libc/arm64/getsockopt.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getsockopt, 209 3 | 4 | .text 5 | .global getsockopt 6 | 7 | getsockopt: 8 | mov x8, NR_getsockopt 9 | b _syscall 10 | 11 | .type getsockopt,function 12 | .size getsockopt,.-getsockopt 13 | -------------------------------------------------------------------------------- /libc/arm64/getuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getuid, 174 3 | 4 | .text 5 | .global getuid 6 | 7 | getuid: 8 | mov x8, NR_getuid 9 | b _syscall 10 | 11 | .type getuid,function 12 | .size getuid,.-getuid 13 | -------------------------------------------------------------------------------- /libc/arm64/ioctl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_ioctl, 29 3 | 4 | .text 5 | .global ioctl 6 | 7 | ioctl: 8 | mov x8, NR_ioctl 9 | b _syscall 10 | 11 | .type ioctl,function 12 | .size ioctl,.-ioctl 13 | -------------------------------------------------------------------------------- /libc/arm64/kill.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_kill, 129 3 | 4 | .text 5 | .global kill 6 | 7 | kill: 8 | mov x8, NR_kill 9 | b _syscall 10 | 11 | .type kill,function 12 | .size kill,.-kill 13 | -------------------------------------------------------------------------------- /libc/arm64/listen.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_listen, 201 3 | 4 | .text 5 | .global listen 6 | 7 | listen: 8 | mov x8, NR_listen 9 | b _syscall 10 | 11 | .type listen,function 12 | .size listen,.-listen 13 | -------------------------------------------------------------------------------- /libc/arm64/mmap.s: -------------------------------------------------------------------------------- 1 | .equ NR_mmap2, 222 2 | 3 | .text 4 | .global mmap 5 | 6 | mmap: 7 | mov x8, NR_mmap2 8 | b _syscall 9 | 10 | .type mmap,function 11 | .size mmap,.-mmap 12 | -------------------------------------------------------------------------------- /libc/arm64/mremap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mremap, 216 3 | 4 | .text 5 | .global mremap 6 | 7 | mremap: 8 | mov x8, NR_mremap 9 | b _syscall 10 | 11 | .type mremap,function 12 | .size mremap,.-mremap 13 | -------------------------------------------------------------------------------- /libc/arm64/munmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_munmap, 215 3 | 4 | .text 5 | .global munmap 6 | 7 | munmap: 8 | mov x8, NR_munmap 9 | b _syscall 10 | 11 | .type munmap,function 12 | .size munmap,.-munmap 13 | -------------------------------------------------------------------------------- /libc/arm64/nanosleep.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_nanosleep, 101 3 | 4 | .text 5 | .global nanosleep 6 | 7 | nanosleep: 8 | mov x8, NR_nanosleep 9 | b _syscall 10 | 11 | .type nanosleep,function 12 | .size nanosleep,.-nanosleep 13 | -------------------------------------------------------------------------------- /libc/arm64/open.s: -------------------------------------------------------------------------------- 1 | .equ NR_openat, 56 2 | .equ AT_FDCWD, -100 3 | 4 | .text 5 | .global open 6 | 7 | open: 8 | mov x3, x2 /* never used in init btw */ 9 | mov x2, x1 10 | mov x1, x0 11 | mov x0, AT_FDCWD 12 | mov x8, NR_openat 13 | b _syscall 14 | 15 | .type stat,function 16 | -------------------------------------------------------------------------------- /libc/arm64/ppoll.s: -------------------------------------------------------------------------------- 1 | .equ NR_ppoll, 73 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global ppoll 6 | 7 | ppoll: 8 | mov x4, sizeof_sigset_t 9 | mov x8, NR_ppoll 10 | b _syscall 11 | 12 | .type ppoll,function 13 | .size ppoll,.-ppoll 14 | -------------------------------------------------------------------------------- /libc/arm64/read.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_read, 63 3 | 4 | .text 5 | .global read 6 | 7 | read: 8 | mov x8, NR_read 9 | b _syscall 10 | 11 | .type read,function 12 | .size read,.-read 13 | -------------------------------------------------------------------------------- /libc/arm64/reboot.s: -------------------------------------------------------------------------------- 1 | .equ NR_reboot, 142 2 | .equ LINUX_REBOOT_MAGIC1, 0xfee1dead 3 | .equ LINUX_REBOOT_MAGIC2, 0x28121969 4 | /* ^ Torvalds' birthday, who could have thought */ 5 | .text 6 | .global reboot 7 | 8 | reboot: 9 | mov x2, x0 10 | ldr x0, =LINUX_REBOOT_MAGIC1 11 | ldr x1, =LINUX_REBOOT_MAGIC2 12 | mov x8, NR_reboot 13 | b _syscall 14 | 15 | .type reboot,function 16 | .size reboot,.-reboot 17 | -------------------------------------------------------------------------------- /libc/arm64/send.s: -------------------------------------------------------------------------------- 1 | .equ NR_sendto, 206 2 | 3 | .text 4 | .global send 5 | 6 | send: 7 | mov x4, #0 8 | mov x5, #0 9 | ldr x8, =NR_sendto 10 | b _syscall 11 | 12 | .type send,function 13 | .size send,.-send 14 | -------------------------------------------------------------------------------- /libc/arm64/setfsgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsgid, 152 3 | 4 | .text 5 | .global setfsgid 6 | 7 | setfsgid: 8 | mov x8, NR_setfsgid 9 | b _syscall 10 | 11 | .type setfsgid,function 12 | .size setfsgid,.-setfsgid 13 | -------------------------------------------------------------------------------- /libc/arm64/setfsuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsuid, 151 3 | 4 | .text 5 | .global setfsuid 6 | 7 | setfsuid: 8 | mov x8, NR_setfsuid 9 | b _syscall 10 | 11 | .type setfsuid,function 12 | .size setfsuid,.-setfsuid 13 | -------------------------------------------------------------------------------- /libc/arm64/setitimer.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setitimer, 103 3 | 4 | .text 5 | .global setitimer 6 | 7 | setitimer: 8 | mov x8, NR_setitimer 9 | b _syscall 10 | 11 | .type setitimer,function 12 | .size setitimer,.-setitimer 13 | -------------------------------------------------------------------------------- /libc/arm64/setpriority.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setpriority, 140 3 | 4 | .text 5 | .global setpriority 6 | 7 | setpriority: 8 | mov x8, NR_setpriority 9 | b _syscall 10 | 11 | .type setpriority,function 12 | .size setpriority,.-setpriority 13 | -------------------------------------------------------------------------------- /libc/arm64/setresgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresgid, 149 3 | 4 | .text 5 | .global setresgid 6 | 7 | setresgid: 8 | mov x8, NR_setresgid 9 | b _syscall 10 | 11 | .type setresgid,function 12 | .size setresgid,.-setresgid 13 | -------------------------------------------------------------------------------- /libc/arm64/setresuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresuid, 147 3 | 4 | .text 5 | .global setresuid 6 | 7 | setresuid: 8 | mov x8, NR_setresuid 9 | b _syscall 10 | 11 | .type setresuid,function 12 | .size setresuid,.-setresuid 13 | -------------------------------------------------------------------------------- /libc/arm64/setrlimit.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setrlimit, 164 3 | 4 | .text 5 | .global setrlimit 6 | 7 | setrlimit: 8 | mov x8, NR_setrlimit 9 | b _syscall 10 | 11 | .type setrlimit,function 12 | .size setrlimit,.-setrlimit 13 | -------------------------------------------------------------------------------- /libc/arm64/setsid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setsid, 157 3 | 4 | .text 5 | .global setsid 6 | 7 | setsid: 8 | mov x8, NR_setsid 9 | b _syscall 10 | 11 | .type setsid,function 12 | .size setsid,.-setsid 13 | -------------------------------------------------------------------------------- /libc/arm64/shutdown.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_shutdown, 210 3 | 4 | .text 5 | .global shutdown 6 | 7 | shutdown: 8 | mov x8, NR_shutdown 9 | b _syscall 10 | 11 | .type shutdown,function 12 | .size shutdown,.-shutdown 13 | -------------------------------------------------------------------------------- /libc/arm64/sigaction.s: -------------------------------------------------------------------------------- 1 | .equ NR_rt_sigaction, 134 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global sigaction 6 | 7 | /* sigaction(x0=signum, x1=*act, x2=*old) */ 8 | /* rt_sigaction(x0=signum, x1=*act, x2=*old, x3=nr) */ 9 | sigaction: 10 | mov x8, NR_rt_sigaction 11 | mov x3, sizeof_sigset_t 12 | b _syscall 13 | 14 | .type sigaction,function 15 | .size sigaction,.-sigaction 16 | -------------------------------------------------------------------------------- /libc/arm64/sigprocmask.s: -------------------------------------------------------------------------------- 1 | .equ NR_rt_sigprocmask, 135 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global sigprocmask 6 | 7 | sigprocmask: 8 | mov x3, sizeof_sigset_t 9 | mov x8, NR_rt_sigprocmask 10 | b _syscall 11 | 12 | .type sigprocmask,function 13 | .size sigprocmask,.-sigprocmask 14 | -------------------------------------------------------------------------------- /libc/arm64/socket.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_socket, 198 3 | 4 | .text 5 | .global socket 6 | 7 | socket: 8 | mov x8, NR_socket 9 | b _syscall 10 | 11 | .type socket,function 12 | .size socket,.-socket 13 | -------------------------------------------------------------------------------- /libc/arm64/stat.s: -------------------------------------------------------------------------------- 1 | # only used in tests btw 2 | .equ NR_fstatat, 79 3 | .equ AT_FDCWD, -100 4 | 5 | .text 6 | .global stat 7 | 8 | stat: 9 | mov x2, x1 10 | mov x1, x0 11 | mov x0, AT_FDCWD 12 | mov x3, #0 13 | mov x8, NR_fstatat 14 | b _syscall 15 | 16 | .type stat,function 17 | -------------------------------------------------------------------------------- /libc/arm64/umask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_umask, 166 3 | 4 | .text 5 | .global umask 6 | 7 | umask: 8 | mov x8, NR_umask 9 | b _syscall 10 | 11 | .type umask,function 12 | .size umask,.-umask 13 | -------------------------------------------------------------------------------- /libc/arm64/unshare.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_unshare, 97 3 | 4 | .text 5 | .global unshare 6 | 7 | unshare: 8 | mov x8, NR_unshare 9 | b _syscall 10 | 11 | .type unshare,function 12 | .size unshare,.-unshare 13 | -------------------------------------------------------------------------------- /libc/arm64/vfork.s: -------------------------------------------------------------------------------- 1 | /* NR_vfork is listed as deprecated on newer arches including arm64 */ 2 | .equ NR_clone, 220 3 | .equ SIGCHLD, 17 4 | .equ CLONE_VM, 0x00000100 5 | .equ CLONE_VFORK, 0x00004000 6 | 7 | .text 8 | .global vfork 9 | 10 | vfork: 11 | mov x0, (CLONE_VM | CLONE_VFORK | SIGCHLD) 12 | mov x1, 0 /* child stack */ 13 | mov x2, 0 /* ptid */ 14 | mov x3, 0 /* ctid */ 15 | mov x4, 0 /* pt_regs */ 16 | mov x8, NR_clone 17 | b _syscall 18 | 19 | .type vfork,function 20 | .size vfork,.-vfork 21 | -------------------------------------------------------------------------------- /libc/arm64/waitpid.s: -------------------------------------------------------------------------------- 1 | .equ NR_wait4, 260 2 | 3 | .text 4 | .global waitpid 5 | 6 | waitpid: 7 | mov x3, #0 8 | mov x8, NR_wait4 9 | b _syscall 10 | 11 | .type waitpid,function 12 | .size waitpid,.-waitpid 13 | -------------------------------------------------------------------------------- /libc/arm64/write.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_write, 64 3 | 4 | .text 5 | .global write 6 | 7 | write: 8 | mov x8, NR_write 9 | b _syscall 10 | 11 | .type write,function 12 | .size write,.-write 13 | -------------------------------------------------------------------------------- /libc/atoi.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int atoi(const char* s) 4 | { 5 | int v = 0; 6 | int m = 0; 7 | 8 | switch (*s) { 9 | case '-': m = 1; 10 | case '+': ++s; 11 | } 12 | while ((unsigned int) (*s - '0') < 10u) 13 | v = v*10 + (*(s++) - '0'); 14 | 15 | return m ? -v : v; 16 | } 17 | -------------------------------------------------------------------------------- /libc/getenv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char* getenv(const char *s) 5 | { 6 | unsigned int len; 7 | char** e; 8 | 9 | if(!environ || !s) 10 | return 0; 11 | 12 | len = strlen(s); 13 | for(e = environ; *e; e++) 14 | if((memcmp(*e, s, len) == 0) && ((*e)[len] == '=')) 15 | return (*e) + len + 1; 16 | 17 | return NULL; 18 | } 19 | -------------------------------------------------------------------------------- /libc/include/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRENT_H 2 | #define DIRENT_H 3 | 4 | #include 5 | 6 | int getdents64(int fd, struct dirent64 *dirp, unsigned int count); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libc/include/errno.h: -------------------------------------------------------------------------------- 1 | #ifndef ERRNO_H 2 | #define ERRNO_H 3 | 4 | #include 5 | 6 | extern int errno; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libc/include/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef FCNTL_H 2 | #define FCNTL_H 3 | 4 | #include 5 | 6 | #define F_GETFD 1 /* Get file descriptor flags. */ 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libc/include/inttypes.h: -------------------------------------------------------------------------------- 1 | #ifndef INTTYPES_H 2 | #define INTTYPES_H 3 | 4 | #include 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /libc/include/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIMITS_H 2 | #define LIMITS_H 3 | 4 | #include 5 | 6 | #define PATH_MAX 4095 /* # chars in a path name */ 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libc/include/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef POLL_H 2 | #define POLL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | struct pollfd { 9 | int fd; 10 | short events; 11 | short revents; 12 | }; 13 | 14 | int ppoll(struct pollfd *fds, unsigned int nfds, const struct timespec *timeout, const sigset_t *sigmask); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/include/sched.h: -------------------------------------------------------------------------------- 1 | #ifndef SCHED_H 2 | #define SCHED_H 3 | 4 | #define CLONE_FS 0x00000200 5 | #define CLONE_FILES 0x00000400 6 | #define CLONE_NEWNS 0x00020000 7 | #define CLONE_SYSVSEM 0x00040000 8 | #define CLONE_NEWUTS 0x04000000 9 | #define CLONE_NEWIPC 0x08000000 10 | #define CLONE_NEWUSER 0x10000000 11 | #define CLONE_NEWPID 0x20000000 12 | #define CLONE_NEWNET 0x40000000 13 | 14 | int unshare(int flags); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/include/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNAL_H 2 | #define SIGNAL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int kill(pid_t pid, int sig); 9 | int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); 10 | 11 | int sigemptyset(sigset_t *set); 12 | int sigfillset(sigset_t *set); 13 | int sigaddset(sigset_t *set, int signum); 14 | int sigdelset(sigset_t *set, int signum); 15 | int sigismember(const sigset_t *set, int signo); 16 | int sigsuspend(const sigset_t *mask); 17 | int sigpending(sigset_t *set); 18 | int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libc/include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef STDARG_H 2 | #define STDARG_H 3 | 4 | #ifdef va_end 5 | /* it's already defined */ 6 | #elif (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) 7 | typedef __builtin_va_list va_list; 8 | #define va_start(v,l) __builtin_va_start((v),(l)) 9 | #define va_end __builtin_va_end 10 | #define va_arg __builtin_va_arg 11 | #define __va_copy(d,s) __builtin_va_copy((d),(s)) 12 | #else 13 | #error No stdarg.h found for you target architecture 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef STDDEF_H 2 | #define STDDEF_H 3 | 4 | #define NULL ((void*)0) 5 | 6 | #include 7 | 8 | #define offsetof(type,member) ((size_t) &((type*)0)->member) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/include/stdint.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef STDIO_H 2 | #define STDIO_H 3 | 4 | #include 5 | #include 6 | 7 | int printf(const char *format, ...) __attribute__((__format__(__printf__,1,2))); 8 | int snprintf(char *str, size_t size, const char *format, ...) __attribute__((__format__(__printf__,3,4))); 9 | int vsnprintf(char *str, size_t size, const char *format, va_list ap) __attribute__((__format__(__printf__,3,0))); 10 | int vprintf(const char *format, va_list ap) __attribute__((__format__(__printf__,1,0))); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /libc/include/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef STDLIB_H 2 | #define STDLIB_H 3 | 4 | #include 5 | #include 6 | 7 | extern char **environ; 8 | 9 | int atoi(const char *nptr); 10 | 11 | char *getenv(const char *name) pure; 12 | int putenv(const char *string); 13 | int setenv(const char *name, const char *value, int overwrite); 14 | 15 | #ifdef __GNUC__ 16 | #define alloca(x) __builtin_alloca(x) 17 | #else 18 | void *alloca(size_t size); 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /libc/include/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_CDEFS_H 2 | #define SYS_CDEFS_H 3 | 4 | #define pure __attribute__ ((__pure__)) 5 | #define nonnull(params) __attribute__ ((__nonnull__ params)) 6 | #define restrict __restrict__ 7 | 8 | #if __GNUC__ < 3 9 | #define likely(foo) (foo) 10 | #define unlikely(foo) (foo) 11 | #else 12 | #define likely(foo) __builtin_expect((foo),1) 13 | #define unlikely(foo) __builtin_expect((foo),0) 14 | #endif 15 | 16 | /* idea for these macros taken from Linux kernel */ 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/include/sys/fsuid.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_FSUID_H 2 | #define SYS_FSUID_H 3 | 4 | #include 5 | 6 | int setfsuid(uid_t uid); 7 | int setfsgid(gid_t gid); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libc/include/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_IOCTL_H 2 | #define SYS_IOCTL_H 3 | 4 | #include 5 | 6 | int ioctl(int d, long int request, ...); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libc/include/sys/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_MMAN_H 2 | #define SYS_MMAN_H 3 | 4 | #include 5 | 6 | void *mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset); 7 | void *mremap (void *addr, size_t old_len, size_t new_len, int flags, ...); 8 | int munmap (void *addr, size_t len); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/include/sys/poll.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsv/sninit/ea73a7e2d8fa4a162beade0f4196455974468e81/libc/include/sys/poll.h -------------------------------------------------------------------------------- /libc/include/sys/reboot.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_REBOOT_H 2 | #define SYS_REBOOT_H 3 | 4 | #define RB_AUTOBOOT 0x01234567 5 | #define RB_HALT_SYSTEM 0xcdef0123 6 | #define RB_ENABLE_CAD 0x89abcdef 7 | #define RB_DISABLE_CAD 0 8 | #define RB_POWER_OFF 0x4321fedc 9 | 10 | int reboot (int flag); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /libc/include/sys/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_RESOURCE_H 2 | #define SYS_RESOURCE_H 3 | 4 | #include 5 | 6 | #define PRIO_PROCESS 0 7 | #define PRIO_PGRP 1 8 | #define PRIO_USER 2 9 | 10 | struct rlimit { 11 | unsigned long rlim_cur; 12 | unsigned long rlim_max; 13 | }; 14 | 15 | typedef int id_t; 16 | 17 | int getrlimit (int resource, struct rlimit *rlim); 18 | int setrlimit (int resource, const struct rlimit *rlim); 19 | 20 | int getpriority(int which, id_t who); 21 | int setpriority(int which, id_t who, int prio); 22 | 23 | typedef unsigned long rlim_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libc/include/sys/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef SOCKET_H 2 | #define SOCKET_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | struct sockaddr { 10 | sa_family_t sa_family; 11 | char sa_data[14]; 12 | }; 13 | 14 | struct ucred { 15 | pid_t pid; 16 | uid_t uid; 17 | gid_t gid; 18 | }; 19 | 20 | int socket(int domain, int type, int protocol); 21 | int accept(int s, struct sockaddr *addr, socklen_t *addrlen); 22 | int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen); 23 | int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen); 24 | int listen(int s, int backlog); 25 | int shutdown(int s, int how); 26 | 27 | int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libc/include/sys/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_STAT_H 2 | #define SYS_STAT_H 3 | 4 | #include 5 | 6 | int stat(const char* filename, struct stat *buf); 7 | int fstat(int fd, struct stat *buf); 8 | int umask(int mask); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/include/sys/syscall.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/sys/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #include 5 | 6 | typedef int32_t clockid_t; 7 | typedef signed long suseconds_t; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libc/include/sys/un.h: -------------------------------------------------------------------------------- 1 | #ifndef UN_H 2 | #define UN_H 3 | 4 | #include 5 | 6 | #define UNIX_PATH_MAX 108 7 | 8 | struct sockaddr_un { 9 | sa_family_t sun_family; /* AF_UNIX */ 10 | char sun_path[UNIX_PATH_MAX]; /* pathname */ 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libc/include/sys/wait.h: -------------------------------------------------------------------------------- 1 | #ifndef WAIT_H 2 | #define WAIT_H 3 | 4 | #include 5 | 6 | #define WNOHANG 1 /* Don't block waiting. */ 7 | #define WUNTRACED 2 /* Report stopped child. */ 8 | #define WCONTINUED 8 /* Report continued child. */ 9 | 10 | #define WEXITSTATUS(status) (((status) & 0xFF00) >> 8) 11 | #define WTERMSIG(status) ((status) & 0x7F) 12 | 13 | #define WIFEXITED(status) (WTERMSIG(status) == 0) 14 | #define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status)) 15 | #define WIFSTOPPED(status) (((status) & 0xFF) == 0x7F) 16 | #define WIFCONTINUED(status) ((status) == 0xFFFF) 17 | 18 | pid_t waitpid(pid_t pid, int *status, int options); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libc/include/time.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* These seem to be arch-independent, so let's put them 5 | here instead of using ARCH/bits/time.h */ 6 | #define CLOCK_REALTIME 0 7 | #define CLOCK_MONOTONIC 1 8 | #define CLOCK_BOOTTIME 7 9 | 10 | struct tm* gmtime_r(const time_t* t, struct tm* r); 11 | int clock_gettime(clockid_t clk_id, struct timespec *tp); 12 | int nanosleep(const struct timespec *req, struct timespec *rem); 13 | -------------------------------------------------------------------------------- /libc/libtest/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile should not be used. It is here merely to make sure 2 | # make (something).o uses the right CFLAGS, for quick-edit syntax checks. 3 | 4 | /=../../ 5 | include $/config.mk 6 | CFLAGS := $(filter-out -flto,$(CFLAGS)) 7 | 8 | default: 9 | @echo ERROR: To build libc, run make libc.a from the top directory. 10 | @false 11 | -------------------------------------------------------------------------------- /libc/libtest/README: -------------------------------------------------------------------------------- 1 | These are libc routines only used for tests (the stuff in test/ directory). 2 | To keep things clear, they are isolated from the "primary" libc parts 3 | which go into the final executables. 4 | 5 | The only exception is syscall() which is arch-specific and resides in resp. 6 | arch directories despite not being used anywhere in the init itself. 7 | -------------------------------------------------------------------------------- /libc/libtest/putchar.c: -------------------------------------------------------------------------------- 1 | /* gcc does sometimes "optimize" printf calls by replacing them with putchar or puts */ 2 | 3 | #include 4 | 5 | int putchar(int c) 6 | { 7 | char s = (char) c; 8 | return write(1, &s, 1); 9 | } 10 | -------------------------------------------------------------------------------- /libc/libtest/puts.c: -------------------------------------------------------------------------------- 1 | /* gcc does sometimes "optimize" printf calls by replacing them with putchar or puts */ 2 | 3 | #include 4 | #include 5 | 6 | int puts(char* s) 7 | { 8 | write(1, s, strlen(s)); 9 | write(1, "\n", 1); 10 | return 1; 11 | } 12 | -------------------------------------------------------------------------------- /libc/libtest/sleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sleep(int sec) 5 | { 6 | struct timespec ts = { sec, 0 }; 7 | 8 | return nanosleep(&ts, NULL); 9 | } 10 | -------------------------------------------------------------------------------- /libc/libtest/strerror.c: -------------------------------------------------------------------------------- 1 | extern const char* sys_errlist[]; 2 | extern const int sys_nerr; 3 | 4 | /* Standard prototype for strerror is char*(int), and sys_errlist is 5 | const char*[]. Clang knows it and complains if strerror is declared 6 | as const char*(int) as it should be, despite the lack of const 7 | in the prototype being apparently a remnant of the days when const 8 | wasn't even a keyword. 9 | 10 | This is bad and clang should feel bad. 11 | 12 | Honoring the fossils, we hereby declare char* strerror BUT we keep in mind 13 | it is in fact const char* strerror. */ 14 | 15 | char* strerror(int err) 16 | { 17 | if(err >= 0 && err < sys_nerr) 18 | return (char*)sys_errlist[err]; 19 | else 20 | return "unknown error"; 21 | } 22 | -------------------------------------------------------------------------------- /libc/memcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int memcmp(const void *dst, const void *src, size_t count) 5 | { 6 | int r; 7 | const unsigned char* d = dst; 8 | const unsigned char* s = src; 9 | 10 | for(; count--; d++, s++) 11 | if(unlikely(r = (*d - *s))) 12 | return r; 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /libc/memcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void* memcpy(void* dst, const void* src, size_t n) 4 | { 5 | void* r = dst; 6 | char* d = dst; 7 | const char* s = src; 8 | 9 | while(n--) *(d++) = *(s++); 10 | 11 | return r; 12 | } 13 | -------------------------------------------------------------------------------- /libc/memmove.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void* memmove(void* dst, const void* src, unsigned long n) 4 | { 5 | if(dst < src) 6 | return memcpy(dst, src, n); 7 | else if(dst == src) 8 | return dst; 9 | 10 | void* r = dst; 11 | char* d = dst + n - 1; 12 | const char* s = src + n - 1; 13 | 14 | while(n--) *(d--) = *(s--); 15 | 16 | return r; 17 | } 18 | -------------------------------------------------------------------------------- /libc/memset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void* memset(void* dst, int s, size_t count) 5 | { 6 | char* a = dst; 7 | 8 | while(count--) 9 | *(a++) = s; 10 | 11 | return dst; 12 | } 13 | -------------------------------------------------------------------------------- /libc/mips/README: -------------------------------------------------------------------------------- 1 | The code assumes MIPS o32 ABI. 2 | Should work well in big- and little-endian with no changes. 3 | Will not work on n32 and n64 systems. 4 | 5 | MIPS o32 calling convention: 6 | 7 | 1 2 3 4 5 6 8 | Syscall v0 (a0, a1, a2, a3, [4], [5]) -> v0 9 | Function (a0, a1, a2, a3, [4], [5]) -> v0 [n] = n*4(sp) 10 | 11 | registers: v0 v1 a0 a1 a2 a3 ... sp 12 | 2 3 4 5 6 7 ... 29 13 | 14 | There are irregularities, like pipe(2) returning (v0, v1), 15 | but as far as sninit is concerned everything is neat and uniform, 16 | with functions and syscalls using exactly the same registers 17 | for their arguments. 18 | 19 | Note [4] and [5] are in fact 4 and 5 even though the first four 20 | arguments are passed in registers. 21 | -------------------------------------------------------------------------------- /libc/mips/_syscall.s: -------------------------------------------------------------------------------- 1 | .data 2 | .align 4 3 | .globl errno 4 | 5 | errno: .word 0 6 | 7 | .type errno,object 8 | .size errno,.-errno 9 | 10 | 11 | .text 12 | .align 2 13 | .set reorder 14 | 15 | .globl _syscall 16 | 17 | _syscall: 18 | beq $7, $0, ok 19 | sw $2, errno 20 | li $2, -1 21 | ok: jr $31 22 | 23 | .type _syscall,function 24 | .size _syscall,.-_syscall 25 | -------------------------------------------------------------------------------- /libc/mips/accept.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_accept, 4168 3 | 4 | .text 5 | .set reorder 6 | .global accept 7 | .ent accept 8 | 9 | accept: 10 | li $2, NR_accept 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end accept 16 | -------------------------------------------------------------------------------- /libc/mips/bind.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_bind, 4169 3 | 4 | .text 5 | .set reorder 6 | .global bind 7 | .ent bind 8 | 9 | bind: 10 | li $2, NR_bind 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end bind 16 | -------------------------------------------------------------------------------- /libc/mips/bits/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_DIRENT_H 2 | #define BITS_DIRENT_H 3 | 4 | #include 5 | 6 | #define DT_UNKNOWN 0 7 | #define DT_FIFO 1 8 | #define DT_CHR 2 9 | #define DT_DIR 4 10 | #define DT_BLK 6 11 | #define DT_REG 8 12 | #define DT_LNK 10 13 | #define DT_SOCK 12 14 | #define DT_WHT 14 15 | 16 | struct dirent64 { 17 | uint64_t d_ino; 18 | int64_t d_off; 19 | uint16_t d_reclen; 20 | unsigned char d_type; 21 | char d_name[256]; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/mips/bits/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_FCNTL_H 2 | #define BITS_FCNTL_H 3 | 4 | /* These are pretty much standard */ 5 | #define O_RDONLY 00 6 | #define O_WRONLY 01 7 | #define O_RDWR 02 8 | 9 | /* These are NOT! */ 10 | #define O_CREAT 0x0100 /* not fcntl */ 11 | #define O_CREAT 0x0100 /* not fcntl */ 12 | #define O_TRUNC 0x0200 /* not fcntl */ 13 | #define O_EXCL 0x0400 /* not fcntl */ 14 | #define O_NOCTTY 0x0800 /* not fcntl */ 15 | #define FASYNC 0x1000 /* fcntl, for BSD compatibility */ 16 | #define O_LARGEFILE 0x2000 /* allow large file opens - currently ignored */ 17 | #define O_DIRECT 0x8000 /* direct disk access hint - currently ignored */ 18 | #define O_DIRECTORY 0x10000 /* must be a directory */ 19 | #define O_NOFOLLOW 0x20000 /* don't follow links */ 20 | #define O_NOATIME 0x40000 21 | #define O_CLOEXEC 0x80000 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libc/mips/bits/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_IOCTL_H 2 | #define BITS_IOCTL_H 3 | 4 | /* This value is 0x540E for all arches *except* MIPS and Sparc */ 5 | #define TIOCSCTTY 0x5480 /* become controlling tty */ 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /libc/mips/bits/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_LIMITS_H 2 | #define BITS_LIMITS_H 3 | 4 | #define __WORDSIZE 32 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/mips/bits/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_MMAN_H 2 | #define BITS_MMAN_H 3 | 4 | #define MREMAP_MAYMOVE 1UL 5 | #define MREMAP_FIXED 2UL 6 | 7 | #define PROT_READ 0x1 /* page can be read */ 8 | #define PROT_WRITE 0x2 /* page can be written */ 9 | #define PROT_EXEC 0x4 /* page can be executed */ 10 | #define PROT_NONE 0x0 /* page can not be accessed */ 11 | 12 | #define MAP_SHARED 0x01 /* Share changes */ 13 | #define MAP_PRIVATE 0x02 /* Changes are private */ 14 | #define MAP_ANONYMOUS 0x0800 /* don't use a file (MIPS-specific) */ 15 | 16 | #define MAP_FAILED ((void *) -1) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/mips/bits/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_POLL_H 2 | #define SYS_POLL_H 3 | 4 | #define POLLIN (1<<0) 5 | #define POLLPRI (1<<1) 6 | #define POLLOUT (1<<2) 7 | #define POLLERR (1<<3) 8 | #define POLLHUP (1<<4) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/mips/bits/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_SOCKET_H 2 | #define BITS_SOCKET_H 3 | 4 | #define AF_UNIX 1 5 | 6 | #define SOCK_DGRAM (1<<0) /* MIPS! */ 7 | #define SOCK_STREAM (1<<1) /* (all other arches have it the other way around) */ 8 | #define SOCK_NONBLOCK (1<<7) /* MIPS! */ 9 | #define SOCK_CLOEXEC (1<<19) /* common value */ 10 | 11 | #define SO_PEERCRED 18 /* MIPS! */ 12 | #define SOL_SOCKET 0xffff /* MIPS! */ 13 | 14 | #define SHUT_RD 0 15 | #define SHUT_WR 1 16 | #define SHUT_RDWR 2 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/mips/bits/types.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_TYPES_H 2 | #define BITS_TYPES_H 3 | 4 | typedef signed char int8_t; 5 | typedef signed short int16_t; 6 | typedef int int32_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | 12 | typedef signed long long int64_t; 13 | typedef unsigned long long uint64_t; 14 | 15 | typedef unsigned int size_t; 16 | typedef signed long ssize_t; 17 | typedef signed long off_t; 18 | typedef signed long time_t; 19 | 20 | typedef int32_t pid_t; 21 | typedef int32_t gid_t; 22 | typedef int32_t uid_t; 23 | typedef unsigned long ino_t; 24 | 25 | typedef uint32_t socklen_t; 26 | typedef uint16_t sa_family_t; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libc/mips/chdir.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chdir, 4012 3 | 4 | .text 5 | .set reorder 6 | .global chdir 7 | .ent chdir 8 | 9 | chdir: 10 | li $2, NR_chdir 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end chdir 16 | -------------------------------------------------------------------------------- /libc/mips/chroot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chroot, 4061 3 | 4 | .text 5 | .set reorder 6 | .global chroot 7 | .ent chroot 8 | 9 | chroot: 10 | li $2, NR_chroot 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end chroot 16 | -------------------------------------------------------------------------------- /libc/mips/clock_gettime.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_clock_gettime, 4263 3 | 4 | .text 5 | .set reorder 6 | .global clock_gettime 7 | .ent clock_gettime 8 | 9 | clock_gettime: 10 | li $2, NR_clock_gettime 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end clock_gettime 16 | -------------------------------------------------------------------------------- /libc/mips/close.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_close, 4006 3 | 4 | .text 5 | .set reorder 6 | .global close 7 | .ent close 8 | 9 | close: 10 | li $2, NR_close 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end close 16 | -------------------------------------------------------------------------------- /libc/mips/connect.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_connect, 4170 3 | 4 | .text 5 | .set reorder 6 | .global connect 7 | .ent connect 8 | 9 | connect: 10 | li $2, NR_connect 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end connect 16 | -------------------------------------------------------------------------------- /libc/mips/dup2.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_dup2, 4063 3 | 4 | .text 5 | .set reorder 6 | .global dup2 7 | .ent dup2 8 | 9 | dup2: 10 | li $2, NR_dup2 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end dup2 16 | -------------------------------------------------------------------------------- /libc/mips/execve.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_execve, 4011 3 | 4 | .text 5 | .set reorder 6 | .global execve 7 | .ent execve 8 | 9 | execve: 10 | li $2, NR_execve 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end execve 16 | -------------------------------------------------------------------------------- /libc/mips/fcntl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fcntl, 4055 3 | 4 | .text 5 | .set reorder 6 | .global fcntl 7 | .ent fcntl 8 | 9 | fcntl: 10 | li $2, NR_fcntl 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end fcntl 16 | -------------------------------------------------------------------------------- /libc/mips/fork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fork, 4002 3 | 4 | .text 5 | .set reorder 6 | .global fork 7 | .ent fork 8 | 9 | fork: 10 | li $2, NR_fork 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end fork 16 | -------------------------------------------------------------------------------- /libc/mips/fstat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fstat, 4108 3 | 4 | .text 5 | .set reorder 6 | .global fstat 7 | .ent fstat 8 | 9 | fstat: 10 | li $2, NR_fstat 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end fstat 16 | -------------------------------------------------------------------------------- /libc/mips/getdents64.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getdents64, 4219 3 | 4 | .text 5 | .set reorder 6 | .global getdents64 7 | .ent getdents64 8 | 9 | getdents64: 10 | li $2, NR_getdents64 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end getdents64 16 | -------------------------------------------------------------------------------- /libc/mips/getpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getpid, 4020 3 | 4 | .text 5 | .set reorder 6 | .global getpid 7 | .ent getpid 8 | 9 | getpid: 10 | li $2, NR_getpid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end getpid 16 | -------------------------------------------------------------------------------- /libc/mips/getsockopt.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getsockopt, 4173 3 | 4 | .text 5 | .set reorder 6 | .global getsockopt 7 | .ent getsockopt 8 | 9 | getsockopt: 10 | li $2, NR_getsockopt 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end getsockopt 16 | -------------------------------------------------------------------------------- /libc/mips/getuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getuid, 4024 3 | 4 | .text 5 | .set reorder 6 | .global getuid 7 | .ent getuid 8 | 9 | getuid: 10 | li $2, NR_getuid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end getuid 16 | -------------------------------------------------------------------------------- /libc/mips/ioctl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_ioctl, 4054 3 | 4 | .text 5 | .set reorder 6 | .global ioctl 7 | .ent ioctl 8 | 9 | ioctl: 10 | li $2, NR_ioctl 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end ioctl 16 | -------------------------------------------------------------------------------- /libc/mips/kill.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_kill, 4037 3 | 4 | .text 5 | .set reorder 6 | .global kill 7 | .ent kill 8 | 9 | kill: 10 | li $2, NR_kill 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end kill 16 | -------------------------------------------------------------------------------- /libc/mips/listen.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_listen, 4174 3 | 4 | .text 5 | .set reorder 6 | .global listen 7 | .ent listen 8 | 9 | listen: 10 | li $2, NR_listen 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end listen 16 | -------------------------------------------------------------------------------- /libc/mips/mmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mmap, 4090 3 | 4 | .text 5 | .set reorder 6 | .global mmap 7 | .ent mmap 8 | 9 | mmap: 10 | li $2, NR_mmap 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end mmap 16 | -------------------------------------------------------------------------------- /libc/mips/mremap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mremap, 4167 3 | 4 | .text 5 | .set reorder 6 | .global mremap 7 | .ent mremap 8 | 9 | mremap: 10 | li $2, NR_mremap 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end mremap 16 | -------------------------------------------------------------------------------- /libc/mips/munmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_munmap, 4091 3 | 4 | .text 5 | .set reorder 6 | .global munmap 7 | .ent munmap 8 | 9 | munmap: 10 | li $2, NR_munmap 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end munmap 16 | -------------------------------------------------------------------------------- /libc/mips/nanosleep.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_nanosleep, 4166 3 | 4 | .text 5 | .set reorder 6 | .global nanosleep 7 | .ent nanosleep 8 | 9 | nanosleep: 10 | li $2, NR_nanosleep 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end nanosleep 16 | -------------------------------------------------------------------------------- /libc/mips/open.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_open, 4005 3 | 4 | .text 5 | .set reorder 6 | .global open 7 | .ent open 8 | 9 | open: 10 | li $2, NR_open 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end open 16 | -------------------------------------------------------------------------------- /libc/mips/ppoll.s: -------------------------------------------------------------------------------- 1 | .equ NR_ppoll, 4302 2 | .equ sizeof_sigset_t, 16 3 | 4 | .equ v0, 2 5 | .equ t9, 25 6 | .equ sp, 29 7 | 8 | .text 9 | .set reorder 10 | .global ppoll 11 | .ent ppoll 12 | 13 | /* XXX: do we need to move sp here? 14 | Or is it still that "caller-allocated" area we can use at will? */ 15 | 16 | ppoll: 17 | li $v0, NR_ppoll 18 | addi $sp, $sp, -4 19 | li $t9, sizeof_sigset_t 20 | sw $t9, 16($sp) 21 | syscall 22 | addi $sp, $sp, 4 23 | la $t9, _syscall 24 | jr $t9 25 | 26 | .end ppoll 27 | -------------------------------------------------------------------------------- /libc/mips/read.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_read, 4003 3 | 4 | .text 5 | .set reorder 6 | .global read 7 | .ent read 8 | 9 | read: 10 | li $2, NR_read 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end read 16 | -------------------------------------------------------------------------------- /libc/mips/reboot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_reboot, 4088 3 | .equ LINUX_REBOOT_MAGIC1, 0xfee1dead 4 | .equ LINUX_REBOOT_MAGIC2, 672274793 5 | 6 | .text 7 | .set reorder 8 | .global reboot 9 | .ent reboot 10 | 11 | .equ zero, 0 12 | .equ v0, 2 13 | .equ a0, 4 14 | .equ a1, 5 15 | .equ a2, 6 16 | .equ t9, 25 17 | 18 | reboot: 19 | li $v0, NR_reboot 20 | move $a2, $a0 21 | li $a0, LINUX_REBOOT_MAGIC1 22 | li $a1, LINUX_REBOOT_MAGIC2 23 | syscall 24 | la $t9, _syscall 25 | jr $t9 26 | 27 | .end reboot 28 | -------------------------------------------------------------------------------- /libc/mips/send.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_send, 4178 3 | 4 | .text 5 | .set reorder 6 | .global send 7 | .ent send 8 | 9 | send: 10 | li $2, NR_send 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end send 16 | -------------------------------------------------------------------------------- /libc/mips/setfsgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsgid, 4139 3 | 4 | .text 5 | .set reorder 6 | .global setfsgid 7 | .ent setfsgid 8 | 9 | setfsgid: 10 | li $2, NR_setfsgid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setfsgid 16 | -------------------------------------------------------------------------------- /libc/mips/setfsuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsuid, 4138 3 | 4 | .text 5 | .set reorder 6 | .global setfsuid 7 | .ent setfsuid 8 | 9 | setfsuid: 10 | li $2, NR_setfsuid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setfsuid 16 | -------------------------------------------------------------------------------- /libc/mips/setitimer.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setitimer, 4104 3 | 4 | .text 5 | .set reorder 6 | .global setitimer 7 | .ent setitimer 8 | 9 | setitimer: 10 | li $2, NR_setitimer 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setitimer 16 | -------------------------------------------------------------------------------- /libc/mips/setpriority.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setpriority, 4097 3 | 4 | .text 5 | .set reorder 6 | .global setpriority 7 | .ent setpriority 8 | 9 | setpriority: 10 | li $2, NR_setpriority 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setpriority 16 | -------------------------------------------------------------------------------- /libc/mips/setresgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresgid, 4190 3 | 4 | .text 5 | .set reorder 6 | .global setresgid 7 | .ent setresgid 8 | 9 | setresgid: 10 | li $2, NR_setresgid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setresgid 16 | -------------------------------------------------------------------------------- /libc/mips/setresuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresuid, 4185 3 | 4 | .text 5 | .set reorder 6 | .global setresuid 7 | .ent setresuid 8 | 9 | setresuid: 10 | li $2, NR_setresuid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setresuid 16 | -------------------------------------------------------------------------------- /libc/mips/setrlimit.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setrlimit, 4075 3 | 4 | .text 5 | .set reorder 6 | .global setrlimit 7 | .ent setrlimit 8 | 9 | setrlimit: 10 | li $2, NR_setrlimit 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setrlimit 16 | -------------------------------------------------------------------------------- /libc/mips/setsid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setsid, 4066 3 | 4 | .text 5 | .set reorder 6 | .global setsid 7 | .ent setsid 8 | 9 | setsid: 10 | li $2, NR_setsid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end setsid 16 | -------------------------------------------------------------------------------- /libc/mips/shutdown.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_shutdown, 4182 3 | 4 | .text 5 | .set reorder 6 | .global shutdown 7 | .ent shutdown 8 | 9 | shutdown: 10 | li $2, NR_shutdown 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end shutdown 16 | -------------------------------------------------------------------------------- /libc/mips/sigaction.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_sigaction, 4067 3 | 4 | .text 5 | .set reorder 6 | .global sigaction 7 | .ent sigaction 8 | 9 | sigaction: 10 | li $2, NR_sigaction 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end sigaction 16 | -------------------------------------------------------------------------------- /libc/mips/sigprocmask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_sigprocmask, 4126 3 | 4 | .text 5 | .set reorder 6 | .global sigprocmask 7 | .ent sigprocmask 8 | 9 | sigprocmask: 10 | li $2, NR_sigprocmask 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end sigprocmask 16 | -------------------------------------------------------------------------------- /libc/mips/socket.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_socket, 4183 3 | 4 | .text 5 | .set reorder 6 | .global socket 7 | .ent socket 8 | 9 | socket: 10 | li $2, NR_socket 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end socket 16 | -------------------------------------------------------------------------------- /libc/mips/stat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_stat, 4106 3 | 4 | .text 5 | .set reorder 6 | .global stat 7 | .ent stat 8 | 9 | stat: 10 | li $2, NR_stat 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end stat 16 | -------------------------------------------------------------------------------- /libc/mips/umask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_umask, 4060 3 | 4 | .text 5 | .set reorder 6 | .global umask 7 | .ent umask 8 | 9 | umask: 10 | li $2, NR_umask 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end umask 16 | -------------------------------------------------------------------------------- /libc/mips/unshare.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_unshare, 4303 3 | 4 | .text 5 | .set reorder 6 | .global unshare 7 | .ent unshare 8 | 9 | unshare: 10 | li $2, NR_unshare 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end unshare 16 | -------------------------------------------------------------------------------- /libc/mips/waitpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_waitpid, 4007 3 | 4 | .text 5 | .set reorder 6 | .global waitpid 7 | .ent waitpid 8 | 9 | waitpid: 10 | li $2, NR_waitpid 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end waitpid 16 | -------------------------------------------------------------------------------- /libc/mips/write.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_write, 4004 3 | 4 | .text 5 | .set reorder 6 | .global write 7 | .ent write 8 | 9 | write: 10 | li $2, NR_write 11 | syscall 12 | la $25, _syscall 13 | jr $25 14 | 15 | .end write 16 | -------------------------------------------------------------------------------- /libc/raise.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* libgcc relies on this function in some cases */ 5 | /* (ARM: signal FPE on divide by zero) */ 6 | 7 | int raise(int sig) 8 | { 9 | return kill(getpid(), sig); 10 | } 11 | -------------------------------------------------------------------------------- /libc/sigaddset.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigaddset(sigset_t *set, int sig) 4 | { 5 | if(sig < 1 || sig > SIGRTMAX) 6 | return -1; 7 | else 8 | sig--; 9 | 10 | const int bpl = 8*sizeof(long); /* bits per long */ 11 | 12 | set->sig[sig/bpl] |= (1U << (sig % bpl)); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /libc/sigemptyset.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigemptyset(sigset_t *set) 4 | { 5 | set->sig[0] = 0; 6 | if(_NSIG_WORDS > 1) 7 | set->sig[1] = 0; 8 | if(_NSIG_WORDS > 2) { 9 | set->sig[2]=0; 10 | set->sig[3]=0; 11 | } 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /libc/strcat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char* strcat(char* s, const char* t) 4 | { 5 | char* r = s; 6 | 7 | for(s += strlen(s); (*s = *t); s++, t++) 8 | ; 9 | 10 | return r; 11 | } 12 | -------------------------------------------------------------------------------- /libc/strchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *strchr(register const char *t, int c) 5 | { 6 | register char ch = c; 7 | 8 | while(likely(*t != ch)) 9 | if (unlikely(!*t)) 10 | return 0; 11 | else 12 | ++t; 13 | 14 | return (char*)t; 15 | } 16 | -------------------------------------------------------------------------------- /libc/strcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int strcmp(const char* a, const char* b) 4 | { 5 | while(*a && *a == *b) { a++; b++; } 6 | return (*a - *b); 7 | } 8 | -------------------------------------------------------------------------------- /libc/strcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char* strcpy(char *s1, const char *s2) 4 | { 5 | char* res = s1; 6 | while((*s1++ = *s2++)); 7 | return (res); 8 | } 9 | -------------------------------------------------------------------------------- /libc/strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long strlen(const char* s) 4 | { 5 | int l = 0; 6 | while(*(s++)) l++; 7 | return l; 8 | } 9 | -------------------------------------------------------------------------------- /libc/strncpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strncpy(char* d, const char* s, size_t n) 4 | { 5 | const char* e = s + n; 6 | char* ret = d; 7 | 8 | while(*s && s < e) 9 | *(d++) = *(s++); 10 | *d = '\0'; 11 | 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /libc/strpbrk.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char* strpbrk(const char* s, const char *accept) 5 | { 6 | const char* a; 7 | 8 | for(; *s; s++) 9 | for(a = accept; *a; a++) 10 | if(*s == *a) 11 | return (char*)s; 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /libc/strsep.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char* strsep(char **stringp, const char *delim) 4 | { 5 | char* orig = *stringp; 6 | char* p; 7 | const char* q; 8 | 9 | if(!orig) 10 | goto out; 11 | 12 | for(p = orig; *p; p++) 13 | for(q = delim; *q; q++) 14 | if(*q == *p) { 15 | *p = '\0'; 16 | *stringp = p + 1; 17 | goto out; 18 | } 19 | *stringp = NULL; 20 | 21 | out: 22 | return orig; 23 | } 24 | -------------------------------------------------------------------------------- /libc/x86/accept.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_ACCEPT, 5 3 | 4 | .text 5 | .global accept 6 | 7 | accept: 8 | movb $SYS_ACCEPT, %al 9 | jmp socketcall 10 | 11 | .type accept,@function 12 | .size accept,.-accept 13 | -------------------------------------------------------------------------------- /libc/x86/bind.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_BIND, 2 3 | 4 | .text 5 | .global bind 6 | 7 | bind: 8 | movb $SYS_BIND, %al 9 | jmp socketcall 10 | 11 | .type bind,@function 12 | .size bind,.-bind 13 | -------------------------------------------------------------------------------- /libc/x86/bits/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_DIRENT_H 2 | #define BITS_DIRENT_H 3 | 4 | #include 5 | 6 | #define DT_UNKNOWN 0 7 | #define DT_FIFO 1 8 | #define DT_CHR 2 9 | #define DT_DIR 4 10 | #define DT_BLK 6 11 | #define DT_REG 8 12 | #define DT_LNK 10 13 | #define DT_SOCK 12 14 | #define DT_WHT 14 15 | 16 | struct dirent64 { 17 | uint64_t d_ino; 18 | int64_t d_off; 19 | uint16_t d_reclen; 20 | unsigned char d_type; 21 | char d_name[256]; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/x86/bits/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_FCNTL_H 2 | #define BITS_FCNTL_H 3 | 4 | #define O_RDONLY 00 5 | #define O_WRONLY 01 6 | #define O_RDWR 02 7 | #define O_CREAT 0100 8 | #define O_EXCL 0200 9 | #define O_NOCTTY 0400 10 | #define O_TRUNC 01000 11 | #define O_APPEND 02000 12 | #define O_NONBLOCK 04000 13 | #define O_DIRECTORY 0200000 14 | #define O_NOFOLLOW 0400000 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/x86/bits/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_IOCTL_H 2 | #define BITS_IOCTL_H 3 | 4 | #define TIOCSCTTY 0x540E 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/x86/bits/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_LIMITS_H 2 | #define BITS_LIMITS_H 3 | 4 | #define __WORDSIZE 32 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/x86/bits/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_MMAN_H 2 | #define BITS_MMAN_H 3 | 4 | #define MREMAP_MAYMOVE 1UL 5 | #define MREMAP_FIXED 2UL 6 | 7 | #define PROT_READ 0x1 /* page can be read */ 8 | #define PROT_WRITE 0x2 /* page can be written */ 9 | #define PROT_EXEC 0x4 /* page can be executed */ 10 | #define PROT_NONE 0x0 /* page can not be accessed */ 11 | 12 | #define MAP_SHARED 0x01 /* Share changes */ 13 | #define MAP_PRIVATE 0x02 /* Changes are private */ 14 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ 15 | 16 | #define MAP_FAILED ((void *) -1) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/x86/bits/net.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_NET_H 2 | #define BITS_NET_H 3 | 4 | #define SYS_SOCKET 1 /* sys_socket(2) */ 5 | #define SYS_BIND 2 /* sys_bind(2) */ 6 | #define SYS_CONNECT 3 /* sys_connect(2) */ 7 | #define SYS_LISTEN 4 /* sys_listen(2) */ 8 | #define SYS_ACCEPT 5 /* sys_accept(2) */ 9 | #define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */ 10 | #define SYS_GETPEERNAME 7 /* sys_getpeername(2) */ 11 | #define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */ 12 | #define SYS_SEND 9 /* sys_send(2) */ 13 | #define SYS_RECV 10 /* sys_recv(2) */ 14 | #define SYS_SENDTO 11 /* sys_sendto(2) */ 15 | #define SYS_RECVFROM 12 /* sys_recvfrom(2) */ 16 | #define SYS_SHUTDOWN 13 /* sys_shutdown(2) */ 17 | #define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */ 18 | #define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ 19 | #define SYS_SENDMSG 16 /* sys_sendmsg(2) */ 20 | #define SYS_RECVMSG 17 /* sys_recvmsg(2) */ 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libc/x86/bits/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_POLL_H 2 | #define SYS_POLL_H 3 | 4 | #define POLLIN (1<<0) 5 | #define POLLPRI (1<<1) 6 | #define POLLOUT (1<<2) 7 | #define POLLERR (1<<3) 8 | #define POLLHUP (1<<4) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/x86/bits/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_SOCKET_H 2 | #define BITS_SOCKET_H 3 | 4 | #define AF_UNIX 1 5 | 6 | #define SOCK_STREAM (1<<0) 7 | #define SOCK_DGRAM (1<<1) 8 | #define SOCK_NONBLOCK (1<<11) 9 | #define SOCK_CLOEXEC (1<<19) 10 | 11 | #define SOL_SOCKET 1 12 | #define SO_PEERCRED 17 13 | 14 | #define SHUT_RD 0 15 | #define SHUT_WR 1 16 | #define SHUT_RDWR 2 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/x86/bits/types.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_TYPES_H 2 | #define BITS_TYPES_H 3 | 4 | typedef signed char int8_t; 5 | typedef signed short int16_t; 6 | typedef int int32_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | 12 | typedef signed long long int64_t; 13 | typedef unsigned long long uint64_t; 14 | 15 | typedef unsigned int size_t; 16 | typedef signed long ssize_t; 17 | typedef signed long off_t; 18 | typedef signed long time_t; 19 | 20 | typedef int32_t pid_t; 21 | typedef uint32_t gid_t; 22 | typedef uint32_t uid_t; 23 | 24 | typedef uint32_t socklen_t; 25 | typedef uint16_t sa_family_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libc/x86/chdir.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chdir, 12 3 | 4 | .text 5 | .global chdir 6 | 7 | chdir: 8 | mov $NR_chdir, %al 9 | jmp _syscall 10 | 11 | .type chdir,@function 12 | .size chdir,.-chdir 13 | -------------------------------------------------------------------------------- /libc/x86/chroot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chroot, 61 3 | 4 | .text 5 | .global chroot 6 | 7 | chroot: 8 | mov $NR_chroot, %al 9 | jmp _syscall 10 | 11 | .type chroot,@function 12 | .size chroot,.-chroot 13 | -------------------------------------------------------------------------------- /libc/x86/clock_gettime.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_clock_gettime, 265 3 | 4 | .text 5 | .global clock_gettime 6 | 7 | clock_gettime: 8 | mov $NR_clock_gettime, %ax 9 | jmp _syscallx 10 | 11 | .type clock_gettime,@function 12 | .size clock_gettime,.-clock_gettime 13 | -------------------------------------------------------------------------------- /libc/x86/close.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_close, 6 3 | 4 | .text 5 | .global close 6 | 7 | close: 8 | mov $NR_close, %al 9 | jmp _syscall 10 | 11 | .type close,@function 12 | .size close,.-close 13 | -------------------------------------------------------------------------------- /libc/x86/connect.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_CONNECT, 3 3 | 4 | .text 5 | .global connect 6 | 7 | connect: 8 | movb $SYS_CONNECT, %al 9 | jmp socketcall 10 | 11 | .type connect,@function 12 | .size connect,.-connect 13 | -------------------------------------------------------------------------------- /libc/x86/dup2.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_dup2, 63 3 | 4 | .text 5 | .global dup2 6 | 7 | dup2: 8 | mov $NR_dup2, %al 9 | jmp _syscall 10 | 11 | .type dup2,@function 12 | .size dup2,.-dup2 13 | -------------------------------------------------------------------------------- /libc/x86/execve.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_execve, 11 3 | 4 | .text 5 | .global execve 6 | 7 | execve: 8 | mov $NR_execve, %al 9 | jmp _syscall 10 | 11 | .type execve,@function 12 | .size execve,.-execve 13 | -------------------------------------------------------------------------------- /libc/x86/fcntl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fcntl, 55 3 | 4 | .text 5 | .global fcntl 6 | 7 | fcntl: 8 | mov $NR_fcntl, %al 9 | jmp _syscall 10 | 11 | .type fcntl,@function 12 | .size fcntl,.-fcntl 13 | -------------------------------------------------------------------------------- /libc/x86/fork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fork, 2 3 | 4 | .text 5 | .global fork 6 | 7 | fork: 8 | mov $NR_fork, %al 9 | jmp _syscall 10 | 11 | .type fork,@function 12 | .size fork,.-fork 13 | -------------------------------------------------------------------------------- /libc/x86/fstat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fstat, 108 3 | 4 | .text 5 | .global fstat 6 | 7 | fstat: 8 | mov $NR_fstat, %al 9 | jmp _syscall 10 | 11 | .type fstat,@function 12 | .size fstat,.-fstat 13 | -------------------------------------------------------------------------------- /libc/x86/getdents64.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getdents64, 220 3 | 4 | .text 5 | .global getdents64 6 | 7 | getdents64: 8 | mov $NR_getdents64, %al 9 | jmp _syscall 10 | 11 | .type getdents64,@function 12 | .size getdents64,.-getdents64 13 | -------------------------------------------------------------------------------- /libc/x86/getpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getpid, 20 3 | 4 | .text 5 | .global getpid 6 | 7 | getpid: 8 | mov $NR_getpid, %al 9 | jmp _syscall 10 | 11 | .type getpid,@function 12 | .size getpid,.-getpid 13 | -------------------------------------------------------------------------------- /libc/x86/getsockopt.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_GETSOCKOPT, 15 3 | 4 | .text 5 | .global getsockopt 6 | 7 | getsockopt: 8 | movb $SYS_GETSOCKOPT, %al 9 | jmp socketcall 10 | 11 | .type getsockopt,@function 12 | .size getsockopt,.-getsockopt 13 | -------------------------------------------------------------------------------- /libc/x86/getuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getuid, 24 3 | 4 | .text 5 | .global getuid 6 | 7 | getuid: 8 | mov $NR_getuid, %al 9 | jmp _syscall 10 | 11 | .type getuid,@function 12 | .size getuid,.-getuid 13 | -------------------------------------------------------------------------------- /libc/x86/ioctl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_ioctl, 54 3 | 4 | .text 5 | .global ioctl 6 | 7 | ioctl: 8 | mov $NR_ioctl, %al 9 | jmp _syscall 10 | 11 | .type ioctl,@function 12 | .size ioctl,.-ioctl 13 | -------------------------------------------------------------------------------- /libc/x86/kill.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_kill, 37 3 | 4 | .text 5 | .global kill 6 | 7 | kill: 8 | mov $NR_kill, %al 9 | jmp _syscall 10 | 11 | .type kill,@function 12 | .size kill,.-kill 13 | -------------------------------------------------------------------------------- /libc/x86/listen.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_LISTEN, 4 3 | 4 | .text 5 | .global listen 6 | 7 | listen: 8 | movb $SYS_LISTEN, %al 9 | jmp socketcall 10 | 11 | .type listen,@function 12 | .size listen,.-listen 13 | -------------------------------------------------------------------------------- /libc/x86/mmap.s: -------------------------------------------------------------------------------- 1 | /* NR_mmap is an old 4-argument pass-stuff-in-memory call version. 2 | Standard mmap interface is provided by NR_mmap2 instead. 3 | Ref. http://www.win.tue.nl/~aeb/linux/lk/lk-4.html */ 4 | 5 | .equ NR_mmap2, 192 6 | 7 | .text 8 | .global mmap 9 | 10 | mmap: 11 | mov $NR_mmap2, %al 12 | jmp _syscall 13 | 14 | .type mmap,@function 15 | .size mmap,.-mmap 16 | -------------------------------------------------------------------------------- /libc/x86/mremap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mremap, 163 3 | 4 | .text 5 | .global mremap 6 | 7 | mremap: 8 | mov $NR_mremap, %al 9 | jmp _syscall 10 | 11 | .type mremap,@function 12 | .size mremap,.-mremap 13 | -------------------------------------------------------------------------------- /libc/x86/munmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_munmap, 91 3 | 4 | .text 5 | .global munmap 6 | 7 | munmap: 8 | mov $NR_munmap, %al 9 | jmp _syscall 10 | 11 | .type munmap,@function 12 | .size munmap,.-munmap 13 | -------------------------------------------------------------------------------- /libc/x86/nanosleep.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_nanosleep, 162 3 | 4 | .text 5 | .global nanosleep 6 | 7 | nanosleep: 8 | mov $NR_nanosleep, %al 9 | jmp _syscall 10 | 11 | .type nanosleep,@function 12 | .size nanosleep,.-nanosleep 13 | -------------------------------------------------------------------------------- /libc/x86/open.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_open, 5 3 | 4 | .text 5 | .global open 6 | 7 | open: 8 | mov $NR_open, %al 9 | jmp _syscall 10 | 11 | .type open,@function 12 | .size open,.-open 13 | -------------------------------------------------------------------------------- /libc/x86/ppoll.s: -------------------------------------------------------------------------------- 1 | .equ NR_ppoll, 309 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global ppoll 6 | 7 | ppoll: 8 | xor %eax, %eax 9 | mov $NR_ppoll, %ax 10 | 11 | push %edi 12 | push %esi 13 | push %ebx 14 | push %ebp 15 | 16 | movl %esp, %edi 17 | movl 5*4(%edi), %ebx 18 | movl 6*4(%edi), %ecx 19 | movl 7*4(%edi), %edx 20 | movl 8*4(%edi), %esi 21 | movl $sizeof_sigset_t, %edi 22 | 23 | jmp _syscallc 24 | 25 | .type ppoll,@function 26 | .size ppoll,.-ppoll 27 | -------------------------------------------------------------------------------- /libc/x86/read.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_read, 3 3 | 4 | .text 5 | .global read 6 | 7 | read: 8 | mov $NR_read, %al 9 | jmp _syscall 10 | 11 | .type read,@function 12 | .size read,.-read 13 | -------------------------------------------------------------------------------- /libc/x86/reboot.s: -------------------------------------------------------------------------------- 1 | .equ NR_reboot, 88 2 | .equ LINUX_REBOOT_MAGIC1, 0xfee1dead 3 | .equ LINUX_REBOOT_MAGIC2, 672274793 4 | 5 | .text 6 | .global reboot 7 | 8 | /* One may wonder why bother saving registers before doing a reboot call. 9 | The call may very well fail, and it makes sense to give at least some 10 | indication of the cause. 11 | 12 | The failure will be immediately followed by a kernel panic, but at least 13 | it won't be "segmetation fault (...) kernel panic", but instead something 14 | like "init: reboot failed (...) kernel panic". */ 15 | 16 | reboot: 17 | xor %eax, %eax 18 | mov $NR_reboot, %al 19 | 20 | push %edi 21 | push %esi 22 | push %ebx 23 | push %ebp 24 | 25 | movl $LINUX_REBOOT_MAGIC1, %ebx 26 | movl $LINUX_REBOOT_MAGIC2, %ecx 27 | movl 5*4(%esp), %edx 28 | 29 | jmp _syscallc 30 | 31 | .type reboot,@function 32 | .size reboot,.-reboot 33 | -------------------------------------------------------------------------------- /libc/x86/send.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_SEND, 9 3 | 4 | .text 5 | .global send 6 | 7 | send: 8 | movb $SYS_SEND, %al 9 | jmp socketcall 10 | 11 | .type send,@function 12 | .size send,.-send 13 | -------------------------------------------------------------------------------- /libc/x86/setfsgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsgid, 139 3 | 4 | .text 5 | .global setfsgid 6 | 7 | setfsgid: 8 | mov $NR_setfsgid, %al 9 | jmp _syscall 10 | 11 | .type setfsgid,@function 12 | .size setfsgid,.-setfsgid 13 | -------------------------------------------------------------------------------- /libc/x86/setfsuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsuid, 138 3 | 4 | .text 5 | .global setfsuid 6 | 7 | setfsuid: 8 | mov $NR_setfsuid, %al 9 | jmp _syscall 10 | 11 | .type setfsuid,@function 12 | .size setfsuid,.-setfsuid 13 | -------------------------------------------------------------------------------- /libc/x86/setitimer.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setitimer, 104 3 | 4 | .text 5 | .global setitimer 6 | 7 | setitimer: 8 | mov $NR_setitimer, %al 9 | jmp _syscall 10 | 11 | .type setitimer,@function 12 | .size setitimer,.-setitimer 13 | -------------------------------------------------------------------------------- /libc/x86/setpriority.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setpriority, 97 3 | 4 | .text 5 | .global setpriority 6 | 7 | setpriority: 8 | mov $NR_setpriority, %al 9 | jmp _syscall 10 | 11 | .type setpriority,@function 12 | .size setpriority,.-setpriority 13 | -------------------------------------------------------------------------------- /libc/x86/setresgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresgid, 170 3 | 4 | .text 5 | .global setresgid 6 | 7 | setresgid: 8 | mov $NR_setresgid, %al 9 | jmp _syscall 10 | 11 | .type setresgid,@function 12 | .size setresgid,.-setresgid 13 | -------------------------------------------------------------------------------- /libc/x86/setresuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresuid, 164 3 | 4 | .text 5 | .global setresuid 6 | 7 | setresuid: 8 | mov $NR_setresuid, %al 9 | jmp _syscall 10 | 11 | .type setresuid,@function 12 | .size setresuid,.-setresuid 13 | -------------------------------------------------------------------------------- /libc/x86/setrlimit.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setrlimit, 75 3 | 4 | .text 5 | .global setrlimit 6 | 7 | setrlimit: 8 | mov $NR_setrlimit, %al 9 | jmp _syscall 10 | 11 | .type setrlimit,@function 12 | .size setrlimit,.-setrlimit 13 | -------------------------------------------------------------------------------- /libc/x86/setsid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setsid, 66 3 | 4 | .text 5 | .global setsid 6 | 7 | setsid: 8 | mov $NR_setsid, %al 9 | jmp _syscall 10 | 11 | .type setsid,@function 12 | .size setsid,.-setsid 13 | -------------------------------------------------------------------------------- /libc/x86/shutdown.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_SHUTDOWN, 13 3 | 4 | .text 5 | .global shutdown 6 | 7 | shutdown: 8 | movb $SYS_SHUTDOWN, %al 9 | jmp socketcall 10 | 11 | .type shutdown,@function 12 | .size shutdown,.-shutdown 13 | -------------------------------------------------------------------------------- /libc/x86/sigaction.s: -------------------------------------------------------------------------------- 1 | .text 2 | .global sigaction 3 | 4 | .equ NR_sigaction, 67 5 | .equ sizeof_sigset_t, 8 6 | 7 | /* sigaction(signum, act, oldact) := linux_sigaction(signum, act, oldact, sizeof(sigset_t)) */ 8 | 9 | sigaction: 10 | xor %eax, %eax 11 | mov $NR_sigaction, %al 12 | 13 | push %edi 14 | push %esi 15 | push %ebx 16 | push %ebp 17 | 18 | movl %esp, %edi 19 | movl 5*4(%edi), %ebx 20 | movl 6*4(%edi), %ecx 21 | movl 7*4(%edi), %edx 22 | movl $sizeof_sigset_t, %esi 23 | 24 | jmp _syscallc 25 | 26 | .type sigaction,@function 27 | .size sigaction,.-sigaction 28 | -------------------------------------------------------------------------------- /libc/x86/sigprocmask.s: -------------------------------------------------------------------------------- 1 | .equ NR_sigprocmask, 126 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global sigprocmask 6 | 7 | /* sigprocmask(how, set, old) := linux_sigprocmask(how, set, old, sizeof(sigset_t)) */ 8 | /* 4sp 8sp 12sp 4sp 8sp 12sp 16sp */ 9 | 10 | /* To avoid messing with the stack to call _syscall, we put a custom syscall 11 | preamble here and jump to the point in _syscall where arguments are already 12 | in their respective registers. */ 13 | 14 | sigprocmask: 15 | xor %eax, %eax 16 | mov $NR_sigprocmask, %al 17 | 18 | push %edi 19 | push %esi 20 | push %ebx 21 | push %ebp 22 | 23 | movl %esp, %edi 24 | movl 5*4(%edi), %ebx 25 | movl 6*4(%edi), %ecx 26 | movl 7*4(%edi), %edx 27 | movl $sizeof_sigset_t, %esi 28 | 29 | jmp _syscallc 30 | 31 | .type sigprocmask,@function 32 | .size sigprocmask,.-sigprocmask 33 | -------------------------------------------------------------------------------- /libc/x86/socket.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ SYS_SOCKET, 1 3 | 4 | .text 5 | .global socket 6 | 7 | socket: 8 | movb $SYS_SOCKET, %al 9 | jmp socketcall 10 | 11 | .type socket,@function 12 | .size socket,.-socket 13 | -------------------------------------------------------------------------------- /libc/x86/socketcall.s: -------------------------------------------------------------------------------- 1 | .equ NR_socketcall, 102 2 | 3 | .text 4 | .global socketcall 5 | 6 | socketcall: 7 | leal 4(%esp), %ecx 8 | pushl %ecx 9 | movzbl %al,%eax 10 | pushl %eax 11 | movb $NR_socketcall, %al 12 | call _syscall 13 | popl %ecx 14 | popl %ecx 15 | ret 16 | 17 | .type socketcall,@function 18 | .size socketcall,.-socketcall 19 | -------------------------------------------------------------------------------- /libc/x86/stat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_stat, 106 3 | 4 | .text 5 | .global stat 6 | 7 | stat: 8 | mov $NR_stat, %al 9 | jmp _syscall 10 | 11 | .type stat,@function 12 | .size stat,.-stat 13 | -------------------------------------------------------------------------------- /libc/x86/umask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_umask, 60 3 | 4 | .text 5 | .global umask 6 | 7 | umask: 8 | mov $NR_umask, %al 9 | jmp _syscall 10 | 11 | .type umask,@function 12 | .size umask,.-umask 13 | -------------------------------------------------------------------------------- /libc/x86/unshare.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_unshare, 310 3 | 4 | .text 5 | .global unshare 6 | 7 | unshare: 8 | mov $NR_unshare, %ax 9 | jmp _syscallx 10 | 11 | .type unshare,@function 12 | .size unshare,.-unshare 13 | -------------------------------------------------------------------------------- /libc/x86/vfork.s: -------------------------------------------------------------------------------- 1 | .equ NR_vfork, 190 2 | 3 | /* vfork is a special syscall for achitectures that keep 4 | return address in the stack. For x86, it may not use 5 | standard trampoline for instance. */ 6 | 7 | .text 8 | .global vfork 9 | 10 | vfork: 11 | popl %edx 12 | xorl %eax,%eax 13 | movb $NR_vfork, %al 14 | int $0x80 15 | jmpl *%edx 16 | 17 | .type vfork,@function 18 | .size vfork,.-vfork 19 | -------------------------------------------------------------------------------- /libc/x86/waitpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_waitpid, 7 3 | 4 | .text 5 | .global waitpid 6 | 7 | waitpid: 8 | mov $NR_waitpid, %al 9 | jmp _syscall 10 | 11 | .type waitpid,@function 12 | .size waitpid,.-waitpid 13 | -------------------------------------------------------------------------------- /libc/x86/write.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_write, 4 3 | 4 | .text 5 | .global write 6 | 7 | write: 8 | mov $NR_write, %al 9 | jmp _syscall 10 | 11 | .type write,@function 12 | .size write,.-write 13 | -------------------------------------------------------------------------------- /libc/x86_32/README: -------------------------------------------------------------------------------- 1 | x86_32, or in other words, x86_64 with short pointers. 2 | Check ../x86_64/README for ABI and such. 3 | 4 | 5 | Big fat warning: building sninit for x86_32 makes little sense. 6 | Negligible net gain over x86_64 in the init process will likely be 7 | offset by not-so-negligible increase in the kernel size needed 8 | to support x86_32. 9 | 10 | The only situation I can think of that warrants x32 init executable 11 | is a kernel without regular x86_64 syscalls, which is not something 12 | that can be built easily. 13 | 14 | 15 | This arch is more of a experiment for the sake of experiment, 16 | not something intended for real use. It is not well tested too. 17 | 18 | 19 | 20 | In case the build fails with 21 | 22 | /usr/bin/ld: skipping incompatible .../libgcc.a when searching for -lgcc 23 | 24 | try removing -lgcc from libs, or make sure your gcc is built correctly and has x32 libs. 25 | -------------------------------------------------------------------------------- /libc/x86_32/_start.s: -------------------------------------------------------------------------------- 1 | .equ NR_exit, 60 2 | 3 | .bss 4 | .global environ 5 | 6 | environ: .quad 0 7 | 8 | .type environ,@object 9 | .size environ,.-environ 10 | 11 | 12 | .text 13 | .global _start 14 | .global _exit 15 | 16 | _start: 17 | movl (%esp), %edi /* %edi = argc */ 18 | lea 4(%esp), %esi /* %esi = argv */ 19 | leaq 4(%rsi,%rdi,4),%rdx /* %edx = envp = (4*edi)+%esi+4 */ 20 | 21 | movl %edx, environ(%rip) 22 | 23 | call main 24 | 25 | movl %eax, %edi /* return value */ 26 | 27 | _exit: mov $NR_exit, %ax /* call _exit */ 28 | movzwl %ax, %eax 29 | mov %rcx, %r10 30 | syscall 31 | hlt /* catch fire and die */ 32 | 33 | .type _exit,@function 34 | .size _exit,.-_exit 35 | 36 | .type _start,@function 37 | .size _start,_exit-_start 38 | -------------------------------------------------------------------------------- /libc/x86_32/_syscall.s: -------------------------------------------------------------------------------- 1 | .bss 2 | .global errno 3 | 4 | errno: .int 0 5 | 6 | .type errno,@object 7 | .size errno,.-errno 8 | 9 | 10 | .text 11 | .global _syscall 12 | .global _syscallx 13 | .global _sysret 14 | 15 | _syscall: 16 | mov $0, %ah 17 | _syscallx: 18 | movzwl %ax, %eax 19 | orl $0x40000000, %eax 20 | mov %rcx, %r10 21 | syscall 22 | _sysret: 23 | cmpq $-132, %rax 24 | jbe ok 25 | negl %eax 26 | movl %eax, errno 27 | orq $-1, %rax 28 | ok: ret 29 | 30 | .type _syscallx,@function 31 | .size _syscallx,.-_syscallx 32 | 33 | .type _syscall,@function 34 | .size _syscall,_syscallx-_syscall 35 | -------------------------------------------------------------------------------- /libc/x86_32/accept.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_accept, 43 3 | 4 | .text 5 | .global accept 6 | 7 | accept: 8 | mov $NR_accept, %al 9 | jmp _syscall 10 | 11 | .type accept,@function 12 | .size accept,.-accept 13 | -------------------------------------------------------------------------------- /libc/x86_32/bind.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_bind, 49 3 | 4 | .text 5 | .global bind 6 | 7 | bind: 8 | mov $NR_bind, %al 9 | jmp _syscall 10 | 11 | .type bind,@function 12 | .size bind,.-bind 13 | -------------------------------------------------------------------------------- /libc/x86_32/bits/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_DIRENT_H 2 | #define BITS_DIRENT_H 3 | 4 | #include 5 | 6 | #define DT_UNKNOWN 0 7 | #define DT_FIFO 1 8 | #define DT_CHR 2 9 | #define DT_DIR 4 10 | #define DT_BLK 6 11 | #define DT_REG 8 12 | #define DT_LNK 10 13 | #define DT_SOCK 12 14 | #define DT_WHT 14 15 | 16 | struct dirent64 { 17 | uint64_t d_ino; 18 | int64_t d_off; 19 | uint16_t d_reclen; 20 | unsigned char d_type; 21 | char d_name[256]; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/x86_32/bits/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_FCNTL_H 2 | #define BITS_FCNTL_H 3 | 4 | #define O_RDONLY 00 5 | #define O_WRONLY 01 6 | #define O_RDWR 02 7 | #define O_CREAT 0100 8 | #define O_EXCL 0200 9 | #define O_NOCTTY 0400 10 | #define O_TRUNC 01000 11 | #define O_APPEND 02000 12 | #define O_NONBLOCK 04000 13 | #define O_DIRECTORY 0200000 14 | #define O_NOFOLLOW 0400000 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/x86_32/bits/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_IOCTL_H 2 | #define BITS_IOCTL_H 3 | 4 | #define TIOCSCTTY 0x540E 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/x86_32/bits/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_LIMITS_H 2 | #define BITS_LIMITS_H 3 | 4 | #define __WORDSIZE 32 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/x86_32/bits/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_MMAN_H 2 | #define BITS_MMAN_H 3 | 4 | #define MREMAP_MAYMOVE 1UL 5 | #define MREMAP_FIXED 2UL 6 | 7 | #define PROT_READ 0x1 /* page can be read */ 8 | #define PROT_WRITE 0x2 /* page can be written */ 9 | #define PROT_EXEC 0x4 /* page can be executed */ 10 | #define PROT_NONE 0x0 /* page can not be accessed */ 11 | 12 | #define MAP_SHARED 0x01 /* Share changes */ 13 | #define MAP_PRIVATE 0x02 /* Changes are private */ 14 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ 15 | 16 | #define MAP_FAILED ((void *) -1) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/x86_32/bits/net.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_NET_H 2 | #define BITS_NET_H 3 | 4 | #define SYS_SOCKET 1 /* sys_socket(2) */ 5 | #define SYS_BIND 2 /* sys_bind(2) */ 6 | #define SYS_CONNECT 3 /* sys_connect(2) */ 7 | #define SYS_LISTEN 4 /* sys_listen(2) */ 8 | #define SYS_ACCEPT 5 /* sys_accept(2) */ 9 | #define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */ 10 | #define SYS_GETPEERNAME 7 /* sys_getpeername(2) */ 11 | #define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */ 12 | #define SYS_SEND 9 /* sys_send(2) */ 13 | #define SYS_RECV 10 /* sys_recv(2) */ 14 | #define SYS_SENDTO 11 /* sys_sendto(2) */ 15 | #define SYS_RECVFROM 12 /* sys_recvfrom(2) */ 16 | #define SYS_SHUTDOWN 13 /* sys_shutdown(2) */ 17 | #define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */ 18 | #define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ 19 | #define SYS_SENDMSG 16 /* sys_sendmsg(2) */ 20 | #define SYS_RECVMSG 17 /* sys_recvmsg(2) */ 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libc/x86_32/bits/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_POLL_H 2 | #define SYS_POLL_H 3 | 4 | #define POLLIN (1<<0) 5 | #define POLLPRI (1<<1) 6 | #define POLLOUT (1<<2) 7 | #define POLLERR (1<<3) 8 | #define POLLHUP (1<<4) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/x86_32/bits/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_SOCKET_H 2 | #define BITS_SOCKET_H 3 | 4 | #define AF_UNIX 1 5 | 6 | #define SOCK_STREAM (1<<0) 7 | #define SOCK_DGRAM (1<<1) 8 | #define SOCK_NONBLOCK (1<<11) 9 | #define SOCK_CLOEXEC (1<<19) 10 | 11 | #define SOL_SOCKET 1 12 | #define SO_PEERCRED 17 13 | 14 | #define SHUT_RD 0 15 | #define SHUT_WR 1 16 | #define SHUT_RDWR 2 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/x86_32/bits/types.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_TYPES_H 2 | #define BITS_TYPES_H 3 | 4 | typedef signed char int8_t; 5 | typedef signed short int16_t; 6 | typedef int int32_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | 12 | typedef signed long long int64_t; 13 | typedef unsigned long long uint64_t; 14 | 15 | typedef unsigned int size_t; 16 | typedef signed long ssize_t; 17 | typedef signed long off_t; 18 | typedef signed long time_t; 19 | 20 | typedef int32_t pid_t; 21 | typedef uint32_t gid_t; 22 | typedef uint32_t uid_t; 23 | 24 | typedef uint32_t socklen_t; 25 | typedef uint16_t sa_family_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libc/x86_32/chdir.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chdir, 80 3 | 4 | .text 5 | .global chdir 6 | 7 | chdir: 8 | mov $NR_chdir, %al 9 | jmp _syscall 10 | 11 | .type chdir,@function 12 | .size chdir,.-chdir 13 | -------------------------------------------------------------------------------- /libc/x86_32/chroot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chroot, 161 3 | 4 | .text 5 | .global chroot 6 | 7 | chroot: 8 | mov $NR_chroot, %al 9 | jmp _syscall 10 | 11 | .type chroot,@function 12 | .size chroot,.-chroot 13 | -------------------------------------------------------------------------------- /libc/x86_32/clock_gettime.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_clock_gettime, 228 3 | 4 | .text 5 | .global clock_gettime 6 | 7 | clock_gettime: 8 | mov $NR_clock_gettime, %al 9 | jmp _syscall 10 | 11 | .type clock_gettime,@function 12 | .size clock_gettime,.-clock_gettime 13 | -------------------------------------------------------------------------------- /libc/x86_32/close.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_close, 3 3 | 4 | .text 5 | .global close 6 | 7 | close: 8 | mov $NR_close, %al 9 | jmp _syscall 10 | 11 | .type close,@function 12 | .size close,.-close 13 | -------------------------------------------------------------------------------- /libc/x86_32/connect.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_connect, 42 3 | 4 | .text 5 | .global connect 6 | 7 | connect: 8 | mov $NR_connect, %al 9 | jmp _syscall 10 | 11 | .type connect,@function 12 | .size connect,.-connect 13 | -------------------------------------------------------------------------------- /libc/x86_32/dup2.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_dup2, 33 3 | 4 | .text 5 | .global dup2 6 | 7 | dup2: 8 | mov $NR_dup2, %al 9 | jmp _syscall 10 | 11 | .type dup2,@function 12 | .size dup2,.-dup2 13 | -------------------------------------------------------------------------------- /libc/x86_32/execve.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_execve, 520 3 | 4 | .text 5 | .global execve 6 | 7 | execve: 8 | mov $NR_execve, %ax 9 | jmp _syscallx 10 | 11 | .type execve,@function 12 | .size execve,.-execve 13 | -------------------------------------------------------------------------------- /libc/x86_32/fcntl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fcntl, 72 3 | 4 | .text 5 | .global fcntl 6 | 7 | fcntl: 8 | mov $NR_fcntl, %al 9 | jmp _syscall 10 | 11 | .type fcntl,@function 12 | .size fcntl,.-fcntl 13 | -------------------------------------------------------------------------------- /libc/x86_32/fork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fork, 57 3 | 4 | .text 5 | .global fork 6 | 7 | fork: 8 | mov $NR_fork, %al 9 | jmp _syscall 10 | 11 | .type fork,@function 12 | .size fork,.-fork 13 | -------------------------------------------------------------------------------- /libc/x86_32/fstat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fstat, 5 3 | 4 | .text 5 | .global fstat 6 | 7 | fstat: 8 | mov $NR_fstat, %al 9 | jmp _syscall 10 | 11 | .type fstat,@function 12 | .size fstat,.-fstat 13 | -------------------------------------------------------------------------------- /libc/x86_32/getdents64.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getdents64, 217 3 | 4 | .text 5 | .global getdents64 6 | 7 | getdents64: 8 | mov $NR_getdents64, %al 9 | jmp _syscall 10 | 11 | .type getdents64,@function 12 | .size getdents64,.-getdents64 13 | -------------------------------------------------------------------------------- /libc/x86_32/getpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getpid, 39 3 | 4 | .text 5 | .global getpid 6 | 7 | getpid: 8 | mov $NR_getpid, %al 9 | jmp _syscall 10 | 11 | .type getpid,@function 12 | .size getpid,.-getpid 13 | -------------------------------------------------------------------------------- /libc/x86_32/getsockopt.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getsockopt, 542 3 | 4 | .text 5 | .global getsockopt 6 | 7 | getsockopt: 8 | mov $NR_getsockopt, %ax 9 | jmp _syscallx 10 | 11 | .type getsockopt,@function 12 | .size getsockopt,.-getsockopt 13 | -------------------------------------------------------------------------------- /libc/x86_32/getuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getuid, 102 3 | 4 | .text 5 | .global getuid 6 | 7 | getuid: 8 | mov $NR_getuid, %al 9 | jmp _syscall 10 | 11 | .type getuid,@function 12 | .size getuid,.-getuid 13 | -------------------------------------------------------------------------------- /libc/x86_32/ioctl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_ioctl, 514 3 | 4 | .text 5 | .global ioctl 6 | 7 | ioctl: 8 | mov $NR_ioctl, %ax 9 | jmp _syscallx 10 | 11 | .type ioctl,@function 12 | .size ioctl,.-ioctl 13 | -------------------------------------------------------------------------------- /libc/x86_32/kill.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_kill, 62 3 | 4 | .text 5 | .global kill 6 | 7 | kill: 8 | mov $NR_kill, %al 9 | jmp _syscall 10 | 11 | .type kill,@function 12 | .size kill,.-kill 13 | -------------------------------------------------------------------------------- /libc/x86_32/listen.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_listen, 50 3 | 4 | .text 5 | .global listen 6 | 7 | listen: 8 | mov $NR_listen, %al 9 | jmp _syscall 10 | 11 | .type listen,@function 12 | .size listen,.-listen 13 | -------------------------------------------------------------------------------- /libc/x86_32/mmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mmap, 9 3 | 4 | .text 5 | .global mmap 6 | 7 | mmap: 8 | mov $NR_mmap, %al 9 | jmp _syscall 10 | 11 | .type mmap,@function 12 | .size mmap,.-mmap 13 | -------------------------------------------------------------------------------- /libc/x86_32/mremap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mremap, 25 3 | 4 | .text 5 | .global mremap 6 | 7 | mremap: 8 | mov $NR_mremap, %al 9 | jmp _syscall 10 | 11 | .type mremap,@function 12 | .size mremap,.-mremap 13 | -------------------------------------------------------------------------------- /libc/x86_32/munmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_munmap, 11 3 | 4 | .text 5 | .global munmap 6 | 7 | munmap: 8 | mov $NR_munmap, %al 9 | jmp _syscall 10 | 11 | .type munmap,@function 12 | .size munmap,.-munmap 13 | -------------------------------------------------------------------------------- /libc/x86_32/nanosleep.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_nanosleep, 35 3 | 4 | .text 5 | .global nanosleep 6 | 7 | nanosleep: 8 | mov $NR_nanosleep, %al 9 | jmp _syscall 10 | 11 | .type nanosleep,@function 12 | .size nanosleep,.-nanosleep 13 | -------------------------------------------------------------------------------- /libc/x86_32/open.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_open, 2 3 | 4 | .text 5 | .global open 6 | 7 | open: 8 | mov $NR_open, %al 9 | jmp _syscall 10 | 11 | .type open,@function 12 | .size open,.-open 13 | -------------------------------------------------------------------------------- /libc/x86_32/ppoll.s: -------------------------------------------------------------------------------- 1 | .equ NR_ppoll, 271 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global ppoll 6 | 7 | ppoll: 8 | mov $sizeof_sigset_t, %r8d 9 | mov $NR_ppoll, %ax 10 | jmp _syscallx 11 | 12 | .type ppoll,@function 13 | .size ppoll,.-ppoll 14 | -------------------------------------------------------------------------------- /libc/x86_32/read.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_read, 0 3 | 4 | .text 5 | .global read 6 | 7 | read: 8 | mov $NR_read, %al 9 | jmp _syscall 10 | 11 | .type read,@function 12 | .size read,.-read 13 | -------------------------------------------------------------------------------- /libc/x86_32/reboot.s: -------------------------------------------------------------------------------- 1 | .equ NR_reboot, 169 2 | .equ LINUX_REBOOT_MAGIC1, 0xfee1dead 3 | .equ LINUX_REBOOT_MAGIC2, 672274793 4 | 5 | .text 6 | .global reboot 7 | 8 | reboot: 9 | mov %rdi, %rdx 10 | mov $LINUX_REBOOT_MAGIC1, %rdi 11 | mov $LINUX_REBOOT_MAGIC2, %rsi 12 | mov $NR_reboot, %al 13 | jmp _syscall 14 | 15 | .type reboot,@function 16 | .size reboot,.-reboot 17 | -------------------------------------------------------------------------------- /libc/x86_32/send.s: -------------------------------------------------------------------------------- 1 | .equ NR_sendto, 44 2 | 3 | .text 4 | .global send 5 | 6 | send: 7 | xor %r8d, %r8d 8 | xor %r9d, %r9d 9 | mov $NR_sendto, %al 10 | jmp _syscall 11 | 12 | .type send,@function 13 | .size send,.-send 14 | -------------------------------------------------------------------------------- /libc/x86_32/setfsgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsgid, 123 3 | 4 | .text 5 | .global setfsgid 6 | 7 | setfsgid: 8 | mov $NR_setfsgid, %al 9 | jmp _syscall 10 | 11 | .type setfsgid,@function 12 | .size setfsgid,.-setfsgid 13 | -------------------------------------------------------------------------------- /libc/x86_32/setfsuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsuid, 122 3 | 4 | .text 5 | .global setfsuid 6 | 7 | setfsuid: 8 | mov $NR_setfsuid, %al 9 | jmp _syscall 10 | 11 | .type setfsuid,@function 12 | .size setfsuid,.-setfsuid 13 | -------------------------------------------------------------------------------- /libc/x86_32/setitimer.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setitimer, 38 3 | 4 | .text 5 | .global setitimer 6 | 7 | setitimer: 8 | mov $NR_setitimer, %al 9 | jmp _syscall 10 | 11 | .type setitimer,@function 12 | .size setitimer,.-setitimer 13 | -------------------------------------------------------------------------------- /libc/x86_32/setpriority.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setpriority, 141 3 | 4 | .text 5 | .global setpriority 6 | 7 | setpriority: 8 | mov $NR_setpriority, %al 9 | jmp _syscall 10 | 11 | .type setpriority,@function 12 | .size setpriority,.-setpriority 13 | -------------------------------------------------------------------------------- /libc/x86_32/setresgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresgid, 119 3 | 4 | .text 5 | .global setresgid 6 | 7 | setresgid: 8 | mov $NR_setresgid, %al 9 | jmp _syscall 10 | 11 | .type setresgid,@function 12 | .size setresgid,.-setresgid 13 | -------------------------------------------------------------------------------- /libc/x86_32/setresuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresuid, 117 3 | 4 | .text 5 | .global setresuid 6 | 7 | setresuid: 8 | mov $NR_setresuid, %al 9 | jmp _syscall 10 | 11 | .type setresuid,@function 12 | .size setresuid,.-setresuid 13 | -------------------------------------------------------------------------------- /libc/x86_32/setrlimit.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setrlimit, 160 3 | 4 | .text 5 | .global setrlimit 6 | 7 | setrlimit: 8 | mov $NR_setrlimit, %al 9 | jmp _syscall 10 | 11 | .type setrlimit,@function 12 | .size setrlimit,.-setrlimit 13 | -------------------------------------------------------------------------------- /libc/x86_32/setsid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setsid, 112 3 | 4 | .text 5 | .global setsid 6 | 7 | setsid: 8 | mov $NR_setsid, %al 9 | jmp _syscall 10 | 11 | .type setsid,@function 12 | .size setsid,.-setsid 13 | -------------------------------------------------------------------------------- /libc/x86_32/shutdown.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_shutdown, 48 3 | 4 | .text 5 | .global shutdown 6 | 7 | shutdown: 8 | mov $NR_shutdown, %al 9 | jmp _syscall 10 | 11 | .type shutdown,@function 12 | .size shutdown,.-shutdown 13 | -------------------------------------------------------------------------------- /libc/x86_32/sigprocmask.s: -------------------------------------------------------------------------------- 1 | .equ NR_rt_sigprocmask, 14 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global sigprocmask 6 | 7 | sigprocmask: 8 | mov $sizeof_sigset_t, %r10d 9 | mov $NR_rt_sigprocmask, %al 10 | jmp _syscall 11 | 12 | .type sigprocmask,@function 13 | .size sigprocmask,.-sigprocmask 14 | -------------------------------------------------------------------------------- /libc/x86_32/socket.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_socket, 41 3 | 4 | .text 5 | .global socket 6 | 7 | socket: 8 | mov $NR_socket, %al 9 | jmp _syscall 10 | 11 | .type socket,@function 12 | .size socket,.-socket 13 | -------------------------------------------------------------------------------- /libc/x86_32/stat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_stat, 4 3 | 4 | .text 5 | .global stat 6 | 7 | stat: 8 | mov $NR_stat, %al 9 | jmp _syscall 10 | 11 | .type stat,@function 12 | .size stat,.-stat 13 | -------------------------------------------------------------------------------- /libc/x86_32/umask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_umask, 95 3 | 4 | .text 5 | .global umask 6 | 7 | umask: 8 | mov $NR_umask, %al 9 | jmp _syscall 10 | 11 | .type umask,@function 12 | .size umask,.-umask 13 | -------------------------------------------------------------------------------- /libc/x86_32/unshare.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_unshare, 272 3 | 4 | .text 5 | .global unshare 6 | 7 | unshare: 8 | mov $NR_unshare, %ax 9 | jmp _syscallx 10 | 11 | .type unshare,@function 12 | .size unshare,.-unshare 13 | -------------------------------------------------------------------------------- /libc/x86_32/vfork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_vfork, 58 3 | 4 | .text 5 | .global vfork 6 | 7 | vfork: 8 | pop %rdx 9 | mov $(0x40000000 | NR_vfork), %rax 10 | syscall 11 | push %rdx 12 | mov %rax, %rdi 13 | jmp _sysret 14 | 15 | .type vfork,@function 16 | .size vfork,.-vfork 17 | -------------------------------------------------------------------------------- /libc/x86_32/waitpid.s: -------------------------------------------------------------------------------- 1 | .equ NR_wait4, 61 2 | 3 | .text 4 | .global waitpid 5 | 6 | waitpid: 7 | xor %rcx,%rcx 8 | mov $NR_wait4,%al 9 | jmp _syscall 10 | 11 | .type waitpid,@function 12 | .size waitpid,.-waitpid 13 | -------------------------------------------------------------------------------- /libc/x86_32/write.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_write, 1 3 | 4 | .text 5 | .global write 6 | 7 | write: 8 | mov $NR_write, %al 9 | jmp _syscall 10 | 11 | .type write,@function 12 | .size write,.-write 13 | -------------------------------------------------------------------------------- /libc/x86_64/README: -------------------------------------------------------------------------------- 1 | AMD 64 SysV calling convention 2 | 3 | 1 2 3 4 5 6 4 | Syscall RAX (RDI, RSI, RDX, R10, R8, R9) -> RAX 5 | Function (RDI, RSI, RDX, RCX, R8, R9) -> RAX 6 | 7 | 8 | dietlibc implements some time-related syscalls via VDSO on x86_64. 9 | This is not done in the bundled libc, the implementation seems to be fragile 10 | and init is not the kind of process to benefit much from using VDSO. 11 | -------------------------------------------------------------------------------- /libc/x86_64/_start.s: -------------------------------------------------------------------------------- 1 | .equ NR_exit, 0x3c 2 | 3 | .bss 4 | .global environ 5 | 6 | environ: .quad 0 7 | 8 | .type environ,@object 9 | .size environ,.-environ 10 | 11 | 12 | .text 13 | .global _start 14 | .global _exit 15 | 16 | _start: 17 | popq %rdi /* %rdi = argc */ 18 | movq %rsp,%rsi /* %rsi = argv */ 19 | pushq %rdi 20 | 21 | leaq 8(%rsi,%rdi,8),%rdx /* %rdx = envp = (8*rdi)+%rsi+8 */ 22 | 23 | movq %rdx, environ(%rip) 24 | 25 | call main 26 | 27 | movq %rax, %rdi /* return value */ 28 | 29 | _exit: mov $NR_exit, %ax /* call _exit */ 30 | movzwl %ax, %eax 31 | mov %rcx, %r10 32 | syscall 33 | hlt /* catch fire and die */ 34 | 35 | .type _exit,@function 36 | .size _exit,.-_exit 37 | 38 | .type _start,@function 39 | .size _start,_exit-_start 40 | -------------------------------------------------------------------------------- /libc/x86_64/_syscall.s: -------------------------------------------------------------------------------- 1 | .bss 2 | .global errno 3 | 4 | errno: .int 0 5 | 6 | .type errno,@object 7 | .size errno,.-errno 8 | 9 | 10 | .text 11 | .global _syscall 12 | .global _sysret 13 | .global _syscallx 14 | 15 | _syscall: 16 | mov $0, %ah 17 | _syscallx: 18 | movzwl %ax, %eax 19 | mov %rcx, %r10 20 | 21 | syscall 22 | _sysret: /* vfork jumps here */ 23 | cmpq $-132, %rax 24 | jbe ok 25 | negl %eax 26 | movl %eax, errno 27 | orq $-1, %rax 28 | ok: ret 29 | 30 | .type _syscall,@function 31 | .size _syscall,.-_syscall 32 | 33 | .type _syscallx,@function 34 | .size _syscallx,0 35 | -------------------------------------------------------------------------------- /libc/x86_64/accept.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_accept, 43 3 | 4 | .text 5 | .global accept 6 | 7 | accept: 8 | mov $NR_accept, %al 9 | jmp _syscall 10 | 11 | .type accept,@function 12 | .size accept,.-accept 13 | -------------------------------------------------------------------------------- /libc/x86_64/bind.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_bind, 49 3 | 4 | .text 5 | .global bind 6 | 7 | bind: 8 | mov $NR_bind, %al 9 | jmp _syscall 10 | 11 | .type bind,@function 12 | .size bind,.-bind 13 | -------------------------------------------------------------------------------- /libc/x86_64/bits/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_DIRENT_H 2 | #define BITS_DIRENT_H 3 | 4 | #include 5 | 6 | #define DT_UNKNOWN 0 7 | #define DT_FIFO 1 8 | #define DT_CHR 2 9 | #define DT_DIR 4 10 | #define DT_BLK 6 11 | #define DT_REG 8 12 | #define DT_LNK 10 13 | #define DT_SOCK 12 14 | #define DT_WHT 14 15 | 16 | struct dirent64 { 17 | uint64_t d_ino; 18 | int64_t d_off; 19 | uint16_t d_reclen; 20 | unsigned char d_type; 21 | char d_name[256]; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/x86_64/bits/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_FCNTL_H 2 | #define BITS_FCNTL_H 3 | 4 | #define O_RDONLY 00 5 | #define O_WRONLY 01 6 | #define O_RDWR 02 7 | #define O_CREAT 0100 8 | #define O_EXCL 0200 9 | #define O_NOCTTY 0400 10 | #define O_TRUNC 01000 11 | #define O_APPEND 02000 12 | #define O_NONBLOCK 04000 13 | #define O_DIRECTORY 0200000 14 | #define O_NOFOLLOW 0400000 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/x86_64/bits/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_IOCTL_H 2 | #define BITS_IOCTL_H 3 | 4 | #define TIOCSCTTY 0x540E 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/x86_64/bits/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_LIMITS_H 2 | #define BITS_LIMITS_H 3 | 4 | #define __WORDSIZE 64 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/x86_64/bits/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_MMAN_H 2 | #define BITS_MMAN_H 3 | 4 | #define MREMAP_MAYMOVE 1UL 5 | #define MREMAP_FIXED 2UL 6 | 7 | #define PROT_READ 0x1 /* page can be read */ 8 | #define PROT_WRITE 0x2 /* page can be written */ 9 | #define PROT_EXEC 0x4 /* page can be executed */ 10 | #define PROT_NONE 0x0 /* page can not be accessed */ 11 | 12 | #define MAP_SHARED 0x01 /* Share changes */ 13 | #define MAP_PRIVATE 0x02 /* Changes are private */ 14 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ 15 | 16 | #define MAP_FAILED ((void *) -1) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/x86_64/bits/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_POLL_H 2 | #define SYS_POLL_H 3 | 4 | #define POLLIN (1<<0) 5 | #define POLLPRI (1<<1) 6 | #define POLLOUT (1<<2) 7 | #define POLLERR (1<<3) 8 | #define POLLHUP (1<<4) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libc/x86_64/bits/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_SOCKET_H 2 | #define BITS_SOCKET_H 3 | 4 | #define AF_UNIX 1 5 | 6 | #define SOCK_STREAM (1<<0) 7 | #define SOCK_DGRAM (1<<1) 8 | #define SOCK_NONBLOCK (1<<11) 9 | #define SOCK_CLOEXEC (1<<19) 10 | 11 | #define SOL_SOCKET 1 12 | #define SO_PEERCRED 17 13 | 14 | #define SHUT_RD 0 15 | #define SHUT_WR 1 16 | #define SHUT_RDWR 2 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/x86_64/bits/types.h: -------------------------------------------------------------------------------- 1 | #ifndef BITS_TYPES_H 2 | #define BITS_TYPES_H 3 | 4 | typedef signed char int8_t; 5 | typedef signed short int16_t; 6 | typedef int int32_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | 12 | typedef signed long int64_t; 13 | typedef unsigned long uint64_t; 14 | 15 | typedef unsigned long size_t; 16 | typedef signed long ssize_t; 17 | typedef signed long off_t; 18 | typedef signed long long time_t; 19 | 20 | typedef int32_t pid_t; 21 | typedef uint32_t gid_t; 22 | typedef uint32_t uid_t; 23 | 24 | typedef uint32_t socklen_t; 25 | typedef uint16_t sa_family_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libc/x86_64/chdir.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chdir, 80 3 | 4 | .text 5 | .global chdir 6 | 7 | chdir: 8 | mov $NR_chdir, %al 9 | jmp _syscall 10 | 11 | .type chdir,@function 12 | .size chdir,.-chdir 13 | -------------------------------------------------------------------------------- /libc/x86_64/chroot.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_chroot, 161 3 | 4 | .text 5 | .global chroot 6 | 7 | chroot: 8 | mov $NR_chroot, %al 9 | jmp _syscall 10 | 11 | .type chroot,@function 12 | .size chroot,.-chroot 13 | -------------------------------------------------------------------------------- /libc/x86_64/clock_gettime.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_clock_gettime, 228 3 | 4 | .text 5 | .global clock_gettime 6 | 7 | clock_gettime: 8 | mov $NR_clock_gettime, %al 9 | jmp _syscall 10 | 11 | .type clock_gettime,@function 12 | .size clock_gettime,.-clock_gettime 13 | -------------------------------------------------------------------------------- /libc/x86_64/close.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_close, 3 3 | 4 | .text 5 | .global close 6 | 7 | close: 8 | mov $NR_close, %al 9 | jmp _syscall 10 | 11 | .type close,@function 12 | .size close,.-close 13 | -------------------------------------------------------------------------------- /libc/x86_64/connect.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_connect, 42 3 | 4 | .text 5 | .global connect 6 | 7 | connect: 8 | mov $NR_connect, %al 9 | jmp _syscall 10 | 11 | .type connect,@function 12 | .size connect,.-connect 13 | -------------------------------------------------------------------------------- /libc/x86_64/dup2.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_dup2, 33 3 | 4 | .text 5 | .global dup2 6 | 7 | dup2: 8 | mov $NR_dup2, %al 9 | jmp _syscall 10 | 11 | .type dup2,@function 12 | .size dup2,.-dup2 13 | -------------------------------------------------------------------------------- /libc/x86_64/execve.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_execve, 59 3 | 4 | .text 5 | .global execve 6 | 7 | execve: 8 | mov $NR_execve, %al 9 | jmp _syscall 10 | 11 | .type execve,@function 12 | .size execve,.-execve 13 | -------------------------------------------------------------------------------- /libc/x86_64/fcntl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fcntl, 72 3 | 4 | .text 5 | .global fcntl 6 | 7 | fcntl: 8 | mov $NR_fcntl, %al 9 | jmp _syscall 10 | 11 | .type fcntl,@function 12 | .size fcntl,.-fcntl 13 | -------------------------------------------------------------------------------- /libc/x86_64/fork.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fork, 57 3 | 4 | .text 5 | .global fork 6 | 7 | fork: 8 | mov $NR_fork, %al 9 | jmp _syscall 10 | 11 | .type fork,@function 12 | .size fork,.-fork 13 | -------------------------------------------------------------------------------- /libc/x86_64/fstat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_fstat, 5 3 | 4 | .text 5 | .global fstat 6 | 7 | fstat: 8 | mov $NR_fstat, %al 9 | jmp _syscall 10 | 11 | .type fstat,@function 12 | .size fstat,.-fstat 13 | -------------------------------------------------------------------------------- /libc/x86_64/getdents64.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getdents64, 217 3 | 4 | .text 5 | .global getdents64 6 | 7 | getdents64: 8 | mov $NR_getdents64, %al 9 | jmp _syscall 10 | 11 | .type getdents64,@function 12 | .size getdents64,.-getdents64 13 | -------------------------------------------------------------------------------- /libc/x86_64/getpid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getpid, 39 3 | 4 | .text 5 | .global getpid 6 | 7 | getpid: 8 | mov $NR_getpid, %al 9 | jmp _syscall 10 | 11 | .type getpid,@function 12 | .size getpid,.-getpid 13 | -------------------------------------------------------------------------------- /libc/x86_64/getsockopt.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getsockopt, 55 3 | 4 | .text 5 | .global getsockopt 6 | 7 | getsockopt: 8 | mov $NR_getsockopt, %al 9 | jmp _syscall 10 | 11 | .type getsockopt,@function 12 | .size getsockopt,.-getsockopt 13 | -------------------------------------------------------------------------------- /libc/x86_64/getuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_getuid, 102 3 | 4 | .text 5 | .global getuid 6 | 7 | getuid: 8 | mov $NR_getuid, %al 9 | jmp _syscall 10 | 11 | .type getuid,@function 12 | .size getuid,.-getuid 13 | -------------------------------------------------------------------------------- /libc/x86_64/ioctl.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_ioctl, 16 3 | 4 | .text 5 | .global ioctl 6 | 7 | ioctl: 8 | mov $NR_ioctl, %al 9 | jmp _syscall 10 | 11 | .type ioctl,@function 12 | .size ioctl,.-ioctl 13 | -------------------------------------------------------------------------------- /libc/x86_64/kill.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_kill, 62 3 | 4 | .text 5 | .global kill 6 | 7 | kill: 8 | mov $NR_kill, %al 9 | jmp _syscall 10 | 11 | .type kill,@function 12 | .size kill,.-kill 13 | -------------------------------------------------------------------------------- /libc/x86_64/listen.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_listen, 50 3 | 4 | .text 5 | .global listen 6 | 7 | listen: 8 | mov $NR_listen, %al 9 | jmp _syscall 10 | 11 | .type listen,@function 12 | .size listen,.-listen 13 | -------------------------------------------------------------------------------- /libc/x86_64/mmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mmap, 9 3 | 4 | .text 5 | .global mmap 6 | 7 | mmap: 8 | mov $NR_mmap, %al 9 | jmp _syscall 10 | 11 | .type mmap,@function 12 | .size mmap,.-mmap 13 | -------------------------------------------------------------------------------- /libc/x86_64/mremap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_mremap, 25 3 | 4 | .text 5 | .global mremap 6 | 7 | mremap: 8 | mov $NR_mremap, %al 9 | jmp _syscall 10 | 11 | .type mremap,@function 12 | .size mremap,.-mremap 13 | -------------------------------------------------------------------------------- /libc/x86_64/munmap.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_munmap, 11 3 | 4 | .text 5 | .global munmap 6 | 7 | munmap: 8 | mov $NR_munmap, %al 9 | jmp _syscall 10 | 11 | .type munmap,@function 12 | .size munmap,.-munmap 13 | -------------------------------------------------------------------------------- /libc/x86_64/nanosleep.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_nanosleep, 35 3 | 4 | .text 5 | .global nanosleep 6 | 7 | nanosleep: 8 | mov $NR_nanosleep, %al 9 | jmp _syscall 10 | 11 | .type nanosleep,@function 12 | .size nanosleep,.-nanosleep 13 | -------------------------------------------------------------------------------- /libc/x86_64/open.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_open, 2 3 | 4 | .text 5 | .global open 6 | 7 | open: 8 | mov $NR_open, %al 9 | jmp _syscall 10 | 11 | .type open,@function 12 | .size open,.-open 13 | -------------------------------------------------------------------------------- /libc/x86_64/ppoll.s: -------------------------------------------------------------------------------- 1 | .equ NR_ppoll, 271 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global ppoll 6 | 7 | ppoll: 8 | mov $sizeof_sigset_t, %r8d 9 | mov $NR_ppoll, %ax 10 | jmp _syscallx 11 | 12 | .type ppoll,@function 13 | .size ppoll,.-ppoll 14 | -------------------------------------------------------------------------------- /libc/x86_64/read.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_read, 0 3 | 4 | .text 5 | .global read 6 | 7 | read: 8 | mov $NR_read, %al 9 | jmp _syscall 10 | 11 | .type read,@function 12 | .size read,.-read 13 | -------------------------------------------------------------------------------- /libc/x86_64/reboot.s: -------------------------------------------------------------------------------- 1 | .equ NR_reboot, 169 2 | .equ LINUX_REBOOT_MAGIC1, 0xfee1dead 3 | .equ LINUX_REBOOT_MAGIC2, 672274793 4 | 5 | .text 6 | .global reboot 7 | 8 | reboot: 9 | mov %rdi, %rdx 10 | mov $LINUX_REBOOT_MAGIC1, %rdi 11 | mov $LINUX_REBOOT_MAGIC2, %rsi 12 | mov $NR_reboot, %al 13 | jmp _syscall 14 | 15 | .type reboot,@function 16 | .size reboot,.-reboot 17 | -------------------------------------------------------------------------------- /libc/x86_64/send.s: -------------------------------------------------------------------------------- 1 | .equ NR_sendto, 44 2 | 3 | .text 4 | .global send 5 | 6 | send: 7 | xor %r8d, %r8d 8 | xor %r9d, %r9d 9 | mov $NR_sendto, %al 10 | jmp _syscall 11 | 12 | .type send,@function 13 | .size send,.-send 14 | -------------------------------------------------------------------------------- /libc/x86_64/setfsgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsgid, 123 3 | 4 | .text 5 | .global setfsgid 6 | 7 | setfsgid: 8 | mov $NR_setfsgid, %al 9 | jmp _syscall 10 | 11 | .type setfsgid,@function 12 | .size setfsgid,.-setfsgid 13 | -------------------------------------------------------------------------------- /libc/x86_64/setfsuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setfsuid, 122 3 | 4 | .text 5 | .global setfsuid 6 | 7 | setfsuid: 8 | mov $NR_setfsuid, %al 9 | jmp _syscall 10 | 11 | .type setfsuid,@function 12 | .size setfsuid,.-setfsuid 13 | -------------------------------------------------------------------------------- /libc/x86_64/setitimer.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setitimer, 38 3 | 4 | .text 5 | .global setitimer 6 | 7 | setitimer: 8 | mov $NR_setitimer, %al 9 | jmp _syscall 10 | 11 | .type setitimer,@function 12 | .size setitimer,.-setitimer 13 | -------------------------------------------------------------------------------- /libc/x86_64/setpriority.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setpriority, 141 3 | 4 | .text 5 | .global setpriority 6 | 7 | setpriority: 8 | mov $NR_setpriority, %al 9 | jmp _syscall 10 | 11 | .type setpriority,@function 12 | .size setpriority,.-setpriority 13 | -------------------------------------------------------------------------------- /libc/x86_64/setresgid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresgid, 119 3 | 4 | .text 5 | .global setresgid 6 | 7 | setresgid: 8 | mov $NR_setresgid, %al 9 | jmp _syscall 10 | 11 | .type setresgid,@function 12 | .size setresgid,.-setresgid 13 | -------------------------------------------------------------------------------- /libc/x86_64/setresuid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setresuid, 117 3 | 4 | .text 5 | .global setresuid 6 | 7 | setresuid: 8 | mov $NR_setresuid, %al 9 | jmp _syscall 10 | 11 | .type setresuid,@function 12 | .size setresuid,.-setresuid 13 | -------------------------------------------------------------------------------- /libc/x86_64/setrlimit.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setrlimit, 160 3 | 4 | .text 5 | .global setrlimit 6 | 7 | setrlimit: 8 | mov $NR_setrlimit, %al 9 | jmp _syscall 10 | 11 | .type setrlimit,@function 12 | .size setrlimit,.-setrlimit 13 | -------------------------------------------------------------------------------- /libc/x86_64/setsid.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_setsid, 112 3 | 4 | .text 5 | .global setsid 6 | 7 | setsid: 8 | mov $NR_setsid, %al 9 | jmp _syscall 10 | 11 | .type setsid,@function 12 | .size setsid,.-setsid 13 | -------------------------------------------------------------------------------- /libc/x86_64/shutdown.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_shutdown, 48 3 | 4 | .text 5 | .global shutdown 6 | 7 | shutdown: 8 | mov $NR_shutdown, %al 9 | jmp _syscall 10 | 11 | .type shutdown,@function 12 | .size shutdown,.-shutdown 13 | -------------------------------------------------------------------------------- /libc/x86_64/sigprocmask.s: -------------------------------------------------------------------------------- 1 | .equ NR_rt_sigprocmask, 14 2 | .equ sizeof_sigset_t, 8 3 | 4 | .text 5 | .global sigprocmask 6 | 7 | sigprocmask: 8 | mov $sizeof_sigset_t, %rcx 9 | mov $NR_rt_sigprocmask, %al 10 | jmp _syscall 11 | 12 | .type sigprocmask,@function 13 | .size sigprocmask,.-sigprocmask 14 | -------------------------------------------------------------------------------- /libc/x86_64/socket.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_socket, 41 3 | 4 | .text 5 | .global socket 6 | 7 | socket: 8 | mov $NR_socket, %al 9 | jmp _syscall 10 | 11 | .type socket,@function 12 | .size socket,.-socket 13 | -------------------------------------------------------------------------------- /libc/x86_64/stat.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_stat, 4 3 | 4 | .text 5 | .global stat 6 | 7 | stat: 8 | mov $NR_stat, %al 9 | jmp _syscall 10 | 11 | .type stat,@function 12 | .size stat,.-stat 13 | -------------------------------------------------------------------------------- /libc/x86_64/strcmp.s: -------------------------------------------------------------------------------- 1 | .text 2 | .global strcmp 3 | 4 | strcmp: 5 | .Lloop: 6 | mov (%rdi),%al 7 | cmp (%rsi),%al 8 | jnz .Lmismatch 9 | inc %rsi 10 | inc %rdi 11 | or %al,%al 12 | jnz .Lloop 13 | /* end of string reached, return NULL */ 14 | xor %eax,%eax 15 | ret 16 | .Lmismatch: 17 | /* In the C version we return (unsigned char)*b-(unsigned char)*a 18 | but in assembler it is less trouble to return 1 or -1 19 | depending on whether the carry flag is set. 20 | The standard only wants positive, zero, or negative, so both are OK */ 21 | sbb %eax,%eax 22 | or $1,%eax 23 | ret 24 | 25 | .type strcmp,@function 26 | .size strcmp,.-strcmp 27 | -------------------------------------------------------------------------------- /libc/x86_64/umask.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_umask, 95 3 | 4 | .text 5 | .global umask 6 | 7 | umask: 8 | mov $NR_umask, %al 9 | jmp _syscall 10 | 11 | .type umask,@function 12 | .size umask,.-umask 13 | -------------------------------------------------------------------------------- /libc/x86_64/unshare.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_unshare, 272 3 | 4 | .text 5 | .global unshare 6 | 7 | unshare: 8 | mov $NR_unshare, %ax 9 | jmp _syscallx 10 | 11 | .type unshare,@function 12 | .size unshare,.-unshare 13 | -------------------------------------------------------------------------------- /libc/x86_64/vfork.s: -------------------------------------------------------------------------------- 1 | .equ NR_vfork, 58 2 | 3 | .text 4 | .global vfork 5 | 6 | vfork: 7 | mov $NR_vfork, %al 8 | pop %rdx 9 | syscall 10 | push %rdx 11 | jmp _sysret 12 | 13 | .type vfork,@function 14 | .size vfork,.-vfork 15 | -------------------------------------------------------------------------------- /libc/x86_64/waitpid.s: -------------------------------------------------------------------------------- 1 | .equ NR_wait4, 61 2 | 3 | .text 4 | .global waitpid 5 | 6 | waitpid: 7 | xor %rcx,%rcx 8 | mov $NR_wait4,%al 9 | jmp _syscall 10 | 11 | .type waitpid,@function 12 | .size waitpid,.-waitpid 13 | -------------------------------------------------------------------------------- /libc/x86_64/write.s: -------------------------------------------------------------------------------- 1 | # auto-generated, remove this line before editing 2 | .equ NR_write, 1 3 | 4 | .text 5 | .global write 6 | 7 | write: 8 | mov $NR_write, %al 9 | jmp _syscall 10 | 11 | .type write,@function 12 | .size write,.-write 13 | -------------------------------------------------------------------------------- /misc/buildroot/Config.in: -------------------------------------------------------------------------------- 1 | source "$BR2_EXTERNAL/package/sninit/Config.in" 2 | -------------------------------------------------------------------------------- /misc/buildroot/README: -------------------------------------------------------------------------------- 1 | Buildroot external configuration (BR2_EXTERNAL) for sninit-based 2 | bootable qemu images. See ../../doc/buildroot.txt for more info. 3 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/post_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | target="$1" 4 | arch="$2" 5 | external="$3" 6 | 7 | if [ -n "$arch" -a -n "$external" ]; then 8 | qemu="$external/board/sninit/qemu_$arch.sh" 9 | if [ -f "$qemu" ]; then 10 | if [ ! -e "./qemu" -o -h "./qemu" ]; then 11 | ln -sf "$qemu" "./qemu" 12 | fi 13 | fi 14 | fi 15 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/qemu_aarch64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qemu-system-aarch64 \ 4 | -M virt \ 5 | -cpu cortex-a57 \ 6 | -display none \ 7 | -smp 1 \ 8 | -kernel output/images/Image \ 9 | -append "console=ttyAMA0" \ 10 | -serial stdio \ 11 | -device virtio-net-device,netdev=eth0 \ 12 | -netdev user,id=eth0,hostfwd=tcp:127.0.0.1:1234-:1234 13 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/qemu_arm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qemu-system-arm \ 4 | -M vexpress-a9 \ 5 | -kernel output/images/zImage \ 6 | -dtb output/images/vexpress-v2p-ca9.dtb \ 7 | -sd output/images/rootfs.ext2 \ 8 | -append "root=/dev/mmcblk0" \ 9 | -serial pty \ 10 | -net nic \ 11 | -net user,id=eth0,hostfwd=tcp:127.0.0.1:1234-:1234 12 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/qemu_mips.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Malta apparently lacks graphical output, so use serial console instead. 4 | 5 | qemu-system-mips \ 6 | -M malta \ 7 | -display none \ 8 | -kernel output/images/vmlinux \ 9 | -serial stdio \ 10 | -hda output/images/rootfs.ext2 \ 11 | -append "root=/dev/hda" \ 12 | -net nic,model=pcnet \ 13 | -net user,id=eth0,hostfwd=tcp:127.0.0.1:1234-:1234 14 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/qemu_x86.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qemu-system-i386 \ 4 | -M pc \ 5 | -kernel output/images/bzImage \ 6 | -drive file=output/images/rootfs.ext2,if=ide,format=raw \ 7 | -append "root=/dev/sda" \ 8 | -serial pty\ 9 | -net nic,model=rtl8139 \ 10 | -net user,id=eth0,hostfwd=tcp:127.0.0.1:1234-:1234 11 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/qemu_x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qemu-system-x86_64 \ 4 | -kernel output/images/bzImage \ 5 | -drive file=output/images/rootfs.ext2,if=ide,format=raw \ 6 | -append "root=/dev/sda" \ 7 | -serial pty \ 8 | -net nic,model=rtl8139 \ 9 | -net user,id=eth0,hostfwd=tcp:127.0.0.1:1234-:1234 10 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/root.aarch64/etc/inittab: -------------------------------------------------------------------------------- 1 | PATH=/bin:/sbin 2 | 3 | proc R /bin/mount -t proc proc /proc 4 | pts R /bin/mkdir -p /dev/pts 5 | shm R /bin/mkdir -p /dev/shm 6 | host R /bin/hostname -F /etc/hostname 7 | 8 | syslog L /sbin/syslogd -n 9 | klogd S /sbin/klogd -nc1 10 | dhcp L /sbin/run -n /sbin/udhcpc -fRS eth0 11 | 12 | ttyS T /sbin/getty -L ttyAMA0 115200 vt100 13 | 14 | # vim: ft=conf: 15 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/root.aarch64/setup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | /bin/mount -t devtmpfs devtmpfs /dev 3 | /sbin/ifconfig eth0 10.0.2.15 up 4 | /sbin/route add default gw 10.0.2.2 dev eth0 5 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/root.mips/etc/inittab: -------------------------------------------------------------------------------- 1 | PATH=/bin:/sbin 2 | 3 | proc R /bin/mount -t proc proc /proc 4 | pts R /bin/mkdir -p /dev/pts 5 | shm R /bin/mkdir -p /dev/shm 6 | mount W /bin/mount -o remount,rw / 7 | host R /bin/hostname -F /etc/hostname 8 | 9 | syslog L /sbin/syslogd -n 10 | klogd S /sbin/klogd -nc1 11 | dhcp L /sbin/run -n /sbin/udhcpc -fRS eth0 12 | 13 | ttyS T /sbin/getty -L ttyS0 115200 vt100 14 | 15 | umount X /bin/umount -ar 16 | 17 | # vim: ft=conf: 18 | -------------------------------------------------------------------------------- /misc/buildroot/board/sninit/root/etc/inittab: -------------------------------------------------------------------------------- 1 | PATH=/bin:/sbin 2 | 3 | proc R /bin/mount -t proc proc /proc 4 | pts R /bin/mkdir -p /dev/pts 5 | shm R /bin/mkdir -p /dev/shm 6 | mount W /bin/mount -o remount,rw / 7 | host R /bin/hostname -F /etc/hostname 8 | 9 | syslog L /sbin/syslogd -n 10 | klogd S /sbin/klogd -nc1 11 | dhcp L /sbin/run -n /sbin/udhcpc -fRS eth0 12 | 13 | tty1 T /sbin/getty -L tty1 115200 linux 14 | tty2 T /sbin/getty -L tty2 115200 linux 15 | tty3 T /sbin/getty -L tty3 115200 linux 16 | 17 | umount X /bin/umount -ar 18 | 19 | # vim: ft=conf: 20 | -------------------------------------------------------------------------------- /misc/buildroot/configs/sninit_aarch64_defconfig: -------------------------------------------------------------------------------- 1 | BR2_aarch64=y 2 | BR2_KERNEL_HEADERS_VERSION=y 3 | BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_3=y 4 | BR2_PACKAGE_HOST_GDB=y 5 | BR2_INIT_NONE=y 6 | BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 7 | BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/board/sninit/root.aarch64" 8 | BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/sninit/post_build.sh" 9 | BR2_ROOTFS_POST_SCRIPT_ARGS="aarch64 $(BR2_EXTERNAL)" 10 | BR2_LINUX_KERNEL=y 11 | BR2_LINUX_KERNEL_CUSTOM_VERSION=y 12 | BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.3" 13 | BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 14 | BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux-4.3.config" 15 | BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y 16 | BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="Image" 17 | BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y 18 | BR2_PACKAGE_GDB=y 19 | BR2_PACKAGE_DROPBEAR=y 20 | BR2_PACKAGE_NETCAT=y 21 | BR2_TARGET_ROOTFS_INITRAMFS=y 22 | # BR2_TARGET_ROOTFS_TAR is not set 23 | BR2_PACKAGE_SNINIT=y 24 | -------------------------------------------------------------------------------- /misc/buildroot/configs/sninit_arm_defconfig: -------------------------------------------------------------------------------- 1 | BR2_arm=y 2 | BR2_cortex_a9=y 3 | BR2_ARM_ENABLE_NEON=y 4 | BR2_ARM_FPU_VFPV3=y 5 | BR2_PTHREAD_DEBUG=y 6 | BR2_PACKAGE_HOST_GDB=y 7 | BR2_INIT_NONE=y 8 | BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 9 | BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/board/sninit/root" 10 | BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/sninit/post_build.sh" 11 | BR2_ROOTFS_POST_SCRIPT_ARGS="arm $(BR2_EXTERNAL)" 12 | BR2_LINUX_KERNEL=y 13 | BR2_LINUX_KERNEL_SAME_AS_HEADERS=y 14 | BR2_LINUX_KERNEL_DEFCONFIG="vexpress" 15 | BR2_LINUX_KERNEL_ZIMAGE=y 16 | BR2_LINUX_KERNEL_DTS_SUPPORT=y 17 | BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9" 18 | BR2_PACKAGE_GDB=y 19 | BR2_PACKAGE_DROPBEAR=y 20 | # BR2_PACKAGE_DROPBEAR_CLIENT is not set 21 | BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS=y 22 | BR2_TARGET_ROOTFS_EXT2=y 23 | # BR2_TARGET_ROOTFS_TAR is not set 24 | BR2_PACKAGE_SNINIT=y 25 | -------------------------------------------------------------------------------- /misc/buildroot/configs/sninit_mips_defconfig: -------------------------------------------------------------------------------- 1 | BR2_mips=y 2 | BR2_TOOLCHAIN_BUILDROOT_GLIBC=y 3 | BR2_PACKAGE_HOST_GDB=y 4 | BR2_INIT_NONE=y 5 | BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" 6 | BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/board/sninit/root.mips" 7 | BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/sninit/post_build.sh" 8 | BR2_ROOTFS_POST_SCRIPT_ARGS="mips $(BR2_EXTERNAL)" 9 | BR2_LINUX_KERNEL=y 10 | BR2_LINUX_KERNEL_CUSTOM_VERSION=y 11 | BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.3" 12 | BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 13 | BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/mips-malta/linux-4.3.config" 14 | BR2_PACKAGE_GDB=y 15 | BR2_PACKAGE_DROPBEAR=y 16 | # BR2_PACKAGE_DROPBEAR_CLIENT is not set 17 | BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS=y 18 | BR2_TARGET_ROOTFS_EXT2=y 19 | # BR2_TARGET_ROOTFS_TAR is not set 20 | BR2_PACKAGE_SNINIT=y 21 | -------------------------------------------------------------------------------- /misc/buildroot/configs/sninit_x86_64_defconfig: -------------------------------------------------------------------------------- 1 | BR2_x86_64=y 2 | BR2_TOOLCHAIN_BUILDROOT_GLIBC=y 3 | BR2_INIT_NONE=y 4 | BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" 5 | BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/board/sninit/root" 6 | BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/sninit/post_build.sh" 7 | BR2_ROOTFS_POST_SCRIPT_ARGS="x86_64 $(BR2_EXTERNAL)" 8 | BR2_LINUX_KERNEL=y 9 | BR2_LINUX_KERNEL_CUSTOM_VERSION=y 10 | BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.3" 11 | BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 12 | BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux-4.3.config" 13 | BR2_PACKAGE_GDB=y 14 | BR2_PACKAGE_DROPBEAR=y 15 | # BR2_PACKAGE_DROPBEAR_CLIENT is not set 16 | BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS=y 17 | BR2_TARGET_ROOTFS_EXT2=y 18 | # BR2_TARGET_ROOTFS_TAR is not set 19 | BR2_PACKAGE_SNINIT=y 20 | -------------------------------------------------------------------------------- /misc/buildroot/configs/sninit_x86_defconfig: -------------------------------------------------------------------------------- 1 | BR2_x86_nocona=y 2 | BR2_TOOLCHAIN_BUILDROOT_GLIBC=y 3 | BR2_PACKAGE_HOST_GDB=y 4 | BR2_INIT_NONE=y 5 | BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" 6 | BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/board/sninit/root" 7 | BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/sninit/post_build.sh" 8 | BR2_ROOTFS_POST_SCRIPT_ARGS="x86 $(BR2_EXTERNAL)" 9 | BR2_LINUX_KERNEL=y 10 | BR2_LINUX_KERNEL_CUSTOM_VERSION=y 11 | BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.3" 12 | BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 13 | BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86/linux-4.3.config" 14 | BR2_PACKAGE_GDB=y 15 | BR2_PACKAGE_DROPBEAR=y 16 | # BR2_PACKAGE_DROPBEAR_CLIENT is not set 17 | BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS=y 18 | BR2_TARGET_ROOTFS_EXT2=y 19 | # BR2_TARGET_ROOTFS_TAR is not set 20 | BR2_PACKAGE_SNINIT=y 21 | -------------------------------------------------------------------------------- /misc/buildroot/external.mk: -------------------------------------------------------------------------------- 1 | include $(sort $(wildcard $(BR2_EXTERNAL)/package/*/*.mk)) 2 | -------------------------------------------------------------------------------- /misc/dietlibc/0002-mips-syscall.patch: -------------------------------------------------------------------------------- 1 | From 30cea8cba051b8cdb9dd4a073bb744f0daace24a Mon Sep 17 00:00:00 2001 2 | From: Alex Suykov 3 | Date: Tue, 30 Dec 2014 23:24:08 +0200 4 | Subject: [PATCH 2/7] mips: syscall() 5 | 6 | --- 7 | libcompat/syscall.S | 14 ++++++++++++++ 8 | 1 file changed, 14 insertions(+) 9 | 10 | diff --git a/libcompat/syscall.S b/libcompat/syscall.S 11 | index 5743000..3884329 100644 12 | --- a/libcompat/syscall.S 13 | +++ b/libcompat/syscall.S 14 | @@ -129,6 +129,20 @@ syscall: 15 | mr %r8,%r9 16 | b __unified_syscall 17 | 18 | +#elif defined(__mips__) 19 | + move $2, $4 20 | + move $4, $5 21 | + move $5, $6 22 | + move $6, $7 23 | + lw $7, 16($29) 24 | + lw $25, 20($29) 25 | + sw $25, 16($29) 26 | + lw $25, 24($29) 27 | + sw $25, 20($29) 28 | + syscall 29 | + la $25, __unified_syscall 30 | + jr $25 31 | + 32 | #else 33 | #include 34 | .section .comment 35 | -- 36 | 2.0.3 37 | 38 | -------------------------------------------------------------------------------- /misc/dietlibc/0003-mips-TLS-register.patch: -------------------------------------------------------------------------------- 1 | From c4e87b3af4728da52209d52609829401e28f7db8 Mon Sep 17 00:00:00 2001 2 | From: Alex Suykov 3 | Date: Tue, 30 Dec 2014 23:25:14 +0200 4 | Subject: [PATCH 3/7] mips: TLS register 5 | 6 | --- 7 | include/sys/tls.h | 4 ++++ 8 | 1 file changed, 4 insertions(+) 9 | 10 | diff --git a/include/sys/tls.h b/include/sys/tls.h 11 | index c3137ac..9c1d7cb 100644 12 | --- a/include/sys/tls.h 13 | +++ b/include/sys/tls.h 14 | @@ -71,6 +71,10 @@ int arch_prctl(unsigned int what, void* where); 15 | 16 | #define __ABI_TLS_REGISTER "%g7" 17 | 18 | +#elif defined(__mips__) 19 | + 20 | +#define __ABI_TLS_REGISTER "$29" 21 | + 22 | #elif defined(__arm__) 23 | 24 | void __arm_set_tls(void *); 25 | -- 26 | 2.0.3 27 | 28 | -------------------------------------------------------------------------------- /misc/dietlibc/0005-arm-syscall.patch: -------------------------------------------------------------------------------- 1 | From 8037fecaf72a59835d66585b19ca09c4df12c09a Mon Sep 17 00:00:00 2001 2 | From: Alex Suykov 3 | Date: Wed, 31 Dec 2014 11:21:44 +0200 4 | Subject: [PATCH 5/7] arm: syscall() 5 | 6 | --- 7 | libcompat/syscall.S | 12 ++++++++++++ 8 | 1 file changed, 12 insertions(+) 9 | 10 | diff --git a/libcompat/syscall.S b/libcompat/syscall.S 11 | index 3884329..c0a7b3e 100644 12 | --- a/libcompat/syscall.S 13 | +++ b/libcompat/syscall.S 14 | @@ -143,6 +143,18 @@ syscall: 15 | la $25, __unified_syscall 16 | jr $25 17 | 18 | +#elif defined(__arm__) && defined __ARM_EABI__ 19 | + stmfd sp!,{r4,r5,r7,lr} 20 | + mov r7, r0 21 | + mov r0, r1 22 | + mov r1, r2 23 | + mov r2, r3 24 | + ldr r3, [sp,#16] 25 | + ldr r4, [sp,#20] 26 | + ldr r5, [sp,#24] 27 | + swi 0 28 | + b __unified_syscall 29 | + 30 | #else 31 | #include 32 | .section .comment 33 | -- 34 | 2.0.3 35 | 36 | -------------------------------------------------------------------------------- /misc/dietlibc/0007-mips-SOCK_NONBLOCK-is-0200-O_NONBLOCK-is-080.patch: -------------------------------------------------------------------------------- 1 | From 19a95c61bdec6f179ef35f64fe953b589018002a Mon Sep 17 00:00:00 2001 2 | From: Alex Suykov 3 | Date: Wed, 31 Dec 2014 17:33:21 +0200 4 | Subject: [PATCH 7/7] mips: SOCK_NONBLOCK is 0200 (O_NONBLOCK is 080) 5 | 6 | --- 7 | include/sys/socket.h | 2 ++ 8 | 1 file changed, 2 insertions(+) 9 | 10 | diff --git a/include/sys/socket.h b/include/sys/socket.h 11 | index 64d801d..69b8dda 100644 12 | --- a/include/sys/socket.h 13 | +++ b/include/sys/socket.h 14 | @@ -322,6 +322,8 @@ __BEGIN_DECLS 15 | 16 | #if defined(__hppa__) || defined(__alpha__) 17 | #define SOCK_NONBLOCK 0x40000000 18 | +#elif defined(__mips__) 19 | +#define SOCK_NONBLOCK 0x00000200 20 | #else 21 | #define SOCK_NONBLOCK O_NONBLOCK 22 | #endif 23 | -- 24 | 2.0.3 25 | 26 | -------------------------------------------------------------------------------- /misc/dietlibc/README: -------------------------------------------------------------------------------- 1 | Patches for dietlibc-0.33 adding/fixing some stuff needed for sninit. 2 | Dietlibc with these pathes applied is called dietlibc-fixed in configure. 3 | 4 | The patches have been merged into https://github.com/ensc/dietlibc 5 | and some of the issues are now also fixed in the mainline CVS. 6 | 7 | All this barely make sense now with the bundled libc available. 8 | -------------------------------------------------------------------------------- /misc/service/README: -------------------------------------------------------------------------------- 1 | This directory contains initdir files for various daemons. 2 | 3 | Do check commands and paths before using any of them! 4 | These files were made for Buildroot, other distributions may have 5 | executables and/or config files installed in different locations. 6 | 7 | To use, copy to target system's initdir (/etc/rc or /etc/initdir). 8 | -------------------------------------------------------------------------------- /misc/service/acpid: -------------------------------------------------------------------------------- 1 | /usr/sbin/acpid -f -n 2 | -------------------------------------------------------------------------------- /misc/service/atd: -------------------------------------------------------------------------------- 1 | /usr/sbin/atd -f 2 | -------------------------------------------------------------------------------- /misc/service/avahi: -------------------------------------------------------------------------------- 1 | /usr/sbin/avahi-daemon -s 2 | -------------------------------------------------------------------------------- /misc/service/bandwidthd: -------------------------------------------------------------------------------- 1 | /usr/bin/bandwidthd -D 2 | -------------------------------------------------------------------------------- /misc/service/chrony: -------------------------------------------------------------------------------- 1 | /usr/bin/chronyd -n 2 | -------------------------------------------------------------------------------- /misc/service/connman: -------------------------------------------------------------------------------- 1 | /usr/bin/connmand -n 2 | -------------------------------------------------------------------------------- /misc/service/dbus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/sbin/dbus-uuidgen --ensure 4 | exec /usr/sbin/dbus-daemon --system --nofork 5 | -------------------------------------------------------------------------------- /misc/service/dcron: -------------------------------------------------------------------------------- 1 | /usr/sbin/crond -f -S 2 | -------------------------------------------------------------------------------- /misc/service/dnsmasq: -------------------------------------------------------------------------------- 1 | /usr/sbin/dnsmasq -k 2 | -------------------------------------------------------------------------------- /misc/service/dropbear: -------------------------------------------------------------------------------- 1 | /sbin/run -m077 /usr/sbin/dropbear -F -R 2 | -------------------------------------------------------------------------------- /misc/service/ejabberd: -------------------------------------------------------------------------------- 1 | /usr/bin/ejabberd 2 | -------------------------------------------------------------------------------- /misc/service/exim: -------------------------------------------------------------------------------- 1 | /usr/bin/exim -bdf 2 | -------------------------------------------------------------------------------- /misc/service/haveged: -------------------------------------------------------------------------------- 1 | /usr/sbin/haveged -w 1024 -r 0 -F 2 | -------------------------------------------------------------------------------- /misc/service/iiod: -------------------------------------------------------------------------------- 1 | /usr/sbin/iiod 2 | -------------------------------------------------------------------------------- /misc/service/inadyn: -------------------------------------------------------------------------------- 1 | /usr/bin/inadyn 2 | -------------------------------------------------------------------------------- /misc/service/inputevd: -------------------------------------------------------------------------------- 1 | /usr/bin/input-event-daemon --no-daemon 2 | -------------------------------------------------------------------------------- /misc/service/irqbalance: -------------------------------------------------------------------------------- 1 | /usr/sbin/irqbalance --foreground 2 | -------------------------------------------------------------------------------- /misc/service/kodi: -------------------------------------------------------------------------------- 1 | /usr/lib/xbmc/xbmc.bin --standalone -fs -n 2 | -------------------------------------------------------------------------------- /misc/service/lighttpd: -------------------------------------------------------------------------------- 1 | /usr/sbin/lighttpd-angel -f /etc/lighttpd/lighttpd.conf -D 2 | -------------------------------------------------------------------------------- /misc/service/mongoose: -------------------------------------------------------------------------------- 1 | /usr/sbin/mongoose 2 | -------------------------------------------------------------------------------- /misc/service/mpd: -------------------------------------------------------------------------------- 1 | /usr/bin/mpd --no-daemon 2 | -------------------------------------------------------------------------------- /misc/service/mysqld: -------------------------------------------------------------------------------- 1 | /sbin/run -umysql -gmysql /usr/bin/mysqld 2 | -------------------------------------------------------------------------------- /misc/service/neard: -------------------------------------------------------------------------------- 1 | /usr/libexec/nfc/neard -d '*' 2 | -------------------------------------------------------------------------------- /misc/service/netatalk: -------------------------------------------------------------------------------- 1 | /usr/sbin/netatalk -d 2 | -------------------------------------------------------------------------------- /misc/service/netman: -------------------------------------------------------------------------------- 1 | /usr/sbin/NetworkManager --no-daemon 2 | -------------------------------------------------------------------------------- /misc/service/netplug: -------------------------------------------------------------------------------- 1 | /sbin/netplugd -F 2 | -------------------------------------------------------------------------------- /misc/service/nginx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec /usr/sbin/nginx -g 'daemon off; master_process on;' 4 | -------------------------------------------------------------------------------- /misc/service/nmbd: -------------------------------------------------------------------------------- 1 | # Samba NMB daemon 2 | 3 | /usr/sbin/nmbd -F 4 | -------------------------------------------------------------------------------- /misc/service/ntpd: -------------------------------------------------------------------------------- 1 | /usr/sbin/ntpd -g -n 2 | -------------------------------------------------------------------------------- /misc/service/ofono: -------------------------------------------------------------------------------- 1 | /usr/sbin/ofonod -n 2 | -------------------------------------------------------------------------------- /misc/service/olsrd: -------------------------------------------------------------------------------- 1 | /usr/sbin/olsrd -nofork 2 | -------------------------------------------------------------------------------- /misc/service/openntpd: -------------------------------------------------------------------------------- 1 | # ntpd from openntpd package 2 | 3 | /usr/sbin/ntpd -s -d 4 | -------------------------------------------------------------------------------- /misc/service/postgresql: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # PostgreSQL database server 3 | 4 | test -f /var/lib/pgsql/PG_VERSION || /usr/bin/initdb -D /var/lib/pgsql 5 | exec /sbin/run -upostgres -gpostgres /usr/bin/postmaster -D /var/lib/pgsql 6 | -------------------------------------------------------------------------------- /misc/service/proftpd: -------------------------------------------------------------------------------- 1 | /usr/sbin/proftpd -n -q 2 | -------------------------------------------------------------------------------- /misc/service/ptpd: -------------------------------------------------------------------------------- 1 | # ptpd version 1.x 2 | 3 | /usr/sbin/ptpd -c -S 4 | -------------------------------------------------------------------------------- /misc/service/ptpd2: -------------------------------------------------------------------------------- 1 | # ptpd version 2.x 2 | 3 | /usr/sbin/ptpd2 -C -s 4 | -------------------------------------------------------------------------------- /misc/service/pulseaudio: -------------------------------------------------------------------------------- 1 | /sbin/run -m077 /usr/bin/pulseaudio --system 2 | -------------------------------------------------------------------------------- /misc/service/smbd: -------------------------------------------------------------------------------- 1 | # Samba SMB daemon 2 | 3 | /usr/sbin/smbd -F 4 | -------------------------------------------------------------------------------- /misc/service/squid: -------------------------------------------------------------------------------- 1 | /usr/sbin/squid -N 2 | -------------------------------------------------------------------------------- /misc/service/sshd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # OpenSSH server daemon 3 | 4 | /usr/bin/ssh-keygen -A 5 | exec /usr/sbin/sshd -D -e 6 | -------------------------------------------------------------------------------- /misc/service/supervisord: -------------------------------------------------------------------------------- 1 | /usr/bin/supervisord -n 2 | -------------------------------------------------------------------------------- /misc/service/thd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Triggerhappy daemon 3 | 4 | /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d --socket /var/run/thd.socket --user nobody /dev/input/event* 5 | -------------------------------------------------------------------------------- /misc/service/tinyhttpd: -------------------------------------------------------------------------------- 1 | /usr/sbin/tinyhttpd 2 | -------------------------------------------------------------------------------- /misc/service/transmission: -------------------------------------------------------------------------------- 1 | /sbin/run -udefault /usr/bin/transmission-daemon -f 2 | -------------------------------------------------------------------------------- /misc/service/tvheadend: -------------------------------------------------------------------------------- 1 | /sbin/run -utvheadend -gtvheadend /usr/sbin/tvheadend 2 | -------------------------------------------------------------------------------- /misc/service/vsftpd: -------------------------------------------------------------------------------- 1 | /usr/bin/vsftpd /etc/vsftpd.conf -obackground=NO 2 | -------------------------------------------------------------------------------- /run.h: -------------------------------------------------------------------------------- 1 | /* Logging directory */ 2 | #define LOGDIR "/var/log" 3 | 4 | /* CGroups mount dir */ 5 | #define CGBASE "/sys/fs/cgroup" 6 | /* Now technically this is incorrect, cgroups can be mounted at any location. 7 | libcgroup uses /etc/cgconfig.conf to find the path, a C-syntax file with 8 | nested blocks for no apparent reason. Parsing that in a small utility does 9 | not look like a good idea. 10 | However, for a given system, it's probably safe to assume the path is fixed. */ 11 | 12 | /* Size limit for mmaped /etc/passwd and /etc/group */ 13 | #define MAXFILELEN 65536 14 | /* Maximum number of secondary groups */ 15 | #define MAXGROUPS 20 16 | -------------------------------------------------------------------------------- /sbin/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -g -Wall 3 | 4 | all = trap slogdg slogst logger 5 | 6 | all: $(all) 7 | 8 | trap: trap.c 9 | 10 | slogdg: slogdg.c 11 | 12 | slogst: slogst.c 13 | 14 | logger: logger.c 15 | 16 | %: %.c 17 | $(CC) $(CFLAGS) -o $@ $< 18 | 19 | clean: 20 | rm -f *.o $(all) devlog daemon.log 21 | -------------------------------------------------------------------------------- /sbin/hwclock: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "+++ setting hw clock" 4 | -------------------------------------------------------------------------------- /sbin/mount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "+++ mounting root" 4 | -------------------------------------------------------------------------------- /sbin/net: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case "$1" in 4 | up|down) 5 | echo "+++ bringing network $1" 6 | ;; 7 | esac 8 | -------------------------------------------------------------------------------- /sbin/sleep: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "+++ going to sleep" 4 | sleep $1 5 | echo "+++ waking up" 6 | -------------------------------------------------------------------------------- /sbin/umount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "+++ umounting root" 4 | -------------------------------------------------------------------------------- /sys_err_run.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* Error messages for run. See sys_err_init.c for explanation. */ 5 | /* This is similar to telinit */ 6 | 7 | extern char* ltoa(long n); 8 | 9 | #define r(sym) case sym: return #sym 10 | 11 | char* strerror(int err) 12 | { 13 | switch(err) { 14 | r(EAGAIN); /* setresuid */ 15 | r(EPERM); /* setresuid */ 16 | r(EFAULT); /* open */ 17 | r(EINVAL); /* any, bad news */ 18 | r(ELOOP); /* open, unlikely */ 19 | r(EACCES); /* open */ 20 | r(EISDIR); /* open */ 21 | r(EMFILE); /* open */ 22 | r(ENFILE); /* open */ 23 | r(ENOENT); /* open */ 24 | r(ENOMEM); /* open */ 25 | r(ENAMETOOLONG);/* open, unlikely */ 26 | r(ENODEV); /* mmap */ 27 | r(EOVERFLOW); /* mmap */ 28 | r(EINTR); /* write? */ 29 | r(EIO); /* fstat, write */ 30 | r(EBADF); /* fstat, mmap */ 31 | default: return ltoa(err); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /sys_getdents.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include "sys.h" 6 | 7 | /* This should only be needed with glibc, other libc implementations 8 | provide proper direct getdents syscall. */ 9 | 10 | struct dirent64; 11 | 12 | int getdents64(int fd, struct dirent64 *dirp, size_t count) 13 | { 14 | return syscall(__NR_getdents64, fd, dirp, count); 15 | } 16 | -------------------------------------------------------------------------------- /sys_ppoll.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | /* For non-patched dietlibc. Do not forget to include -lcompat in LIBS. */ 6 | 7 | int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts, const sigset_t *sigmask) 8 | { 9 | return syscall(__NR_ppoll, fds, nfds, timeout_ts, sigmask, _NSIG/8); 10 | } 11 | -------------------------------------------------------------------------------- /sys_unshare.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | /* For non-patched dietlibc. Do not forget to include -lcompat in LIBS. */ 6 | 7 | int unshare(int flags) 8 | { 9 | return syscall(__NR_unshare, flags); 10 | } 11 | -------------------------------------------------------------------------------- /test/_stub.c: -------------------------------------------------------------------------------- 1 | int currlevel = 0; 2 | int nextlevel = 0; 3 | int warnfd = 2; 4 | int syslogfd = -1; 5 | 6 | void* cfg = (void*)0; 7 | 8 | extern void nocall(const char* func) __attribute__((noreturn)); 9 | 10 | #define STUB(fun) \ 11 | void fun(void) { nocall(#fun); } 12 | 13 | STUB(configure); 14 | STUB(setnewconf); 15 | 16 | STUB(initpass); 17 | STUB(waitpids); 18 | 19 | STUB(setinitctl); 20 | STUB(acceptctl); 21 | 22 | STUB(spawn); 23 | STUB(stop); 24 | STUB(levelmatch); 25 | 26 | STUB(parsecmd); 27 | STUB(dumpstate); 28 | STUB(dumpidof); 29 | 30 | STUB(findentry); 31 | 32 | STUB(finishinittab); 33 | STUB(rewirepointers); 34 | STUB(setrunflags); 35 | 36 | STUB(readinittab); 37 | STUB(readinitdir); 38 | 39 | STUB(extendblock); 40 | -------------------------------------------------------------------------------- /test/addenviron.c: -------------------------------------------------------------------------------- 1 | #include "../init.h" 2 | #include "../init_conf.h" 3 | #include "_test.h" 4 | 5 | char* test_env[] = { 6 | "PATH=/bin", 7 | "LANG=C", 8 | NULL 9 | }; 10 | 11 | #define SN(p) ((struct stringnode*) p) 12 | 13 | int main(void) 14 | { 15 | int hdrsize = sizeof(struct config) + sizeof(struct scratch); 16 | ZERO(mmapblock(hdrsize)); 17 | 18 | ASSERT(addenviron("PATH=/bin") >= 0); 19 | ASSERT(addenviron("LANG=C") >= 0); 20 | 21 | finishinittab(); 22 | rewirepointers(); 23 | 24 | ASSERT(NCF->env != NULL); 25 | INBLOCK(newblock, NCF->env); 26 | 27 | STREQUALS(NCF->env[0], "PATH=/bin"); 28 | STREQUALS(NCF->env[1], "LANG=C"); 29 | ASSERT(NCF->env[2] == NULL); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /test/addparsedargv.c: -------------------------------------------------------------------------------- 1 | #include "../init.h" 2 | #include "../init_conf.h" 3 | #include "_test.h" 4 | 5 | #define asoffset(ptr) ((offset)((void*)ptr - NULL)) 6 | 7 | int main(void) 8 | { 9 | int start = 10; 10 | 11 | if(mmapblock(start)) 12 | return -1; 13 | 14 | char args[] = "blah foo\tbar "; 15 | int off = newblock.ptr; 16 | 17 | int ret = addparsedargv(args); 18 | ASSERT(ret == 0); 19 | INTEQUALS(newblock.ptr, start + 4*sizeof(char*) + 13); 20 | 21 | char** ptr = newblockptr(off, char**); 22 | ASSERT(ptr[0] == NULL + off + 4*sizeof(char*)); 23 | char* s1 = newblockptr(asoffset(ptr[0]), char*); 24 | char* s2 = newblockptr(asoffset(ptr[1]), char*); 25 | char* s3 = newblockptr(asoffset(ptr[2]), char*); 26 | STREQUALS(s1, "blah"); 27 | STREQUALS(s2, "foo"); 28 | STREQUALS(s3, "bar"); 29 | ASSERT(asoffset(ptr[3]) == 0); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /test/addstaticargv.c: -------------------------------------------------------------------------------- 1 | #include "../init.h" 2 | #include "../init_conf.h" 3 | #include "_test.h" 4 | 5 | #define count(a) (sizeof(a)/sizeof(*a)) 6 | #define asoffset(ptr) ((offset)((void*)ptr - NULL)) 7 | 8 | int main(void) 9 | { 10 | int start = 10; 11 | 12 | if(mmapblock(start)) 13 | return -1; 14 | 15 | const char* arg[] = { "foo", "bar" }; 16 | int off = newblock.ptr; 17 | 18 | int ret = addstaticargv(arg, 2); 19 | ASSERT(ret == 0); 20 | INTEQUALS(newblock.ptr, start + 3*sizeof(void*) + 8); 21 | 22 | char** ptr = newblockptr(off, char**); 23 | ASSERT(ptr[0] == NULL + off + (count(arg)+1)*sizeof(char*)); 24 | char* s1 = newblockptr(asoffset(ptr[0]), char*); 25 | char* s2 = newblockptr(asoffset(ptr[1]), char*); 26 | STREQUALS(s1, "foo"); 27 | STREQUALS(s2, "bar"); 28 | ASSERT(asoffset(ptr[2]) == 0); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /test/addstring.c: -------------------------------------------------------------------------------- 1 | #include "../init.h" 2 | #include "../init_conf.h" 3 | #include "_test.h" 4 | 5 | int main(void) 6 | { 7 | mmapblock(10); 8 | 9 | newblock.ptr = 0; 10 | ASSERT(addstring("abc") == 0); 11 | ASSERT(((char*)newblock.addr)[4] == '\0'); 12 | STREQUALS((char*)newblock.addr, "abc"); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /test/etc/initdir/disabled~: -------------------------------------------------------------------------------- 1 | this file is disabled and should not be picked up 2 | -------------------------------------------------------------------------------- /test/etc/initdir/plain: -------------------------------------------------------------------------------- 1 | plain contents 2 | -------------------------------------------------------------------------------- /test/etc/initdir/script: -------------------------------------------------------------------------------- 1 | script contents 2 | -------------------------------------------------------------------------------- /test/etc/initdir/symlink: -------------------------------------------------------------------------------- 1 | plain -------------------------------------------------------------------------------- /test/fileblock.txt: -------------------------------------------------------------------------------- 1 | line 1 2 | line 2 3 | 4 | somewhat longer line 4 5 | -------------------------------------------------------------------------------- /test/pintlen.c: -------------------------------------------------------------------------------- 1 | #include "../init.h" 2 | #include "_test.h" 3 | 4 | int currlevel; 5 | int nextlevel; 6 | struct config* cfg; 7 | 8 | int main(void) 9 | { 10 | INTEQUALS(pintlen(1), 1); 11 | INTEQUALS(pintlen(12), 2); 12 | INTEQUALS(pintlen(123), 3); 13 | INTEQUALS(pintlen(1234), 4); 14 | INTEQUALS(pintlen(12345), 5); 15 | INTEQUALS(pintlen(0), 0); 16 | INTEQUALS(pintlen(-1), 0); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/printfstat.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -n 2 | # Show all printf sequences used by specified files. 3 | # This is mostly to make sure ../libc/libtest/printf.c and ../warn.c 4 | # have required formats implemented. 5 | 6 | $seen{$&}++ foreach(/%-?[0-9]*[hl]?[a-zA-Z]/g); 7 | 8 | END { printf("%3i %s\n", $seen{$_}, $_) foreach(sort { $seen{$b} <=> $seen{$a} } keys %seen); } 9 | -------------------------------------------------------------------------------- /test/strssep.c: -------------------------------------------------------------------------------- 1 | #include "../init.h" 2 | #include "../init_conf.h" 3 | #include "_test.h" 4 | 5 | struct nblock newblock; 6 | 7 | int main(void) 8 | { 9 | char str[] = "Some words \t go here "; 10 | char* ptr = str; 11 | char* res; 12 | 13 | res = strssep(&ptr); STREQUALS(res, "Some"); 14 | res = strssep(&ptr); STREQUALS(res, "words"); 15 | res = strssep(&ptr); STREQUALS(res, "go"); 16 | res = strssep(&ptr); STREQUALS(res, "here"); 17 | res = strssep(&ptr); STREQUALS(res, NULL); 18 | ASSERT(ptr == NULL); 19 | res = strssep(&ptr); STREQUALS(res, NULL); 20 | ASSERT(ptr == NULL); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /test/xaccept.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "_test.h" 6 | 7 | /* Quick check to see whether O_NONBLOCK actually works. 8 | Control socket that is expected to be nonblocking but 9 | happens to be blocking wreaks init pretty badly. */ 10 | 11 | int main(void) 12 | { 13 | int sfd; 14 | 15 | struct sockaddr_un addr = { 16 | .sun_family = AF_UNIX, 17 | .sun_path = "\0x-accept-nonblock" 18 | }; 19 | struct sockaddr peer; 20 | size_t plen = sizeof(peer); 21 | 22 | sfd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); 23 | A(sfd > 0); 24 | T(bind(sfd, (struct sockaddr*)&addr, sizeof(addr))); 25 | 26 | A(accept(sfd, &peer, &plen) < 0); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /test/xhello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char** argv) 4 | { 5 | int l = 14; 6 | int r = write(1, "Hello, world!\n", l); 7 | 8 | if(r < 0) 9 | return -1; 10 | if(r != l) 11 | return 1 + r; 12 | else 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/xopen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | int fd = open("xopen.c", O_RDONLY); 8 | return (fd <= 0 ? 1 + errno : 0); 9 | } 10 | -------------------------------------------------------------------------------- /test/xopenread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "_test.h" 5 | 6 | int main(void) 7 | { 8 | char* file = "xopenread.txt"; 9 | char buf[100]; 10 | int len; 11 | int wrt; 12 | 13 | int fd = open(file, O_RDONLY); 14 | len = read(fd, buf, 100); 15 | if(len < 0) 16 | die("Can't read %s: %m\n", file); 17 | 18 | wrt = write(1, buf, len); 19 | 20 | if(wrt < 0) 21 | die("Can't dump data to stdout: %m\n"); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /test/xopenread.txt: -------------------------------------------------------------------------------- 1 | Blah blah blah here goes some text. 2 | Line 2. 3 | Line 3. 4 | -------------------------------------------------------------------------------- /test/xppoll.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | struct pollfd pfd = { .fd = 0, .events = POLLIN, .revents = 0 }; 10 | struct timespec pts = { 0, 500000000 }; 11 | sigset_t st; 12 | 13 | sigemptyset(&st); 14 | 15 | int r = ppoll(&pfd, 1, &pts, &st); 16 | 17 | if(r < 0 && errno != EINTR) 18 | return -errno; 19 | else if(r >= 0) 20 | return 0; 21 | else 22 | return -1; 23 | } 24 | -------------------------------------------------------------------------------- /test/xprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char** argv) 7 | { 8 | char s[] = "foobar"; 9 | int i = 1247; 10 | unsigned x = 0x123ABC; 11 | #if __WORDSIZE == 64 12 | long l = 1234567890; 13 | unsigned long lx = 0x123456789ABCDE; 14 | void* ptr = (void*)0x1122334455667788; 15 | #else 16 | long l = 12345678; 17 | unsigned long lx = 0x12345678; 18 | void* ptr = (void*)0x11223344; 19 | #endif 20 | 21 | printf("non-format string\n"); /* this is going to be puts(), thanks gcc */ 22 | printf("str: %s\n", s); 23 | printf("int: %i\n", i); 24 | printf("long: %li\n", l); 25 | printf("hex: 0x%08X\n", x); 26 | printf("long hex: 0x%lX\n", lx); 27 | printf("pointer: 0x%p\n", ptr); 28 | 29 | open("nonexistant", O_RDONLY); 30 | printf("error: %m\n"); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /test/xreboot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* Numeric values as reported by qemu-i386 -strace: 5 | 6 | LINUX_REBOOT_MAGIC1: -18751827 7 | LINUX_REBOOT_MAGIC2: 672274793 8 | RB_HALT_SYSTEM: -839974621 9 | 10 | The call *should* fail with EACCESS. */ 11 | 12 | int main(void) 13 | { 14 | if(reboot(RB_HALT_SYSTEM)) 15 | return 0; 16 | else 17 | return -errno; 18 | }; 19 | -------------------------------------------------------------------------------- /test/xvfork.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | pid_t pid; 8 | int status; 9 | char* cmd[] = { "./xhello", NULL }; 10 | char* env[] = { NULL }; 11 | 12 | if((pid = vfork()) < 0) { 13 | return 13; 14 | } else if(pid) { 15 | return (waitpid(pid, &status, 0) < 0 ? 17 : 0); 16 | } else { 17 | execve(*cmd, cmd, env); 18 | _exit(5); 19 | } 20 | 21 | return 0; 22 | } 23 | --------------------------------------------------------------------------------