Skip to content

feat(fspy-elf-loader): load static ELF images without PT_INTERP - #1003

Closed
wan9chi wants to merge 3 commits into
fspy/userland-execve-loaderfrom
cursor/elf-loader-optional-interp-2d90
Closed

wan9chi wants to merge 3 commits into
fspy/userland-execve-loaderfrom
cursor/elf-loader-optional-interp-2d90

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Motivation

The loader treated PT_INTERP as required, so it could load dynamic PIE and dynamic ET_EXEC but not the other two ELF cells: traditional static (ET_EXEC, no interpreter) and static-PIE (ET_DYN, no interpreter). Those are the images seccomp_unotify exists for today (esbuild, Go, musl -static).

PT_INTERP is now optional. With an interpreter, behavior is unchanged: map both images, AT_BASE is the interpreter bias, enter ld.so. Without one, map only the executable, set AT_BASE to 0, and enter e_entry, matching Linux load_elf_binary. Runtime fixtures compiled with cc -static and cc -static-pie cover BSS, TLS, threads, malloc, and auxv.

This branch also carries an earlier mapping-correctness commit (padzero, mid-page BSS-only PT_LOAD, padded PT_INTERP) that was not yet on the WIP branch.

Open in Web Open in Cursor 

Note

Medium Risk
Changes process image mapping, aux vector, and entry transfer in the custom loader; mistakes could corrupt memory layout or break program startup for both dynamic and static images.

Reviewed by Cursor Bugbot for commit bf0640a. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 2 commits November 18, 2026 03:47
Map zero-filesz loads like elf_map so a mid-page BSS segment does not
wipe the previous page. Padzero whenever filesz is not page-aligned,
including filesz==memsz. Accept padded PT_INTERP paths and unordered
non-overlapping PT_LOADs. Clear leftover GPRs in the enter stubs.

Co-authored-by: Cursor Grok 4.6 <cursoragent@cursor.com>
Co-authored-by: Charles Wang <wan9chi@users.noreply.github.com>
Treat PT_INTERP as optional. Map only the executable when it is absent,
set AT_BASE to 0, and enter e_entry. Add cc -static and -static-pie
runtime fixtures covering traditional static and static-PIE.

Co-authored-by: Cursor Grok 4.6 <cursoragent@cursor.com>
Co-authored-by: Charles Wang <wan9chi@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  -0.46%  [ -5.05% ..  +3.98%]  overhead   +53.20%
dynamic/access             change  -0.04%  [ -6.18% ..  +3.14%]  overhead   +16.43%
dynamic/access-relative    change  -0.28%  [ -1.39% ..  +1.07%]  overhead   +84.25%
dynamic/access-contended   change  -1.20%  [-10.32% ..  +8.42%]  overhead    -4.08%
static/launch              change  +0.17%  [ -2.57% ..  +3.00%]  overhead  +182.83%
static/access              change  +0.46%  [ -1.15% ..  +1.76%]  overhead +1450.78%
static/access-relative     change  +0.26%  [ -0.93% ..  +1.25%]  overhead +1983.67%
static/access-contended    change  +0.20%  [ -0.89% ..  +1.33%]  overhead +1786.49%

macos

dynamic/launch             change  +0.24%  [ -2.76% ..  +3.04%]  overhead  +214.19%
dynamic/access             change  +0.39%  [ -1.93% ..  +3.33%]  overhead    +4.06%
dynamic/access-relative    change  -0.62%  [ -4.44% ..  +2.19%]  overhead  +251.81%
dynamic/access-contended   change  -0.28%  [ -2.90% ..  +2.54%]  overhead    +2.46%

windows

dynamic/launch             change  +0.09%  [ -2.13% ..  +2.00%]  overhead   +31.28%
dynamic/access             change  +0.00%  [ -0.62% ..  +0.82%]  overhead    +1.45%
dynamic/access-relative    change  +0.00%  [ -0.79% ..  +0.82%]  overhead    +1.44%
dynamic/access-contended   change  +0.60%  [ -0.20% ..  +1.39%]  overhead    +1.61%

The undefined __fspy_global_allocator_must_not_be_used symbol is for
freestanding Linux/none binaries. Linking it into fspy_preload_windows
fails MSVC because the rlib object is retained.

Also align cargo-shear with the rustc-only allocator fixture and skip
lib doctests that rustdoc compiles with std.

Co-authored-by: Cursor Grok 4.6 <cursoragent@cursor.com>
Co-authored-by: Charles Wang <wan9chi@users.noreply.github.com>
@wan9chi wan9chi closed this Nov 20, 2026
@cursor
cursor Bot deleted the cursor/elf-loader-optional-interp-2d90 branch November 20, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants