fix(libc): find a relinked module whose name differs in case #5434

Merged
milescoviello merged 1 commit from upstream-pr/5434 into main 2026-10-14 09:41:24 +00:00
milescoviello commented 2026-10-13 19:40:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-13T19:40:29Z.


What

On Linux, a title that loads a bundled module under a name whose case differs from the shipped file gets ENOENT. Borderlands 4 (PPSA01494) loads its UI library with sceKernelLoadStartModule("/app0/prx/libRenoirCore.PS5.prx") but ships it as prx/librenoircore.ps5.prx. On main it logs:

Could not load /app0/prx/libRenoirCore.PS5.prx result 0, handle result -2147352574

That handle is 0x80020002, ENOENT.

Guest paths are resolved case-insensitively (ResolveHostPath), but only against names that exist. With the runtime layout in docs/user/USAGE.md, app0/prx holds the relinker's librenoircore.ps5.prx.guest.prx and not the original module. So the requested name resolves to itself, and RelinkedModulePath_nid_no_patch (#4688) then looks for libRenoirCore.PS5.prx.guest.prx with its exact spelling. When the original .prx is still in app0, the resolver fixes the case first, which is why this only shows without it. Windows and macOS hosts ignore the case anyway, so only Linux is affected.

RelinkedModulePath_nid_no_patch now falls back to the same ASCII case-insensitive match as ResolveHostPath when the exact <name>.guest.prx is missing, and throws for an ambiguous match as that does. dlopen (and so sceKernelLoadStartModule), stat, open and sceKernelCheckReachability all use it. The libc debt entry for guest path resolution now mentions it.

guest_filesystem gains TestRelinkedModuleNameCase. With only librenoircore.ps5.prx.guest.prx in a directory, it checks four things on libRenoirCore.PS5.prx: sceKernelStat and stat report the converted file, sceKernelCheckReachability succeeds, and sceKernelOpen opens it. A name that is not there still gets ENOENT.

Tested

Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on main dacd78525, RTX 4070 Ti (NVIDIA 580.142):

  • With main's General.cpp and the new test, guest_filesystem fails at the first sceKernelStat (ENOENT); with the change it passes 20/20.
  • All 342 guest_* tests pass in two runs, and the 16 relinker and module tests pass.
  • Borderlands 4 (PPSA01494): relinked with --to-intel, with the converted modules in app0/sce_module and app0/prx as the relinker writes them, and run on Linux for 85 to 240 s. It starts, plays its logo movies and stays on its loading screen. The Could not load line above comes from a run on main 18c438b10, with only #5387's unrelated sysctlbyname change in libkernel. The title makes that call late in loading, so not every run reaches it within the time limit. In the runs with this change the line did not appear.

Not checked on a console.

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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848515034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5434). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-13T19:40:29Z. --- ### What On Linux, a title that loads a bundled module under a name whose case differs from the shipped file gets `ENOENT`. Borderlands 4 (PPSA01494) loads its UI library with `sceKernelLoadStartModule("/app0/prx/libRenoirCore.PS5.prx")` but ships it as `prx/librenoircore.ps5.prx`. On `main` it logs: ``` Could not load /app0/prx/libRenoirCore.PS5.prx result 0, handle result -2147352574 ``` That handle is `0x80020002`, `ENOENT`. Guest paths are resolved case-insensitively (`ResolveHostPath`), but only against names that exist. With the runtime layout in `docs/user/USAGE.md`, `app0/prx` holds the relinker's `librenoircore.ps5.prx.guest.prx` and not the original module. So the requested name resolves to itself, and `RelinkedModulePath_nid_no_patch` (#4688) then looks for `libRenoirCore.PS5.prx.guest.prx` with its exact spelling. When the original `.prx` is still in `app0`, the resolver fixes the case first, which is why this only shows without it. Windows and macOS hosts ignore the case anyway, so only Linux is affected. `RelinkedModulePath_nid_no_patch` now falls back to the same ASCII case-insensitive match as `ResolveHostPath` when the exact `<name>.guest.prx` is missing, and throws for an ambiguous match as that does. `dlopen` (and so `sceKernelLoadStartModule`), `stat`, `open` and `sceKernelCheckReachability` all use it. The libc debt entry for guest path resolution now mentions it. `guest_filesystem` gains `TestRelinkedModuleNameCase`. With only `librenoircore.ps5.prx.guest.prx` in a directory, it checks four things on `libRenoirCore.PS5.prx`: `sceKernelStat` and `stat` report the converted file, `sceKernelCheckReachability` succeeds, and `sceKernelOpen` opens it. A name that is not there still gets `ENOENT`. ### Tested Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on `main` dacd78525, RTX 4070 Ti (NVIDIA 580.142): - With `main`'s `General.cpp` and the new test, `guest_filesystem` fails at the first `sceKernelStat` (`ENOENT`); with the change it passes 20/20. - All 342 `guest_*` tests pass in two runs, and the 16 relinker and module tests pass. - Borderlands 4 (PPSA01494): relinked with `--to-intel`, with the converted modules in `app0/sce_module` and `app0/prx` as the relinker writes them, and run on Linux for 85 to 240 s. It starts, plays its logo movies and stays on its loading screen. The `Could not load` line above comes from a run on `main` 18c438b10, with only #5387's unrelated `sysctlbyname` change in libkernel. The title makes that call late in loading, so not every run reaches it within the time limit. In the runs with this change the line did not appear. Not checked on a console. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
milescoviello commented 2026-10-14 01:34:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T01:34:04Z.


Rebased onto main 34355eeea. The only conflict was docs/dev/debt/libc.md, next to the new tzname entry; both entries are kept. After the rebase, the build is clean, guest_filesystem passes 5/5 and all 354 guest_* tests pass (Ubuntu 24.04, GCC 13.3, Release).

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158898273 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5434#issuecomment-6158898273). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T01:34:04Z. --- Rebased onto `main` 34355eeea. The only conflict was `docs/dev/debt/libc.md`, next to the new `tzname` entry; both entries are kept. After the rebase, the build is clean, `guest_filesystem` passes 5/5 and all 354 `guest_*` tests pass (Ubuntu 24.04, GCC 13.3, Release). AI-assisted: yes
oneandonlydean commented 2026-10-14 05:10:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:10:17Z.


The full build is green on this head. Before it goes in it needs one run by someone other than the author on the title this is for (title ID, GPU/OS, before/after on current main); could someone who has it post one?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161386612 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5434#issuecomment-6161386612). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:10:17Z. --- The full build is green on this head. Before it goes in it needs one run by someone other than the author on the title this is for (title ID, GPU/OS, before/after on current `main`); could someone who has it post one?
milescoviello commented 2026-10-14 05:12:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T05:12:15Z.


Thanks, @oneandonlydean. To make a run quick for anyone with Borderlands 4 (PPSA01494, any GPU; the stop is in module loading, before any GPU work):

  1. Relink with --to-intel and lay out app0 as docs/user/USAGE.md describes, so app0/prx holds librenoircore.ps5.prx.guest.prx.
  2. On current main, the log has Could not load /app0/prx/libRenoirCore.PS5.prx result 0, handle result -2147352574 within the first seconds.
  3. With this PR that line is gone, and the title goes on to its logo movies.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161409467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5434#issuecomment-6161409467). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T05:12:15Z. --- Thanks, @oneandonlydean. To make a run quick for anyone with Borderlands 4 (PPSA01494, any GPU; the stop is in module loading, before any GPU work): 1. Relink with `--to-intel` and lay out `app0` as `docs/user/USAGE.md` describes, so `app0/prx` holds `librenoircore.ps5.prx.guest.prx`. 2. On current `main`, the log has `Could not load /app0/prx/libRenoirCore.PS5.prx result 0, handle result -2147352574` within the first seconds. 3. With this PR that line is gone, and the title goes on to its logo movies. AI-assisted: yes
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!5434
No description provided.