A freestanding shell for TinyOS, written in C and x86-64 assembly, with no libc. It reads
a program path, forks, and runs it. The syscall stubs are hand-written in Intel-syntax
GAS. A second, pure-assembly implementation lives in pure-asm-implementation/.
- C (
shell.c) for the read-fork-exec loop. - x86-64 assembly (
sys.S) for the syscall stubs:write,read,fork,execve,waitid,exit. - A custom linker script (
custom.ld) that loads at0x10000and setsmainas the entry point. - GNU
gcc,asandld. No standard library is linked.
./build.sh # compiles and links into ./init
./init # type a program path, for example /bin/ls
build.sh compiles with -Os -fno-ident -fno-asynchronous-unwind-tables -fno-stack-protector -fomit-frame-pointer, then links with custom.ld and --strip-all
to keep the binary small.
The shell runs one loop:
- Print the
#prompt. - Read a line into a 255-byte buffer.
- Replace the trailing newline with a null byte.
fork, thenexecvethe path in the child andwaitidin the parent.
Known limits, visible in the source:
- No argument parsing. The whole line is the program path.
- No builtins and no
PATHsearch. Give a full path, for example/bin/ls. - A fixed 255-byte line buffer.
