lpsantil/rt0
FreeA minimal C runtime for Linux i386 & x86_64
About lpsantil/rt0
rt0 is a minimal C runtime for Linux on i386 and x86_64 architectures, designed to provide the bare essentials for running C programs without a full libc. Implemented in just 202 lines of C code and only 9 lines (i386) or 6 lines (x86_64) of GCC inline assembly, it offers startup components such as argc, argv, envp, __environ, errno, _exit, and memory symbols (_end, _edata, _etext, __executable_start), along with syscall wrappers syscall0 through syscall6. It includes example implementations of sys_brk, brk, and sbrk, and can be linked with the gold linker (Google LD). A minimal "Hello World" program compiles to just 608 bytes on i386 or 792 bytes on x86_64. The runtime has been tested on RHEL 7 and Ubuntu 14.04 for both i386/i686 and x86_64. rt0 is ideal for building extremely small, statically linked Linux binaries and for educational purposes in understanding low-level program startup.
Key Features
Pros & Cons
- Extremely small code footprint (202 SLOC) makes it easy to understand and audit
- Minimal runtime dependencies – only requires a Linux kernel
- Produces very small binary sizes compared to standard libc implementations
- Supports both i386 and x86_64 architectures
- Open source with permissive BSD-2 license
- Provides essential runtime and syscall wrappers for bare-metal C programming
- Only supports Linux on i386 and x86_64 architectures
- Not a full libc – lacks standard library functions like printf, malloc, file I/O, etc.
- No dynamic linking support; only static linking is possible
- Limited testing scope (RHEL 7, Ubuntu 14.04) – may require adjustments on newer distributions
- Not suitable for complex or portable C programs that depend on libc functionality