fix(relinker): skip backup copies of modules without a SONAME #20281

Merged
RiverWhy merged 1 commit from upstream-pr/20281 into main 2026-11-22 05:27:48 +00:00
RiverWhy commented 2026-11-14 23:34:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-14T23:34:56Z.


What

The relinker skips a dumper's backup copy (libX.prx.esbak, libX.prxbak) only when it and the module whose name it extends have the same non-empty SONAME. Modules without a DT_SONAME never matched, so their backups were converted as extra modules. On Stray (PPSA02100) the backups of libc, libSceFace and libSceFaceTracker were skipped, but those of libSceJobManager, libScePfs and libSceNpCppWebApi, which have no SONAME, became *.prx.esbak.guest.prx files and were audited a second time by tools/audit_dump.py.

  • RemoveBackupCopies: when either file has a SONAME, the rule is unchanged. When neither has one, the copy is a backup when both export the same, non-empty list of module names (0x6100000d/0x61000043, already read as GuestImage::ModuleNames). Two modules without a SONAME or module names are never matched.
  • It returns BackupCopy {Copy, Kept, Match}, and both callers (CLI NativeModules.cpp, Conversion.cpp) print (same SONAME as ...) or (same module names as ...).
  • docs/user/USAGE.md describes the fallback.
  • relinker_conversion_tests: the fixture can declare a module name; new cases cover a backup without a SONAME (skipped, Windows and Linux targets), one with other module names and one with none (both kept).

Tested

