What if the file you chmod +x and run were itself a database? Farid Zakaria’s SELF prototype (Structured Executable & Linkable Format) replaces ELF with SQLite — the executable is a real SQLite file, and every tool that reads ELF reduces to a SQL query.
The core argument: ELF is already a database that refuses to admit it.
.strtabis string interning,.gnu.hashis a hand-rolled index,st_nameoffsets are foreign keys done by hand, andstripis aDELETE+VACUUM- Every consumer — kernel,
ld.so, binutils, LIEF — re-implements the same parser against a terse, schema-less format designed for 1970s disk constraints
How SELF works:
- Two tables to run:
self_meta(the ELF header) andsegments(load image, bytes as BLOBs); symbols, imports, and exports are SQL tables and views - SQLite’s
application_idis stampedSELFat byte 68; Linuxbinfmt_miscmagic hands the file to a small C interpreter that maps segments, relocates, and jumps to entry — a miniatureld.so - An
rtld-auditlibrary answers library lookups with SQL on unmodified glibc; a prototypeself-lddoes relocation resolution entirely in SQL
The honest costs: SELF files are roughly 2× ELF (b-tree overhead) — but within 1% after stripping, since the overhead lives in optional tooling tables. Startup adds a fixed ~5 ms plus a copy of the image, because b-tree pages aren’t mmap’d and two processes don’t share text pages the way ELF does.
The payoff is the fun part:
- A closure is one file holding a program plus all transitive dependencies, with dependency resolution as actual foreign keys —
lddbecomes aJOIN - Pointed at every binary on
PATH: 723 executables and 400 libraries become 1,123 objects in one 612 MB SQLite file — smaller than the 644 MB of ELF it came from LD_PRELOADis a row in a table, so interposing a tracingmallocacross a whole userland and rolling it back is a single transaction
A radical idea backed by working code — lossless ELF round-trips, a bootable NixOS VM, real benchmarks — not a manifesto. Even if SELF never ships, the framing of ELF’s ad-hoc structures as reinvented database primitives is a useful mental model on its own.