windows: stub unresolved imports (log once + return 0) instead of fatal #29

Closed
Pouare514 wants to merge 3 commits from upstream-pr/29 into main
Pouare514 commented 2026-09-27 11:31:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pouare514 on 2026-09-27T11:31:31Z.


Unresolved ELF imports bind to a per-NID trampoline (log once at bind, log once at first call, return 0) instead of FAIL 0xC0000139. windows-diagnostics-imports.txt unchanged. lazy-binding aligned to ret-0. New windows_stub_policy_tests (synthetic PE, exit 42, 1x/1x logging). R_X86_64_64 addend handled.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4653544446 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/29). Originally posted by [Pouare514](https://github.com/Pouare514) on 2026-09-27T11:31:31Z. --- Unresolved ELF imports bind to a per-NID trampoline (log once at bind, log once at first call, return 0) instead of FAIL 0xC0000139. windows-diagnostics-imports.txt unchanged. lazy-binding aligned to ret-0. New windows_stub_policy_tests (synthetic PE, exit 42, 1x/1x logging). R_X86_64_64 addend handled.
boykopovar commented 2026-09-27 13:08:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-27T13:08:12Z.


Recently, a branch with a similar feature was merged from main, which, on Windows, writes the path to a library that was not found.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5856139536 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/29#issuecomment-5856139536). Originally posted by [boykopovar](https://github.com/boykopovar) on 2026-09-27T13:08:12Z. --- Recently, a branch with a similar feature was merged from main, which, on Windows, writes the path to a library that was not found.
Pouare514 commented 2026-09-27 13:48:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pouare514 on 2026-09-27T13:48:58Z.


Rebased on top of main (sce-module-load + missing-module path). Instead of picking a side, the stub policy now feeds both modes: eager binds GOT slots to the ret-0 trampolines directly as before, lazy binds the same trampolines through the LazyStubs file-patch mechanism (replacing the fail stubs). Guest startup/TLS-resolver flow is untouched.

Two latent bugs fixed along the way:

  • writeGotStub wrote a raw 32-bit RVA into the 64-bit GOT slot (jump into unmapped low memory on first lazy call); it now writes ImageBase + RVA as U64.
  • stub-policy tests asserted LazyStubs stays empty; updated to expect one file-patched slot per import in lazy mode (resolvable ones are simply re-resolved at boot).

windows_stub_policy_tests (eager/clean/lazy/addend boots, all exit 0 with exact STUB lines) and windows_dependency_diagnostics_tests are green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5856426985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/29#issuecomment-5856426985). Originally posted by [Pouare514](https://github.com/Pouare514) on 2026-09-27T13:48:58Z. --- Rebased on top of main (sce-module-load + missing-module path). Instead of picking a side, the stub policy now feeds both modes: eager binds GOT slots to the ret-0 trampolines directly as before, lazy binds the same trampolines through the LazyStubs file-patch mechanism (replacing the fail stubs). Guest startup/TLS-resolver flow is untouched. Two latent bugs fixed along the way: - writeGotStub wrote a raw 32-bit RVA into the 64-bit GOT slot (jump into unmapped low memory on first lazy call); it now writes ImageBase + RVA as U64. - stub-policy tests asserted LazyStubs stays empty; updated to expect one file-patched slot per import in lazy mode (resolvable ones are simply re-resolved at boot). windows_stub_policy_tests (eager/clean/lazy/addend boots, all exit 0 with exact STUB lines) and windows_dependency_diagnostics_tests are green.
boykopovar commented 2026-09-27 15:10:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-27T15:10:43Z.


Essentially, this changes the policy from “import not found -> application doesn’t start immediately and writes what’s wrong” to “import not found -> we substitute a stub and try to continue execution.”

The entire project was built on a strict approach, to move forward slowly but surely, rather than pretending everything was fine and then running into a segfault later.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5857060985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/29#issuecomment-5857060985). Originally posted by [boykopovar](https://github.com/boykopovar) on 2026-09-27T15:10:43Z. --- Essentially, this changes the policy from “import not found -> application doesn’t start immediately and writes what’s wrong” to “import not found -> we substitute a stub and try to continue execution.” The entire project was built on a strict approach, to move forward slowly but surely, rather than pretending everything was fine and then running into a segfault later.

Pull request closed

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!29
No description provided.