README (1495B)
1 libc 2 ==== 3 4 Minimal freestanding C library (libc) for Linux x86_64 built from scratch 5 without external system dependencies. 6 7 1. Description 8 -------------- 9 This project provides a lightweight, modular C library designed for learning, 10 low-level system control, and minimal binary sizes. It features a custom 11 assembly entry point (_start), System V AMD64 ABI compliance, and a flat source 12 tree where each function lives in its own file. 13 14 2. Features 15 ----------- 16 * Zero external C library or host header dependencies. 17 * Unified header file (libc.h) containing essential types and prototypes. 18 * Granular archive build (libc.a) - only referenced objects are linked. 19 * Custom entry point supporting argc, argv, and envp stack extraction. 20 21 3. Dependencies 22 --------------- 23 * mk-standalone - Plan 9 mk build engine port 24 git://git.evenfri.duckdns.org/mk-standalone.git 25 26 4. Building 27 ----------- 28 The project uses mk-standalone for build automation. 29 30 mk - build libc.a 31 mk clean - remove intermediate object files 32 mk nuke - remove object files and libc.a 33 mk rebuild - perform full clean rebuild 34 35 5. Usage Example 36 ---------------- 37 Include libc.h in your application and link against libc.a: 38 39 #include <libc.h> 40 41 int main(int argc, char *argv[], char *envp[]) { 42 char *msg = "Hello world!\n"; 43 write(stdout, msg, strlen(msg)); 44 return 0; 45 } 46 47 Compile and link using freestanding flags: 48 49 cc -ffreestanding -nostdlib -nostdinc -I. -c main.c -o main.o 50 ld -o app main.o libc.a 51