Skip to content

fix(relinker): honor PS4 needed-module tags - #20574

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Queuse:codex/fix-ps4-import-tags-20261115
Nov 22, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Queuse:codex/fix-ps4-import-tags-20261115

Conversation

@Queuse

@Queuse Queuse commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Honor PS4 needed-module declarations (0x6100000f) when mapping the main executable's qualified imports. Previously those declarations were ignored, allowing a shared symbol to bind to the first provider rather than its declared module. Match the existing guest reader's PS4/PS5 tag handling, including duplicate-ID checks and rejection of mixed-generation declarations.

Tested

Windows / WinLibs GCC 15.2 / Python 3.12: relinker-only build and nine focused CTests passed: windows_import_modules, import_module, reloc_table_bounds, guest_symbol_names, linux_guest_qualified_imports, guest_symbolic_modules, guest_unused_import_dependencies, windows_named_imports, and linux_named_imports. The full module-scoped import test completed in 17.14 seconds under its 30-second timeout.

The original executable returned 11 from the wrong provider in the PS4 control; the change returns 22 from the declared provider. Coverage includes PS4/PS5 parity, native Windows execution, Linux output symbol bindings, module IDs/version bits, aliases, disjoint providers, duplicate/mixed tags, unknown IDs and bounded string errors. Native Linux execution of these Windows-test fixtures was not run.

python tools/check_conventions.py --base origin/main and git diff --check passed. The required overlap scan could not complete five comparisons: #10861 (referenced-code scanning/syscall routing), #11525 (embedded data tables), #15896 (unwind roots), #15903 (TLS addend validation in this file), and #17105 (undefined-symbol visibility). Their current shared-file patches were reviewed manually; none implements PS4 needed-module collection. Composition with those conflicting branches was not built. Based on current main; affected sources are unchanged between the tested and rebased base revisions. No title-unblock or performance claim.
Independent Windows validation by adam25136 compared head 40383cd7e5 with the same inFAMOUS Second Son (CUSA00223 01.07) integration on main 1adc0e2f4b. The title declares 28 PS4 needed-module tags. Both conversions succeeded and both runs reached the same unimplemented PS4 multisampled-texture path with zero unresolved imports. The converted executable was 157,696 bytes smaller with the change. The focused windows_import_modules regression failed without the fix and passed with it.

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

@ycbuzi

ycbuzi commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Tested 40383cd7e5 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Linux: Debian 13 in ChromeOS's Linux environment on a Pentium Silver N6000 (4 cores, SSE4.2, no AVX), GCC 14.2.0, relinker-only build (-DANYPS5_RELINKER_ONLY=ON): run 1: 99% tests passed, 5 tests failed out of 927; run 2: 99% tests passed, 5 tests failed out of 927; run 3: 99% tests passed, 5 tests failed out of 927. 5 of the failing tests fail on main too.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 10861 core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp
PR 11525 core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp
PR 17105 core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp

@adam25136

Copy link
Copy Markdown
Contributor

inFAMOUS Second Son (PS4) with and without this head: its executable declares 28 PS4 needed-module tags (0x6100000f) and none of the PS5 form (0x61000045). With this PR the conversion still succeeds, the converted executable is 157,696 bytes smaller, and the title reaches the same point as without it. This PR's windows_import_modules test file fails without the change and passes with it.

GPU NVIDIA GeForce RTX 5080, driver 621.14
Host Windows 10 Pro 22H2 (19045), i9-12900KF, WinLibs GCC 15.2.0 r7, CMake 4.3.1, Release
Title CUSA00223 01.07, executable from main's unwrap_self.py
Build without this PR main 1adc0e2f4b with the changes the title needs to get this far merged locally: #18235, #17711 (keeping main's version of libSceGnmDriverForNeoMode/Export.cpp, so #17711's changes to that file are left out), #18184, #21961, and two local changes not open as PRs; converted with relinker --windows --registry --trace-imports
Build with this PR the same, plus head 40383cd7e5 (git merge --no-ff, clean merge), converted the same way
  • windows_import_modules with this PR's test file: on the build without this PR it fails with AssertionError: ('ps4-b-prx', 11, 'Transferring control to ELF entry point\n', ''); on the build with it, it passes. On plain main 1adc0e2f4b with only the test file taken from this PR, it fails the same way (in a build folder configured with -DBUILD_TESTING=ON):
    git fetch origin pull/20574/head && git checkout 1adc0e2f4b
    git checkout FETCH_HEAD -- core/relinker/relinker/tests/test_windows_import_modules.py
    cmake --build build --target relinker && ctest --test-dir build -R '^windows_import_modules$' --output-on-failure
    
  • Conversion: exit 0 on both, the same relinker console log apart from the output path, External prx references: 908 on both. The converted app.exe goes from 16,916,992 to 16,759,296 bytes: .entry from 361,370 to 310,435 and .startup from 1,442,356 to 1,335,615 bytes (objdump -h); no other section changes size.
  • One traced start of each: both end at the same place, compute shader 0x2f2fa2500: AGC graphics: PS4 multisampled textures are not implemented (29.2 s without this PR, 26.3 s with it), with 0 unresolved imports. All 32 imports in each run's most-called list are the same NIDs from the same modules, in the same order.
  • Not covered: the other eight tests this PR's description lists (not run here); other PS4 titles (GTA V PS4 was not run); Linux output; and anything after that stop: the title has not reached gameplay on AnyPS5, so imports used later were not exercised.

