GitHub Hot Board

GitHub Hot Board · 저장소 아카이브

ading2210/linuxpdf

Linux running inside a PDF file via a RISC-V emulator (소개는 저장소 자체 문서에서 왔습니다.)

데이터 기준 October 27ading2210

최고 순위

#429

종합 · C 언어별

5.1K

누적 스타

263

포크 수

0

최근 30일 기록 일수

프로젝트 상태라이선스: GPL-3.0최근 push: February 2열린 이슈(PR 포함): 2

2026-10-25부터 수집. 미확인 = 아직 미수집

README에 뱃지를 붙여보세요 · ading2210/linuxpdf[![README에 뱃지를 붙여보세요](https://git.vaiox.xyz/api/badge/ading2210/linuxpdf.svg)](https://git.vaiox.xyz/ko/repo/ading2210/linuxpdf)

Badge · 任何仓库都可以挂 —— 未上榜的仓库显示灰章,上完榜会自动点亮。

<a href="https://git.vaiox.xyz/ko/repo/ading2210/linuxpdf"><img src="https://git.vaiox.xyz/api/badge/ading2210/linuxpdf.svg" alt="README에 뱃지를 붙여보세요" height="20"></a>

프로젝트 문서

LinuxPDF

This is Linux running inside a PDF file via a RISC-V emulator, which is based on TinyEMU.

Try it here: linux.pdf

linuxpdf.mp4

See also: DoomPDF

Explanation

This works in a very similar way to my previous DoomPDF project.

You might expect PDF files to only be comprised of static documents, but surprisingly, the PDF file format supports Javascript with its own separate standard library. Modern browsers (Chromium, Firefox) implement this as part of their PDF engines. However, the APIs that are available in the browser are much more limited.

The full specfication for the JS in PDFs was only ever implemented by Adobe Acrobat, and it contains some ridiculous things like the ability to do 3D rendering, make HTTP requests, and detect every monitor connected to the user's system. However, on Chromium and other browsers, only a tiny subset of this API was ever implemented, due to obvious security concerns. With this, we can do whatever computation we want, just with some very limited IO.

C code can be compiled to run within a PDF using an old version of Emscripten that targets asm.js instead of WebAssembly. With this, I can compile a modified version of the TinyEMU RISC-V emulator to asm.js, which can be run within the PDF. For the input and output, I reused the same display code that I used for DoomPDF. It works by using a separate text field for each row of pixels in the screen, whose contents are set to various ASCII characters. For inputs, there is a virtual keyboard implemented with a bunch of buttons, and a text box you can type in to send keystrokes to the VM.

The largest problem here is with the emulator's performance. For example, the Linux kernel takes about 30-60 seconds to boot up within the PDF, which over 100x slower than normal. Unfortunately, there's no way to fix this, since the version of V8 that Chrome's PDF engine uses has its JIT compiler disabled, destroying its performance.

For the root filesystem, there are both 64 and 32 bit versions possible. The default is a 32 bit buildroot system (which was prebuilt and taken from the original TinyEMU examples), and also a 64 bit Alpine Linux system. The 64 bit emulator is about twice as slow however, so it's normally not used.

Build Instructions

Clone this repository and run the following commands:

python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
./build.sh

If you want to build the 64 bit rather than 32 bit version, edit build.sh and change the BITS="32" line.

The build.sh script will download Emscripten 1.39.20 automatically. You must be on Linux to build this.

The generated files will be in the out/ directory. Then you can run (cd out; python3 -m http.server) to serve the files on a web server.

Credits

This project was made by @ading2210.

The RISC-V emulator is forked from TinyEMU, which was written by Fabrice Bellard.

License

This repository is licensed under the GNU GPL v3.

ading2210/linuxpdf - Linux running inside a PDF file
Copyright (C) 2025 ading2210

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

현재 순위

  • 429

    종합 랭킹 · 역대 최강 · C

    5.1K 스타 · 263 fork · 총 스타 수

    종합 · C →

최근 30일 추이

최근 30일간 기록이 없습니다.

← 랭킹으로

GitHub Hot Board타임머신Discover