fix(tools): do not report weak imports as a title's current stop #5269

Merged
Nixitov merged 1 commit from upstream-pr/5269 into main 2026-10-14 18:52:20 +00:00
Nixitov commented 2026-10-13 16:06:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T16:06:37Z.


What

A weak import is optional: the relinker's entry stub leaves it unresolved (the loader sees null) instead of failing, so a title whose only missing import is weak still runs. The stops report added in #4606 counted those as the title's current stop, so it reported stops that no title actually has.

regie5 (PPSA99520) is the example: it weak-links sceLncUtilLaunchApp (+nRJUD-7qCk, libSceSystemService) as its fallback launcher, and the audit reported that as its stop — but on main the title runs past it (it reaches its own code and stops later for an unrelated reason). A contributor following the report would implement a function the title does not need.

  • The relinker already tracks the symbol binding (NidReference::Weak, used by the entry stub); the call registry now records it as a weak field on each entry.
  • tools/import_audit.py reads that field and skips weak imports when it computes current_stop, so stops (and the JSON report) list only imports the loader cannot resolve.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

  • core/relinker/relinker/tests/test_call_registry.py now asserts the weak field for a global symbol and for a STB_WEAK one; ctest -R call_registry passes.
  • tools/tests/test_import_audit.py adds a case where a weak unresolved import before a strong one is not the stop; ctest -R import_audit passes (47 tests).
  • Relinking regie5 (PPSA99520) writes "weak": true for +nRJUD-7qCk, and the recomputed stop list no longer reports PPSA99520 (before: +nRJUD-7qCk at libSceSystemService; after: none). A strong import (2 Ship 2 Harkinian's nsBDTu22CBU) still records "weak": false.
  • python tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same behaviour
  • 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 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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846038961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5269). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-10-13T16:06:37Z. --- ### What A **weak** import is optional: the relinker's entry stub leaves it unresolved (the loader sees null) instead of failing, so a title whose only missing import is weak still runs. The `stops` report added in #4606 counted those as the title's current stop, so it reported stops that no title actually has. **regie5 (PPSA99520)** is the example: it weak-links `sceLncUtilLaunchApp` (`+nRJUD-7qCk`, libSceSystemService) as its fallback launcher, and the audit reported that as its stop — but on `main` the title runs past it (it reaches its own code and stops later for an unrelated reason). A contributor following the report would implement a function the title does not need. - The relinker already tracks the symbol binding (`NidReference::Weak`, used by the entry stub); the call registry now records it as a `weak` field on each entry. - `tools/import_audit.py` reads that field and skips weak imports when it computes `current_stop`, so `stops` (and the JSON report) list only imports the loader cannot resolve. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. - `core/relinker/relinker/tests/test_call_registry.py` now asserts the `weak` field for a global symbol and for a `STB_WEAK` one; `ctest -R call_registry` passes. - `tools/tests/test_import_audit.py` adds a case where a weak unresolved import before a strong one is not the stop; `ctest -R import_audit` passes (47 tests). - Relinking regie5 (PPSA99520) writes `"weak": true` for `+nRJUD-7qCk`, and the recomputed stop list no longer reports PPSA99520 (before: `+nRJUD-7qCk` at libSceSystemService; after: none). A strong import (2 Ship 2 Harkinian's `nsBDTu22CBU`) still records `"weak": false`. - `python tools/check_conventions.py --base origin/main` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same behaviour - [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) - [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 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Nixitov commented 2026-10-13 19:22:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T19:22:32Z.


Thanks bot. Same-file overlap only: both PRs add a field to the expected entry in test_call_registry.py — this one adds weak (the import's symbol binding) and #4916 adds the dependency metadata for a zero-import dependency. The resolution is to keep both fields; nothing else in the file collides.

#5269 is independent and clean, while #4916 waits on #4425, so this can land first. I'm happy to rebase it after #4916 if the maintainer prefers the other order.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153366979 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5269#issuecomment-6153366979). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-10-13T19:22:32Z. --- Thanks bot. Same-file overlap only: both PRs add a field to the expected entry in `test_call_registry.py` — this one adds `weak` (the import's symbol binding) and #4916 adds the dependency metadata for a zero-import dependency. The resolution is to keep both fields; nothing else in the file collides. #5269 is independent and clean, while #4916 waits on #4425, so this can land first. I'm happy to rebase it after #4916 if the maintainer prefers the other order. AI-assisted: yes
adriadam10 commented 2026-10-14 18:11:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:11:34Z.


Checked the relinker change (weak written from NidReference::Weak, consistent with the entry stubs leaving weak imports null on both SysV and Windows), test_call_registry.py (global and STB_WEAK cases) and test_import_audit.py (66 tests) locally; all pass. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175107798 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5269#issuecomment-6175107798). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:11:34Z. --- Checked the relinker change (`weak` written from `NidReference::Weak`, consistent with the entry stubs leaving weak imports null on both SysV and Windows), `test_call_registry.py` (global and `STB_WEAK` cases) and `test_import_audit.py` (66 tests) locally; all pass. Merging once the full Build is green.
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!5269
No description provided.