LinuxPDF
lastmod 2025-11-04created 2025-02-051 edits
Running Linux with a RISC-V emulator inside a PDF
Features
- PDF files are easy to think of as static documents, but they actually include support for Javascript
- The PDF standard has its own Javascript standard library
- Modern browsers such as Chromium and Firefox implement only an extremely limited API for security reasons
- Uses an old version of Emscripten (e.g. 1.39.20, which supports the asm.js target)
- The structure: the TinyEMU RISC-V emulator is modified, compiled to asm.js, and run from the PDF
- The screen uses one text field per line and represents pixel states with ASCII characters
- Input passes keystrokes to the VM through a virtual keyboard and a text box
- E.g. booting the Linux kernel takes about 30-60 seconds, more than 100 times slower than running it normally
- V8 in Chrome's PDF engine has JIT disabled, which greatly degrades performance
- The default is a 32-bit Buildroot system (taken from the original TinyEMU examples)
- There is also a 64-bit Alpine Linux version, but it is about 2x slower, so it is usually not used