fix(relinker): allow function aliases with different sizes #614

Merged
nicolasabosch merged 1 commit from upstream-pr/614 into main 2026-10-05 07:28:19 +00:00
nicolasabosch commented 2026-10-05 04:50:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-05T04:50:26Z.


What

Windows conversion rejects guest modules whose dynamic function symbols share a start address but declare different sizes. The DOOM PS5 homebrew (PPSA99666, 01.001.000) ships a generated libc shim with this layout and fails with Code analysis: conflicting function ranges (offset 0x50).

Merge symbol aliases at the same address using the largest declared extent so code analysis covers every advertised byte. Each extent still has to fit its executable segment; conflicting unwind extents and TLS instruction checks retain their existing rejection behavior. No title-specific exception or module-skipping flag is added.

Tested

  • Windows, MinGW-w64 GCC 15.2.0: built relinker; all 22 tests registered under build/core/relinker passed.
  • Regression: the new alias fixture fails with the original relinker. With the change, aliases in either size order and zero-size aliases convert and the generated PE fixtures return 42. Out-of-segment aliases still fail. An unsupported FS instruction in the longer alias's unreachable tail is still detected. Existing conflicting symbol/unwind and instruction-boundary cases still fail as expected.
  • Real homebrew: extracted the plaintext eboot and bundled libc from PPSA99666 into a separate working directory; both reconstructed ELF hashes match their containers. --windows --to-intel --registry, with module processing and checks enabled, now converts the executable and libc successfully. The input package was not modified.
  • Launch attempted with the generated module, app resources and built system libraries: startup stops at unresolved access (8vE6Z6VEYyk, Windows error 127). In-game behavior is not tested; this PR fixes conversion only. No PS5 hardware or Linux execution tested.

Checklist

  • Based on current main; no other open PR implementing this fix found
  • One topic per PR; follow-ups go in a new PR
  • No comments added to code
  • Unsupported paths retain explicit failures; no silent stub added
  • No investigation notes, images or game binaries added to the repository
  • No new third-party code
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4740327901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/614). Originally posted by [nicolasabosch](https://github.com/nicolasabosch) on 2026-10-05T04:50:26Z. --- ### What Windows conversion rejects guest modules whose dynamic function symbols share a start address but declare different sizes. The DOOM PS5 homebrew (PPSA99666, 01.001.000) ships a generated libc shim with this layout and fails with `Code analysis: conflicting function ranges (offset 0x50)`. Merge symbol aliases at the same address using the largest declared extent so code analysis covers every advertised byte. Each extent still has to fit its executable segment; conflicting unwind extents and TLS instruction checks retain their existing rejection behavior. No title-specific exception or module-skipping flag is added. ### Tested - Windows, MinGW-w64 GCC 15.2.0: built `relinker`; all 22 tests registered under `build/core/relinker` passed. - Regression: the new alias fixture fails with the original relinker. With the change, aliases in either size order and zero-size aliases convert and the generated PE fixtures return 42. Out-of-segment aliases still fail. An unsupported FS instruction in the longer alias's unreachable tail is still detected. Existing conflicting symbol/unwind and instruction-boundary cases still fail as expected. - Real homebrew: extracted the plaintext eboot and bundled libc from PPSA99666 into a separate working directory; both reconstructed ELF hashes match their containers. `--windows --to-intel --registry`, with module processing and checks enabled, now converts the executable and libc successfully. The input package was not modified. - Launch attempted with the generated module, app resources and built system libraries: startup stops at unresolved `access` (`8vE6Z6VEYyk`, Windows error 127). In-game behavior is **not tested**; this PR fixes conversion only. No PS5 hardware or Linux execution tested. ### Checklist - [x] Based on current `main`; no other open PR implementing this fix found - [x] One topic per PR; follow-ups go in a new PR - [x] No comments added to code - [x] Unsupported paths retain explicit failures; no silent stub added - [x] No investigation notes, images or game binaries added to the repository - [x] No new third-party code - [x] Generic behavior, not specific to one title - Depends on: none - AI-assisted: yes
oneandonlydean commented 2026-10-05 07:26:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T07:26:38Z.


Thanks, this looks right to me. Only the symbol table calls pass symbolAlias, so two dynamic symbols at the same address now merge to the largest extent, while an unwind range still has to match whatever is already recorded there. Each alias still goes through the executable segment check before it is merged, zero-size aliases are skipped as before, and the linear decode then covers the longest extent, so the unsupported TLS instruction in the longer alias's tail is still found (your symbol-alias-unreachable-tls-tail row). Order doesn't matter either, since the merge takes the maximum.

One small side effect, which I think is fine: the end of the shorter alias is no longer checked as an instruction boundary, because only the merged range is decoded.

tls_function_coverage fails on main's code here at the first alias row ("conflicting function ranges (offset 0x1200)") and passes with the change, and the full ctest passes with it merged (Linux, GCC). CodeInstructionCollector is only used by the Windows TLS builder, so Linux relinks are unchanged, and this doesn't need my PPSA21564 check. Ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5990013352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/614#issuecomment-5990013352). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-05T07:26:38Z. --- Thanks, this looks right to me. Only the symbol table calls pass `symbolAlias`, so two dynamic symbols at the same address now merge to the largest extent, while an unwind range still has to match whatever is already recorded there. Each alias still goes through the executable segment check before it is merged, zero-size aliases are skipped as before, and the linear decode then covers the longest extent, so the unsupported TLS instruction in the longer alias's tail is still found (your `symbol-alias-unreachable-tls-tail` row). Order doesn't matter either, since the merge takes the maximum. One small side effect, which I think is fine: the end of the shorter alias is no longer checked as an instruction boundary, because only the merged range is decoded. `tls_function_coverage` fails on main's code here at the first alias row ("conflicting function ranges (offset 0x1200)") and passes with the change, and the full ctest passes with it merged (Linux, GCC). `CodeInstructionCollector` is only used by the Windows TLS builder, so Linux relinks are unchanged, and this doesn't need my PPSA21564 check. Ready to merge from my side.
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!614
No description provided.