Your executable is a SQLite database

Simon Willison's Weblog Simon Willison's Weblog

https://fzakaria.com/2026/08/23/your-executable-is-a-sqlite-database">Your executable is a SQLite database


Farid Zakaria describes a neat Linux pattern for creating a SQLite database file that can be directly used as an executable binary.


The trick sets the SQLite file format's 4-byte application ID (68 bytes into the file) to SELF, standing for Structured Executable & Linkable Format.

The various components of the ELF executable format are then arranged into a number of different SQLite tables, using https://github.com/fzakaria/selfdb/blob/main/schema/self.sql">this schema.


Their self-exec interpreter (https://github.com/fzakaria/selfdb/blob/main/loader/self-exec.c">C code here) can then extract and execute the necessary pieces.


You can additionally use a Linux mechanism called https://docs.kernel.org/admin-guide/binfmt-misc.html">binfmt_misc to teach the kernel to execute that any time it encounters an executable matching that binary pattern.

Farid uses NixOS here, but without NixOS I think registration looks something like this:


printf '%s\n' ':self:M:68:SELF::/usr/local/bin/self-exec:' \
> /proc/sys/fs/binfmt_misc/register


Via https://news.ycombinator.com/item?id=49415271">Hacker News




Tags: https://simonwillison.net/tags/c">c, https://simonwillison.net/tags/linux">linux, https://simonwillison.net/tags/sqlite">sqlite

Read full article at Simon Willison's Weblog →