selfdb README

The project's README from github.com/fzakaria/selfdb. As one markdown file: README.md.

selfdb

SELF — the Structured Executable & Linkable Format: a program that is a SQLite database instead of an ELF file, and the machinery to actually run it on Linux/NixOS.

sqlelf (arXiv:2405.03883) put a SQL view over ELF. This project inverts it: the rows are the format, a binfmt_misc interpreter executes them, and nixpkgs/NixOS is the vehicle to run a real slice of a system on it.

$ file hello
hello: SQLite 3.x database, application id 0x53454c46, user version 1
$ ./hello
Hello, world!
$ sqlite3 hello 'SELECT soname FROM ldd'          # ldd, as a query
$ sqlite3 hello 'DELETE FROM sections; VACUUM'    # strip, as a transaction
$ ./hello                                         # still runs
Hello, world!

What's here

Read DESIGN.md; §13 tracks implementation status.

Try it

$ nix develop                        # dev shell (converter + loader + tools)
$ nix develop -c bash tests/all.sh   # run M0..M3b end to end
$ nix develop -c bash tests/showcase.sh
$ nix run .#self-vm                  # a NixOS VM where ./hello.self just runs
                                     # (login: root, empty password)

$ bash examples/server/build.sh ./server   # a website, inserted into a program
$ loader/self-exec ./server 8080           # http://localhost:8080

selfdb (fzakaria/selfdb)

Searching Database…

572 ·GitHub
What is this?selfdb (SELF, Structured Executable & Linkable Format) makes a program that is literally a SQLite database instead of an ELF binary, plus the loader machinery to actually execute that database on Linux/NixOS.
Is this a library, or a file format with its own toolchain?It is a custom executable file format (rows in a SQLite DB replace ELF sections) with a converter, a kernel binfmt_misc interpreter to run it, and Nix packaging to deploy it.
How do I try converting and running a .self file?Use the self CLI (or elf2self/self2elf directly) in converter/ to turn an ELF binary into a .self SQLite file, then rely on the self-exec binfmt_misc interpreter in loader/ (installed via the Nix packages/NixOS module) to execute it.
Do I need Nix or NixOS to run this?Yes — the project is built around nixpkgs/NixOS: it ships Nix packages, a selfify hook, and a NixOS module (programs.self) to register the binfmt interpreter and run a real system slice as .self files.
Is every execution mode (memfd, native, selfld) fully working?Implementation status is tracked separately in the design doc, implying some of the three loader modes are more complete than others.
Does this run anywhere besides Linux/NixOS?No, it's tied to Linux's binfmt_misc mechanism and the Nix ecosystem for packaging and the NixOS module, so it only runs there.
What is self-httpd?An example server in examples/server/ whose pages, program, and visitor log all live in one .self file: it opens argv[0] as a database and serves responses from its own routes table, so editing the live site is literally a SQL UPDATE.
Why invert ELF into a database instead of just using ELF?It's inspired by sqlelf (arXiv:2405.03883), which put a SQL view over ELF; selfdb inverts that idea so the SQL rows ARE the format itself, executed via a binfmt_misc interpreter.
What does libself-audit.so do?It's an LDAUDIT library that lets stock glibc load .self shared libraries by resolving their symbols through SQL queries instead of normal ELF dynamic linking.
Where is the format itself defined?The DDL for the .self SQLite schema lives in schema/self.sql, generated from selfconv/schema.py.
What are similar projects?wcdb-key-tool, h2o, XRAG, ANE, Tinyhttpd, pwndbg, wikiskill, re4
Creator
fzakaria
Size
0.1 MB
Stars
572
Updated
CommitSep 24
Age
1mo
Commits · 90 Days