feat(relinker): write a registry for each converted bundled module #1462

Merged
abderahmane-ai merged 1 commit from upstream-pr/1462 into main 2026-10-09 21:06:19 +00:00
abderahmane-ai commented 2026-10-08 08:02:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by abderahmane-ai on 2026-10-08T08:02:49Z.


What

relinker --registry only described the imports of the executable, so a title whose own modules import system functions (PSN.prx, libc.prx and others) could not be audited completely. With --registry the relinker now also writes <output-stem>.<module>.registry.json for every converted bundled module.

An entry is written for each relocation, in DT_RELA and DT_JMPREL, against an undefined symbol that no other bundled module exports. That is the test GuestModuleBuilder already uses to decide that a dependency is satisfied by a sibling. Entries carry nid, library and targetOffset; the symbol has lost its # suffix by the time the module is read, so the NID is the bare 11 characters. The executable's registry is unchanged. The import audit from #1461 accepts these files as they are, and its docs are updated for them.

The first commit of this branch is #1461; the second is this change.

Tested

  • core/relinker/relinker/tests/test_guest_registry.py (registered in CTest as guest_registry), for Linux and Windows output: two modules where one is provided by its sibling, both relocation tables, the same module importing the sibling's function once the sibling is removed, and no registry file without --registry.
  • Broke the change three ways in throwaway copies (sibling exclusion removed, DT_JMPREL ignored, wrong target offset); the test caught all three.
  • All 25 relinker Python tests pass with a relinker built from this branch on macOS 26.5 arm64, and the audit over the executable and module registries gave the expected counts.
  • python3 tools/check_conventions.py --base origin/main passes. A trial merge with #1454, the other open relinker PR, is clean.
  • Not tested: GCC or MinGW builds (built with clang here), and a real title.

The code, tests and docs were written with AI assistance. I read every line and ran the checks above.

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: #1461
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4783766500 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1462). Originally posted by [abderahmane-ai](https://github.com/abderahmane-ai) on 2026-10-08T08:02:49Z. --- ### What `relinker --registry` only described the imports of the executable, so a title whose own modules import system functions (`PSN.prx`, `libc.prx` and others) could not be audited completely. With `--registry` the relinker now also writes `<output-stem>.<module>.registry.json` for every converted bundled module. An entry is written for each relocation, in `DT_RELA` and `DT_JMPREL`, against an undefined symbol that no other bundled module exports. That is the test `GuestModuleBuilder` already uses to decide that a dependency is satisfied by a sibling. Entries carry `nid`, `library` and `targetOffset`; the symbol has lost its `#` suffix by the time the module is read, so the NID is the bare 11 characters. The executable's registry is unchanged. The import audit from #1461 accepts these files as they are, and its docs are updated for them. The first commit of this branch is #1461; the second is this change. ### Tested - `core/relinker/relinker/tests/test_guest_registry.py` (registered in CTest as `guest_registry`), for Linux and Windows output: two modules where one is provided by its sibling, both relocation tables, the same module importing the sibling's function once the sibling is removed, and no registry file without `--registry`. - Broke the change three ways in throwaway copies (sibling exclusion removed, `DT_JMPREL` ignored, wrong target offset); the test caught all three. - All 25 relinker Python tests pass with a relinker built from this branch on macOS 26.5 arm64, and the audit over the executable and module registries gave the expected counts. - `python3 tools/check_conventions.py --base origin/main` passes. A trial merge with #1454, the other open relinker PR, is clean. - Not tested: GCC or MinGW builds (built with clang here), and a real title. The code, tests and docs were written with AI assistance. I read every line and ran the checks above. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [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: #1461 - [x] AI-assisted: yes
adriadam10 commented 2026-10-08 14:31:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T14:31:12Z.


Rebased onto current main: #1461 landed, so its commit dropped out and one commit remains. Checked on Linux: build + full ctest green (464/464); guest_registry fails with the non-test changes reverted; the diff matches the description (relocations in DT_RELA and DT_JMPREL against symbols no other bundled module exports; executable registry unchanged); module registries are accepted by tools/import_audit.py as is. Merging once CI is green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6062145895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1462#issuecomment-6062145895). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T14:31:12Z. --- Rebased onto current `main`: #1461 landed, so its commit dropped out and one commit remains. Checked on Linux: build + full ctest green (464/464); `guest_registry` fails with the non-test changes reverted; the diff matches the description (relocations in `DT_RELA` and `DT_JMPREL` against symbols no other bundled module exports; executable registry unchanged); module registries are accepted by `tools/import_audit.py` as is. Merging once CI is green on the rebased head.
github-actions[bot] commented 2026-10-08 14:32:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T14:32:35Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1529 core/relinker/relinker/src/guest/GuestModuleBuilder.cpp L184-185
#1597 core/relinker/CMakeLists.txt L230
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6062174575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1462#issuecomment-6062174575). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T14:32:35Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1529 | `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp` [L184-185](https://github.com/boykopovar/AnyPS5/blob/7995d6578d289310c25b8e104119c8bbfabb14f9/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L184-L185) | | | | #1597 | `core/relinker/CMakeLists.txt` [L230](https://github.com/boykopovar/AnyPS5/blob/7995d6578d289310c25b8e104119c8bbfabb14f9/core/relinker/CMakeLists.txt#L230) | | |
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!1462
No description provided.