Skip to content

Add Linux support via ELF symbol scanner#22

Open
changelingonberry wants to merge 2 commits intospacestation13:mainfrom
changelingonberry:linux-sigscan
Open

Add Linux support via ELF symbol scanner#22
changelingonberry wants to merge 2 commits intospacestation13:mainfrom
changelingonberry:linux-sigscan

Conversation

@changelingonberry
Copy link
Copy Markdown

At library load time, lua_compat.c:

  1. Reads the host binary's .symtab from /proc/self/exe.
  2. For each needed Lua API symbol, tries an exact C-name match first, then a prefix match on the Itanium C++ mangled form _Z, which identifies the function regardless of its parameter types. This handles aseprite's Lua being compiled as C++ without extern "C".
  3. Resolves the ASLR slide via dl_iterate_phdr and computes runtime addresses as base + symtab offset.
  4. Exposes plain C-named wrapper functions covering all 47 Lua/luaL symbols that mlua requires.

build.rs compiles lua_compat.c via the cc crate on Linux only, linking it into libdmi.so so mlua's extern declarations are satisfied at link time with no undefined Lua symbols remaining.

Requires only a non-stripped self-built aseprite binary (.symtab present).

This PR has been created with AI assistance.

changelingonberry and others added 2 commits April 6, 2026 22:31
At library load time, lua_compat.c:
  1. Reads the host binary's .symtab from /proc/self/exe.
  2. For each needed Lua API symbol, tries an exact C-name match first,
     then a prefix match on the Itanium C++ mangled form _Z<len><name>,
     which identifies the function regardless of its parameter types.
     This handles aseprite's Lua being compiled as C++ without extern
"C".
  3. Resolves the ASLR slide via dl_iterate_phdr and computes runtime
     addresses as base + symtab offset.
  4. Exposes plain C-named wrapper functions covering all 47 Lua/luaL
     symbols that mlua requires.

build.rs compiles lua_compat.c via the cc crate on Linux only, linking
it into libdmi.so so mlua's extern declarations are satisfied at link
time with no undefined Lua symbols remaining.

Requires only a non-stripped self-built aseprite binary (.symtab
present).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant