fix(relinker): preserve aliases for Linux guest functions at address zero #23865

Merged
ballollama merged 1 commit from upstream-pr/23865 into main 2026-11-27 07:07:15 +00:00
ballollama commented 2026-11-19 20:13:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ballollama on 2026-11-19T20:13:25Z.


What

Emit one jump per Linux guest module for exported functions at address zero. Previously, two names for the same function got separate jumps, so their exported pointers compared unequal. Hidden functions and data symbols are unchanged.

Tested

On x86-64 Ubuntu under WSL, the synthetic guest regression test showed four distinct export addresses before the fix. After rebasing, rebuilt the relinker and ran linux_guest_zero_address_exports, linux_guest_qualified_imports, guest_export_lookup, and guest_symbol_names; all four passed. No commercial title tested.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5402204906 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23865). Originally posted by [ballollama](https://github.com/ballollama) on 2026-11-19T20:13:25Z. --- ### What Emit one jump per Linux guest module for exported functions at address zero. Previously, two names for the same function got separate jumps, so their exported pointers compared unequal. Hidden functions and data symbols are unchanged. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> On x86-64 Ubuntu under WSL, the synthetic guest regression test showed four distinct export addresses before the fix. After rebasing, rebuilt the relinker and ran `linux_guest_zero_address_exports`, `linux_guest_qualified_imports`, `guest_export_lookup`, and `guest_symbol_names`; all four passed. No commercial title tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
edglz commented 2026-11-20 21:52:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edglz on 2026-11-20T21:52:38Z.

Review: APPROVED


Summary

All function exports at value 0 in one module denote the same address (st_value is a virtual address, not section-relative), so emitting one jmp thunk per module and pointing every such symbol at it restores pointer equality between aliases. The range check moves with the single thunk.

Verification

Environment: macOS 26, Apple M4 (arm64), Apple clang 21.0.0, CMake relinker-only Release build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON), PR diff applied on current main.

Check Result
Full ctest suite with this PR 947/947 pass
linux_guest_zero_address_exports with the writer change reverted Fails

Not verified: execution of the converted outputs on Linux or Windows; the tests that run them are host-gated.

Notes

#24152 edits the same debt entry and its fragment still says two names get two jmps; whichever lands second should drop that clause.

Verdict

Approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5999886845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23865#pullrequestreview-5999886845). Originally posted by [edglz](https://github.com/edglz) on 2026-11-20T21:52:38Z. **Review:** APPROVED --- ## Summary All function exports at value 0 in one module denote the same address (`st_value` is a virtual address, not section-relative), so emitting one `jmp` thunk per module and pointing every such symbol at it restores pointer equality between aliases. The range check moves with the single thunk. ## Verification **Environment:** macOS 26, Apple M4 (arm64), Apple clang 21.0.0, CMake relinker-only Release build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`), PR diff applied on current `main`. | Check | Result | |---|---| | Full ctest suite with this PR | 947/947 pass | | `linux_guest_zero_address_exports` with the writer change reverted | Fails | Not verified: execution of the converted outputs on Linux or Windows; the tests that run them are host-gated. ## Notes #24152 edits the same debt entry and its fragment still says two names get two `jmp`s; whichever lands second should drop that clause. ## Verdict Approved.
MarcZX10 commented 2026-11-21 00:53:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T00:53:09Z.

Review: APPROVED


Reviewed — looks good

Nothing in the reviewed change blocks merging; the alias-preserving thunk logic and regression assertions are consistent with the stated goal.

What I ran

Reviewed head afc3cedd707f68bc7f019c3521c34e00f9baf2ec using repo_read.py to inspect the prepared diff and targeted source context. No tests or builds were run.

Results

Check Result Note
Changed lines reviewed passed All added lines inspected
Tests and build not run Author reports four tests passed
Source context passed Writer layout and test setup inspected

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported test runs were not reproduced. No build, test suite, commercial title, or physical console run was performed. Read all three changed files: core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cpp, core/relinker/relinker/tests/test_linux_guest_zero_address_exports.py, and docs/dev/debt/changes/linux-zero-export-aliases.md. No changed files were excluded according to the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6001503431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23865#pullrequestreview-6001503431). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T00:53:09Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the reviewed change blocks merging; the alias-preserving thunk logic and regression assertions are consistent with the stated goal. ## What I ran Reviewed head `afc3cedd707f68bc7f019c3521c34e00f9baf2ec` using `repo_read.py` to inspect the prepared diff and targeted source context. No tests or builds were run. ## Results | Check | Result | Note | |---|---|---| | Changed lines reviewed | passed | All added lines inspected | | Tests and build | not run | Author reports four tests passed | | Source context | passed | Writer layout and test setup inspected | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The reported test runs were not reproduced. No build, test suite, commercial title, or physical console run was performed. Read all three changed files: `core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cpp`, `core/relinker/relinker/tests/test_linux_guest_zero_address_exports.py`, and `docs/dev/debt/changes/linux-zero-export-aliases.md`. No changed files were excluded according to the manifest. ## To get this to a good state Nothing is required.
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!23865
No description provided.