Skip to content

fix(relinker): accept absolute symbols in guest modules - #698

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
merwie:fix/relinker-guest-absolute-symbols
Oct 6, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
merwie:fix/relinker-guest-absolute-symbols

Conversation

@merwie

@merwie merwie commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What

Guest modules may define symbols in SHN_ABS (0xfff1). PPSA12544 (Hollow Knight: Silksong) bundles Il2cppUserAssemblies.prx with 151 of them (<NID>#K#A, STB_GLOBAL, STT_NOTYPE, value 1). The relinker failed on the first one with Unsupported special symbol section.

  • GuestImageReader: an SHN_ABS symbol is accepted and its value is not checked as a mapped address. Other special sections (SHN_COMMON, ...) are still rejected.
  • WindowsGuestModuleWriter: R_X86_64_64 / GLOB_DAT / JUMP_SLOT against an SHN_ABS symbol write value + addend with no base relocation.
  • SHN_ABS symbols are not exported on Windows and not entered in the guest export map: a PE export is an RVA, so an import of one fails at startup as an unresolved import. No module of PPSA12544 imports any of the 151. On Linux the dynamic symbol table is kept, so ld.so resolves them natively.
  • New test guest_absolute_symbols: a guest module with an exported absolute symbol and a relocation against it relinks for Linux and Windows (Windows output holds the absolute value, Linux output keeps the relocation against the SHN_ABS symbol); SHN_COMMON still fails.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Ryzen 7 9800X3D, Radeon RX 9070 XT.

  • ctest: 287/289 passed, including guest_absolute_symbols. agc_driver_lds_atomics64 and agc_driver_vopc_compare_table fail on this machine; they run on the Vulkan device and do not touch the relinker.
  • PPSA12544: all seven bundled modules (including Il2cppUserAssemblies.prx) relink; at startup only unimplemented exports remain unresolved (separate PR).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

Guest modules may define symbols in SHN_ABS (0xfff1), for example the
151 library marker symbols of PPSA12544's Il2cppUserAssemblies.prx.
The reader no longer rejects them or checks their value as a mapped
address, relocations against them write the absolute value without a
base relocation, and they are not exported: a PE export is an RVA, so an
import of one fails at startup as an unresolved import. Other special
sections are still rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@merwie

merwie commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

On the overlap note: #672 and #684 are different topics (host prx references on Linux, Windows import module binding). The overlap is neighbouring lines in core/relinker/CMakeLists.txt (test registration), GuestImage.hpp and the export checks in GuestModuleBuilder.cpp; whichever merges second needs a small rebase, no behaviour depends on the other.

@oneandonlydean
oneandonlydean merged commit bd8aa57 into boykopovar:main Oct 6, 2026
3 checks passed
fable-void added a commit to fable-void/AnyPS5 that referenced this pull request Oct 11, 2026
boykopovar#698 taught the reader, the module builder and the Windows writer to
resolve relocations against SHN_ABS symbols and to leave them out of the
exports, but the macOS writer still threw "Unsupported guest export
section" for them. PPSA12544 bundles modules with such an export
(RKDbTdN8TO0), so --macos stopped before writing anything.

The macOS writer now resolves a relocation against an absolute symbol to
its value plus the addend, without a rebase, and skips absolute symbols
when exporting, as the Windows writer does. guest_absolute_symbols covers
the macOS output too.

AI-assisted: yes
fable-void added a commit to fable-void/AnyPS5 that referenced this pull request Oct 11, 2026
boykopovar#698 taught the reader, the module builder and the Windows writer to
resolve relocations against SHN_ABS symbols and to leave them out of the
exports, but the macOS writer still threw "Unsupported guest export
section" for them. PPSA12544 bundles modules with such an export
(RKDbTdN8TO0), so --macos stopped before writing anything.

The macOS writer now resolves a relocation against an absolute symbol to
its value plus the addend, without a rebase, and skips absolute symbols
when exporting, as the Windows writer does. guest_absolute_symbols covers
the macOS output too.

AI-assisted: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants