saved
Your executable is a SQLite database
gist
Farid Zakaria argues that ELF already is a hand-rolled database, then shows SELF: a SQLite file you can chmod +x and run via binfmt_misc. Program headers become a segments table, symbols become indexed rows, and strip or patchelf become SQL transactions. A prototype packs one binary's closure—or a whole PATH of 723 programs—into one queryable database; a packed userland is smaller than the ELF files it came from. Startup pays a few milliseconds and loses shared text mappings because bytes are copied out of the b-tree.
ideas
- ELF is already a database. String tables, hash sections, and section headers reinvent interning, indexes, and a schema; every producer and parser rebuilds the same format by hand.
- An executable can be a SQLite file. Stamp application_id SELF, register binfmt_misc, and let self-exec map segment BLOBs; the interpreter itself must stay ELF to avoid ELOOP.
- Inspection and mutation become SQL. ldd, nm, and readelf reduce to queries; strip is DELETE plus VACUUM, patchelf is UPDATE, and missing columns become views.
- A closure kills soname ambiguity. Store resolved dependency paths as foreign keys so one file can hold a binary and its libraries; 723 PATH programs plus 400 libraries pack smaller than the original ELF bytes.
- The cost is startup copy, not size. A stripped coreutils SELF stays within 1% of ELF, but opening SQLite costs about 5 ms and copied b-tree pages do not share text mappings across processes.
quotes
“Not “a database that describes an executable”, but the actual file you chmod +x and run.”
“ELF is already a database. It just implements many database primitives by hand”
“strip is a DELETE and VACUUM. patchelf is an UPDATE.”
“The whole userland, as one queryable file, is smaller than the files it came from.”