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

Merged
merwie merged 1 commit from upstream-pr/698 into main 2026-10-06 00:19:31 +00:00
merwie commented 2026-10-05 16:39:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by merwie on 2026-10-05T16:39:45Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4748077720 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/698). Originally posted by [merwie](https://github.com/merwie) on 2026-10-05T16:39:45Z. --- ### 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 - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merwie commented 2026-10-05 20:49:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by merwie on 2026-10-05T20:49:20Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6002655841 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/698#issuecomment-6002655841). Originally posted by [merwie](https://github.com/merwie) on 2026-10-05T20:49:20Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!698
No description provided.