fix(relinker): resolve all-zero dynamic symbols to null on Windows #4602

Closed
pushkarreddyy wants to merge 1 commit from upstream-pr/4602 into main
pushkarreddyy commented 2026-10-12 16:39:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T16:39:27Z.


What

Fixes #4437. Unblocks OliSe Player (PPSA01153).

In OliSe Player (PPSA01153), the executable contains seven weak references pointing at dynamic symbol entries whose 24 bytes are all zero (no name, local, undefined, value 0). On Windows, WindowsRelocationBuilder::Apply threw FAIL: Empty import symbol name (offset 0x18c5bb8).

  • WindowsRelocationBuilder::Apply: when an import symbol name is empty, inspects the 24-byte symbol entry in dynamicSection.DynSymData. If the entire 24-byte entry is zero (unreferenced / weak null symbol), verifies addend (type != 1 && addend != 0 throws GLOB_DAT/JUMP_SLOT relocation has a nonzero addend), writes the null/addend pointer directly to the target location (image.RequireWritable(target, 8); image.WritePointer(target, addend);), and skips adding a PE import entry. Dynamic symbols with an empty name that have non-zero attributes still throw Empty import symbol name.
  • Documented in TechnicalDebt.md.

Tested

  • Added unit test cases in core/relinker/relinker/tests/test_windows_import_modules.py verifying both that an executable with an all-zero dynamic symbol entry resolves cleanly to null on Windows, and that a non-zero symbol with an empty name is rejected with Empty import symbol name.
  • python tools/check_conventions.py --base origin/main passed cleanly with 0 errors.

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
  • Unblocks: PPSA01153 #4437
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832331682 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4602). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-12T16:39:27Z. --- ### What Fixes #4437. Unblocks *OliSe Player* (`PPSA01153`). In *OliSe Player* (`PPSA01153`), the executable contains seven weak references pointing at dynamic symbol entries whose 24 bytes are all zero (no name, local, undefined, value 0). On Windows, `WindowsRelocationBuilder::Apply` threw `FAIL: Empty import symbol name (offset 0x18c5bb8)`. - `WindowsRelocationBuilder::Apply`: when an import symbol name is empty, inspects the 24-byte symbol entry in `dynamicSection.DynSymData`. If the entire 24-byte entry is zero (unreferenced / weak null symbol), verifies addend (`type != 1 && addend != 0` throws `GLOB_DAT/JUMP_SLOT relocation has a nonzero addend`), writes the null/addend pointer directly to the target location (`image.RequireWritable(target, 8); image.WritePointer(target, addend);`), and skips adding a PE import entry. Dynamic symbols with an empty name that have non-zero attributes still throw `Empty import symbol name`. - Documented in `TechnicalDebt.md`. ### Tested - Added unit test cases in `core/relinker/relinker/tests/test_windows_import_modules.py` verifying both that an executable with an all-zero dynamic symbol entry resolves cleanly to null on Windows, and that a non-zero symbol with an empty name is rejected with `Empty import symbol name`. - `python tools/check_conventions.py --base origin/main` passed cleanly with 0 errors. ### 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/TechnicalDebt.md#silent-stubs) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] Unblocks: PPSA01153 #4437
pushkarreddyy commented 2026-10-12 18:36:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T18:36:36Z.


I had this independently implemented and passing CI, but saw #4452 was merged into main just ahead of this. Closing in favor of #4452.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130330770 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4602#issuecomment-6130330770). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-12T18:36:36Z. --- I had this independently implemented and passing CI, but saw #4452 was merged into main just ahead of this. Closing in favor of #4452.

Pull request closed

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!4602
No description provided.