commit c24ff801990d19566f05e7a00f02a53822889a0d
parent fef118f0953af066d31d0a5b886bc08be8d06f0b
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Tue, 28 Apr 2026 19:08:47 -0700
docs/LIBC.txt: split symbols into pure-code vs syscall-using
The 41 unresolved libc externs that tcc-boot2 needs cluster cleanly
into two groups: 15 entries that are pure C/asm (string/number
parsing, formatted print into a buffer, qsort, memmove) and 26 that
need a Linux syscall (the right column names which) plus errno as
a runtime data global.
Same set as before, just annotated and grouped — boot-undef.sh
still produces the bare list, so refresh by `diff`ing its output
against the lines in this file.
Diffstat:
| M | docs/LIBC.txt | | | 74 | ++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- |
1 file changed, 48 insertions(+), 26 deletions(-)
diff --git a/docs/LIBC.txt b/docs/LIBC.txt
@@ -1,31 +1,26 @@
-__assert_fail
-abort
+# Unresolved external-linkage symbols required to link tcc-boot2.
+# Sorted set difference of `&ref` vs `:def` lines in the linked.hex2
+# produced by `make tcc-boot2 ARCH=aarch64`. Refresh with:
+# scripts/boot-undef.sh > /tmp/raw && diff /tmp/raw docs/LIBC.txt
+#
+# Split by whether the implementation can be straight C/asm or needs a
+# Linux syscall — the right column names which one(s).
+#
+# Notes:
+# - errno is data, not code: a single global int that the syscall
+# wrappers must set on failure. Listed under syscall-using because
+# wiring it up is part of the same layer.
+# - `free`/`realloc` can be pure if the allocator never returns
+# pages to the kernel (free-list only); listed under syscall-using
+# because a usable libc allocator usually needs brk or mmap.
+# - The f-family (fopen/fclose/fread/fwrite/...) wraps an internal
+# FILE struct over fd-based syscalls. Each entry's syscall column
+# names the underlying syscall, not the FILE bookkeeping.
+
+# pure code (no syscalls)
atoi
-close
-errno
-execvp
-exit
-fclose
-fdopen
-fflush
-fopen
-fprintf
-fputc
-fputs
-fread
-free
-fseek
-ftell
-fwrite
-lseek
-malloc
memmove
-open
-printf
qsort
-read
-realloc
-remove
snprintf
sprintf
strchr
@@ -37,5 +32,32 @@ strtof
strtol
strtoul
strtoull
-unlink
vsnprintf
+
+# syscall-using (or runtime data)
+__assert_fail write + exit_group
+abort exit_group (or rt_sigprocmask + kill SIGABRT)
+close close
+errno (data — set by syscall wrappers on failure)
+execvp execve (+ access / faccessat for PATH lookup)
+exit exit_group
+fclose close + write (write to flush any buffered output)
+fdopen — (allocates FILE; transitively malloc -> brk/mmap)
+fflush write
+fopen open (or openat)
+fprintf write
+fputc write
+fputs write
+fread read
+free brk or mmap/munmap (allocator-dependent)
+fseek lseek
+ftell lseek (SEEK_CUR, off=0)
+fwrite write
+lseek lseek
+malloc brk or mmap
+open open (or openat)
+printf write
+read read
+realloc brk or mmap (or pure if grown in place)
+remove unlink (or unlinkat)
+unlink unlink (or unlinkat)