Your executable is a SQLite database

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

A working open-source pattern lets Linux executables live inside SQLite database files, executable directly via binfmt_misc, a curiosity rather than a production technique.

Read this as

Programmer Farid Zakaria built a tool called selfdb that turns a Linux executable file, a program a computer can run directly, into a SQLite database, which is the file format normally used to store data. He does this by rearranging the program's internal pieces (the ELF format) into database tables. A helper interpreter called self-exec, written in C, runs the program. It is a clever trick published on his blog, with code on GitHub.

This is a niche developer experiment, not a product: Farid Zakaria's selfdb project stores the internals of a Linux executable (ELF format) inside a SQLite database and runs it via a C interpreter called self-exec, using the kernel's binfmt_misc mechanism for registration. No performance figures, licensing details or adoption are given. Competitive and business impact is essentially nil; it matters as a technique for single-file packaging enthusiasts.

selfdb (github.com/fzakaria/selfdb) writes an executable as SQLite tables per a schema at schema/self.sql, setting the SQLite header's 4-byte application ID at byte offset 68 to the magic string SELF, so binfmt_misc can match executables by pattern. A C loader, loader/self-exec.c, extracts and runs the pieces; the author demonstrates registration on NixOS and shows a generic /proc/sys/fs/binfmt_misc/register line. No benchmarks, limitations or compatibility data are provided.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

SQLite ELF binfmt_misc NixOS Linux self-exec selfdb

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading