feat(relinker): report every unresolved ELF import before failing on Windows #5406

Merged
tibzejoker merged 1 commit from upstream-pr/5406 into main 2026-10-14 12:07:47 +00:00
tibzejoker commented 2026-10-13 19:03:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T19:03:27Z.


What

On Windows, a converted title that imports functions no library provides used to stop at the first one. Each run printed a single line:

FAIL: unresolved ELF import <NID> from <library>

Listing every missing function took one run per function: implement or declare it, convert again, and see the next one.

The startup stub now goes through all imports before failing:

  • An unresolved import still prints its usual FAIL: unresolved ELF import ... line. The stub then counts it and moves on to the next import, without writing that import's slot.
  • After the last import, if any failed, the stub fails once:
    • it prints the searched library list and the last Windows error, as before;
    • it raises STATUS_ENTRYPOINT_NOT_FOUND (0xc0000139), as before.

Each line keeps its exact format, so tools and issue reports that match FAIL: unresolved ELF import still work.

Unchanged:

  • weak imports;
  • --lazy-binding, which still defers each unresolved import to a stub that fails when it is called;
  • a start-up where every import resolves.

The only extra cost is a counter increment per unresolved import and one test after the import loop.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, on main 18c438b10.

  • windows_import_modules: the test fixture can now carry several imports. A new case converts an executable that imports from a.prx:

    • absent (not exported);
    • shared (exported);
    • missing (not exported).

    The test runs the converted executable and checks three things:

    • it exits with 0xc0000139;
    • its stderr has exactly the two lines FAIL: unresolved ELF import absent from a.prx and FAIL: unresolved ELF import missing from a.prx, in that order;
    • it never reaches the ELF entry point.

    On main it fails: only the absent line is printed. With the change it passes.

  • All relinker tests that run on Windows (90 of the 100 in core/relinker/CMakeLists.txt) pass, including the existing single-import failures (missing-symbol, wrong-provider, missing-symbol-gui), weak_imports, and the tests that convert with --lazy-binding (windows_fixed_base, windows_trace_imports).

  • tools/check_conventions.py --base upstream/main passes.

  • Not tested with a game.

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 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 (start-up diagnostics: a title missing several imports shows all of them in one run)
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code); the change and test were reviewed and run locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V1W4jdNSKTV7xwuS6xQPJV

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848093224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5406). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-13T19:03:27Z. --- ### What On Windows, a converted title that imports functions no library provides used to stop at the first one. Each run printed a single line: ``` FAIL: unresolved ELF import <NID> from <library> ``` Listing every missing function took one run per function: implement or declare it, convert again, and see the next one. The startup stub now goes through all imports before failing: - An unresolved import still prints its usual `FAIL: unresolved ELF import ...` line. The stub then counts it and moves on to the next import, without writing that import's slot. - After the last import, if any failed, the stub fails once: - it prints the searched library list and the last Windows error, as before; - it raises `STATUS_ENTRYPOINT_NOT_FOUND` (0xc0000139), as before. Each line keeps its exact format, so tools and issue reports that match `FAIL: unresolved ELF import` still work. Unchanged: - weak imports; - `--lazy-binding`, which still defers each unresolved import to a stub that fails when it is called; - a start-up where every import resolves. The only extra cost is a counter increment per unresolved import and one test after the import loop. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, on `main` 18c438b10. - `windows_import_modules`: the test fixture can now carry several imports. A new case converts an executable that imports from `a.prx`: - `absent` (not exported); - `shared` (exported); - `missing` (not exported). The test runs the converted executable and checks three things: - it exits with 0xc0000139; - its stderr has exactly the two lines `FAIL: unresolved ELF import absent from a.prx` and `FAIL: unresolved ELF import missing from a.prx`, in that order; - it never reaches the ELF entry point. On `main` it fails: only the `absent` line is printed. With the change it passes. - All relinker tests that run on Windows (90 of the 100 in `core/relinker/CMakeLists.txt`) pass, including the existing single-import failures (`missing-symbol`, `wrong-provider`, `missing-symbol-gui`), `weak_imports`, and the tests that convert with `--lazy-binding` (`windows_fixed_base`, `windows_trace_imports`). - `tools/check_conventions.py --base upstream/main` passes. - Not tested with a game. ### 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 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 (start-up diagnostics: a title missing several imports shows all of them in one run) - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code); the change and test were reviewed and run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01V1W4jdNSKTV7xwuS6xQPJV
adriadam10 commented 2026-10-14 11:41:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:41:16Z.


Checked the stub change (counter after each unresolved import, single failure after the import loop; weak and --lazy-binding paths untouched) and the new missing-symbols case, which fails on main as described. main moved executable() into guest_import_fixtures.py, so I rebased and moved the extra_symbols extension there; relinker build and tests are green on Linux (128/128 in scope), and the Windows build will run before merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167504344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5406#issuecomment-6167504344). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T11:41:16Z. --- Checked the stub change (counter after each unresolved import, single failure after the import loop; weak and `--lazy-binding` paths untouched) and the new `missing-symbols` case, which fails on `main` as described. `main` moved `executable()` into `guest_import_fixtures.py`, so I rebased and moved the `extra_symbols` extension there; relinker build and tests are green on Linux (128/128 in scope), and the Windows build will run before merging.
github-actions[bot] commented 2026-10-14 11:44:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T11:44:21Z.


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
#3965 core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp L594
core/relinker/relinker/tests/test_windows_import_modules.py L395
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167555740 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5406#issuecomment-6167555740). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T11:44:21Z. --- <!-- 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 | |---|---|---|---| | #3965 | `core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp` [L594](https://github.com/boykopovar/AnyPS5/blob/cd65bfafe2456374bb6489ce23d4b4dd899b9848/core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp#L594)<br>`core/relinker/relinker/tests/test_windows_import_modules.py` [L395](https://github.com/boykopovar/AnyPS5/blob/cd65bfafe2456374bb6489ce23d4b4dd899b9848/core/relinker/relinker/tests/test_windows_import_modules.py#L395) | | |
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!5406
No description provided.