Linux Mint 22.3:

  • relinker_conversion_tests passes; without the change it fails with "A backup copy without a SONAME was converted".
  • ctest --test-dir build/core/relinker: 258 tests passed.
  • Stray (PPSA02100 01.005.000) sce_module/ as dumped: before, 9 converted modules including 3 backups; after, all 6 backups skipped (3 by SONAME, 3 by module names) and the 6 modules converted.

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:5317430770 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20281). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-14T23:34:56Z. --- ### What The relinker skips a dumper's backup copy (`libX.prx.esbak`, `libX.prxbak`) only when it and the module whose name it extends have the same non-empty SONAME. Modules without a `DT_SONAME` never matched, so their backups were converted as extra modules. On Stray (PPSA02100) the backups of `libc`, `libSceFace` and `libSceFaceTracker` were skipped, but those of `libSceJobManager`, `libScePfs` and `libSceNpCppWebApi`, which have no SONAME, became `*.prx.esbak.guest.prx` files and were audited a second time by `tools/audit_dump.py`. - `RemoveBackupCopies`: when either file has a SONAME, the rule is unchanged. When neither has one, the copy is a backup when both export the same, non-empty list of module names (`0x6100000d`/`0x61000043`, already read as `GuestImage::ModuleNames`). Two modules without a SONAME or module names are never matched. - It returns `BackupCopy {Copy, Kept, Match}`, and both callers (CLI `NativeModules.cpp`, `Conversion.cpp`) print `(same SONAME as ...)` or `(same module names as ...)`. - `docs/user/USAGE.md` describes the fallback. - `relinker_conversion_tests`: the fixture can declare a module name; new cases cover a backup without a SONAME (skipped, Windows and Linux targets), one with other module names and one with none (both kept). ### Tested Linux Mint 22.3: - `relinker_conversion_tests` passes; without the change it fails with "A backup copy without a SONAME was converted". - `ctest --test-dir build/core/relinker`: 258 tests passed. - Stray (PPSA02100 01.005.000) `sce_module/` as dumped: before, 9 converted modules including 3 backups; after, all 6 backups skipped (3 by SONAME, 3 by module names) and the 6 modules converted. ### 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) 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-15 00:28:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T00:28:21Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 054e14f3da:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: relinker_conversion_tests built cleanly.
  • CTest (relinker_conversion):
    1/1 Test #5250: relinker_conversion ..............   Passed    0.08 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/relinker/cli/src/NativeModules.cpp, core/relinker/relinker/include/relinker/guest/GuestImage.hpp, core/relinker/relinker/src/guest/GuestModuleBuilder.cpp, core/relinker/relinker/src/pipeline/Conversion.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #5250: relinker_conversion ..............***Failed    0.01 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • RemoveBackupCopies identity caching in core/relinker/relinker/src/guest/GuestModuleBuilder.cpp:574: Verified that Soname and ModuleNames are lazily read via GuestImageReader and cached in std::map<std::size_t, Identity> without reference or iterator invalidation across insertions.
    • Backup matching logic in core/relinker/relinker/src/guest/GuestModuleBuilder.cpp:588: Verified that if either candidate has a SONAME, matching strictly requires equal SONAMEs; if neither has a SONAME, matching requires non-empty, identical ModuleNames; modules lacking both or possessing mismatched identifiers evaluate to nullptr and are preserved.
    • Diagnostic reporting in core/relinker/cli/src/NativeModules.cpp:124 and core/relinker/relinker/src/pipeline/Conversion.cpp:56: Verified that BackupCopy structured binding [copy, kept, match] formats '(same SONAME as ...)' and '(same module names as ...)' consistently across CLI stdout and InputProgress messages.
    • Fixture and test coverage in core/relinker/relinker/tests/ConversionTests.cpp:27,161: Verified that dynamic tag 0x6100000d is correctly formatted in fixture(), and test cases validate both Windows and Linux targets for SONAME-less backup exclusion as well as negative retention cases for mismatched or empty module names.
    • AGENTS.md and documentation compliance: Verified zero prohibited code comments introduced in source or test files, no title-specific special-casing, and accurate documentation of the fallback behavior in docs/user/USAGE.md:29.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5908123243 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20281#pullrequestreview-5908123243). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-15T00:28:21Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `054e14f3da`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `relinker_conversion_tests` built cleanly. - **CTest** (`relinker_conversion`): ``` 1/1 Test #5250: relinker_conversion .............. Passed 0.08 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/relinker/cli/src/NativeModules.cpp`, `core/relinker/relinker/include/relinker/guest/GuestImage.hpp`, `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp`, `core/relinker/relinker/src/pipeline/Conversion.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #5250: relinker_conversion ..............***Failed 0.01 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - RemoveBackupCopies identity caching in core/relinker/relinker/src/guest/GuestModuleBuilder.cpp:574: Verified that Soname and ModuleNames are lazily read via GuestImageReader and cached in std::map<std::size_t, Identity> without reference or iterator invalidation across insertions. - Backup matching logic in core/relinker/relinker/src/guest/GuestModuleBuilder.cpp:588: Verified that if either candidate has a SONAME, matching strictly requires equal SONAMEs; if neither has a SONAME, matching requires non-empty, identical ModuleNames; modules lacking both or possessing mismatched identifiers evaluate to nullptr and are preserved. - Diagnostic reporting in core/relinker/cli/src/NativeModules.cpp:124 and core/relinker/relinker/src/pipeline/Conversion.cpp:56: Verified that BackupCopy structured binding [copy, kept, match] formats '(same SONAME as ...)' and '(same module names as ...)' consistently across CLI stdout and InputProgress messages. - Fixture and test coverage in core/relinker/relinker/tests/ConversionTests.cpp:27,161: Verified that dynamic tag 0x6100000d is correctly formatted in fixture(), and test cases validate both Windows and Linux targets for SONAME-less backup exclusion as well as negative retention cases for mismatched or empty module names. - AGENTS.md and documentation compliance: Verified zero prohibited code comments introduced in source or test files, no title-specific special-casing, and accurate documentation of the fallback behavior in docs/user/USAGE.md:29. - Minor: please drop the `Generated with` footer from the description; the AI-assisted checkbox can stay. Looks Good To Me
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!20281
No description provided.