AI-assisted: yes. Claude Code ran the builds, the conversions and the runs, and drafted this comment; a separate review agent checked it. The numbers are from the runs on this machine.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PS4 needed-module tags — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head 40383cd7e59d61220783f03d9fc5b78f2d813359, base main.
  • Read the diff of both changed files, then the head context around the change with repo_read.py.
  • Compared the new tag handling with the guest reader.
  • No build, no CTest run, and no hosted CI check in this pass.
python3 repo_read.py cat core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp 296 336
python3 repo_read.py cat core/relinker/relinker/src/guest/GuestImageReader.cpp 75 115
python3 repo_read.py search ps4ModuleImports
python3 repo_read.py search 0x6100000f

Results

Check Result Note
Diff of both changed files passed Read in full as diff
Parity with guest reader passed Same mixed-tag and duplicate-ID rules
Relinker build and focused CTests not run Author-reported, Windows only
Hosted CI for this head not run Not fetched in this pass
Overlap scan not run Author-reported, five comparisons incomplete
Commands and output

Search for 0x6100000f at the head returned the relinker pipeline, the guest reader, and the new tests. Search for ps4ModuleImports returned the two readers and the mixed-tag check at core/relinker/relinker/src/guest/GuestImageReader.cpp:194.

Findings

Blocking

  • None.

Non-blocking

  • core/relinker/relinker/tests/test_windows_import_modules.py:715: the runtime assertions (exit code 22, unresolved-import stderr) run only when os.name == 'nt'. On Linux only the structural checks run. This follows the existing test style, so it is a note, not a defect.

Sources

  • Mixed-tag and duplicate-ID handling:
    std::vector<std::uint64_t> moduleImports;
    std::vector<std::uint64_t> ps4ModuleImports;
    std::set<std::uint64_t> ownModules;
    for (const auto& tag : dynTags) {
    if (tag.Tag == 0x61000043 || tag.Tag == 0x6100000d) ownModules.insert(tag.Value >> 48);
    else if (tag.Tag == 0x61000045) moduleImports.push_back(tag.Value);
    else if (tag.Tag == 0x6100000f) ps4ModuleImports.push_back(tag.Value);
    }
    if (!moduleImports.empty() && !ps4ModuleImports.empty())
    throw RelinkerException("Executable mixes PS4 and PS5 needed-module tags");
    std::map<std::uint64_t, std::string> importModules;
    for (const auto value : moduleImports.empty() ? ps4ModuleImports : moduleImports)
    if (!importModules.emplace(value >> 48, readCStr(value & 0xffffffffu)).second)
    throw RelinkerException("Duplicate import module ID");
  • Matching guest reader rule:
    if (!moduleImports.empty() && !ps4ModuleImports.empty()) fail("Guest module mixes PS4 and PS5 needed-module tags");
    for (const auto value : moduleImports.empty() ? ps4ModuleImports : moduleImports)

Not verified

  • The Windows CTests (nine named tests) and the module-scoped import test, which the author reports as passed. I did not run them.
  • Native Linux execution of the Windows-test fixtures (author reports it was not run).
  • Hosted CI status for this head. The approval rules need it to pass before approval, so this review is COMMENT.
  • Author identity for the approval rules; the description does not state it.
  • Unchanged parts of test_windows_import_modules.py. Only its changed hunks were read.
  • The five overlap comparisons the author could not complete (#10861, #11525, #15896, #15903, #17105).

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit 3350a35 into boykopovar:main Nov 22, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants