loader: load the bundled PRXs the executable imports at startup #1366

Open
github-bot wants to merge 2 commits from github-bot/gh-1366 into main AGit
Owner

@⁠LukaszRozmej on GitHub · 2026-10-10 11:26 UTC · original
LukaszRozmej:fix/load-imported-bundled-prx → main · +35 −1 · 2 files · 2 commits · open

Problem

Only /app0/sce_module/libc.prx is loaded automatically. Other bundled modules the
executable imports from are never loaded unless the game requests them, so every import from
them is bound to a stub that returns 0.

Astro Bot (PPSA21564) ships sce_module/libSceNpCppWebApi.prx, and its eboot.bin imports 802
NpCppWebApi functions directly. The game never asks for the module, so it runs on stubs:

Unresolved import stub called: Y295ygEccqk[NpCppWebApi_v1][NpCppWebApi_v1.1][Func]
Unresolved import stub called: 8x++mBOUeso[NpCppWebApi_v1][NpCppWebApi_v1.1][Func]
...

Fix

For each module the executable imports, load sce_module/<module name>.prx if it exists,
next to libc, and start it after libc.

  • A bundled PRX is named after the module it exports: libc.prx exports libc, and
    libSceNpCppWebApi.prx exports libSceNpCppWebApi.
  • PS5 modules keep their names in DT_STRTAB rather than DT_OS_STRTAB, so the names come
    from the already-loaded executable's import list; the PRX isn't opened unless it's imported.
  • HLE symbols still take precedence in Resolve, so this only fills imports Kyty doesn't
    implement.

Risk

Games that bundle other PRXs they import will now load them and run their module_start at
boot. That's what fixes the stubbed imports, but a module whose initializer needs something
Kyty doesn't implement yet would now fail at startup instead of later. Happy to gate this
differently if you prefer.

Testing

  • Windows, clang-cl 20.1.8, Release; builds cleanly on current main (307fdcf).
  • Astro Bot: libSceNpCppWebApi.prx loads, relocates and starts, and the Unresolved import stub called count drops from 4 to 0. That run used the same change on 7b9997b; on current
    main I've verified the build only.
  • The Astro Bot boot crash itself is fixed separately in #1365.
**@⁠LukaszRozmej** on GitHub · 2026-10-10 11:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366) `LukaszRozmej:fix/load-imported-bundled-prx` → `main` · +35 −1 · 2 files · 2 commits · open ## Problem Only `/app0/sce_module/libc.prx` is loaded automatically. Other bundled modules the executable imports from are never loaded unless the game requests them, so every import from them is bound to a stub that returns 0. Astro Bot (PPSA21564) ships `sce_module/libSceNpCppWebApi.prx`, and its `eboot.bin` imports 802 `NpCppWebApi` functions directly. The game never asks for the module, so it runs on stubs: ``` Unresolved import stub called: Y295ygEccqk[NpCppWebApi_v1][NpCppWebApi_v1.1][Func] Unresolved import stub called: 8x++mBOUeso[NpCppWebApi_v1][NpCppWebApi_v1.1][Func] ... ``` ## Fix For each module the executable imports, load `sce_module/<module name>.prx` if it exists, next to libc, and start it after libc. - A bundled PRX is named after the module it exports: `libc.prx` exports `libc`, and `libSceNpCppWebApi.prx` exports `libSceNpCppWebApi`. - PS5 modules keep their names in `DT_STRTAB` rather than `DT_OS_STRTAB`, so the names come from the already-loaded executable's import list; the PRX isn't opened unless it's imported. - HLE symbols still take precedence in `Resolve`, so this only fills imports Kyty doesn't implement. ## Risk Games that bundle other PRXs they import will now load them and run their `module_start` at boot. That's what fixes the stubbed imports, but a module whose initializer needs something Kyty doesn't implement yet would now fail at startup instead of later. Happy to gate this differently if you prefer. ## Testing - Windows, clang-cl 20.1.8, Release; builds cleanly on current `main` (307fdcf). - Astro Bot: `libSceNpCppWebApi.prx` loads, relocates and starts, and the `Unresolved import stub called` count drops from 4 to 0. That run used the same change on 7b9997b; on current `main` I've verified the build only. - The Astro Bot boot crash itself is fixed separately in #1365.
Only /app0/sce_module/libc.prx was loaded automatically. Other bundled
modules the executable imports from, such as libSceNpCppWebApi.prx in
Astro Bot (PPSA21564), were never loaded unless the game requested them,
so their functions were bound to stubs returning 0 ("Unresolved import
stub called: ...[NpCppWebApi_v1]").

Load sce_module/<module name>.prx for every module the executable imports,
next to libc, and start them after libc. A bundled PRX is named after the
module it exports (libc.prx exports libc, libSceNpCppWebApi.prx exports
libSceNpCppWebApi). HLE symbols still take precedence when resolving.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:54:33 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-10 11:32 UTC · original · edited 2026-10-12 14:20 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b2d42e7-819a-4fe2-9cea-bffc85c7d082

📥 Commits

Reviewing files that changed from the base of the PR and between 0c16598752 and 1357fc5c30.


📒 Files selected for processing (1)
  • src/loader/runtimeLinker.cpp

🚧 Files skipped from review as they are similar to previous changes (1)
  • src/loader/runtimeLinker.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

RuntimeLinker finds imported modules for the first non-shared program and loads matching PRX files from a supplied folder when they exist and are not already loaded. Execute uses libc’s directory for this lookup. After relocation, it starts each loaded bundled module with a nonzero initializer.


Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1357f

No established issue remains that prevents merging after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: loading bundled PRXs imported by the executable during startup.
Description check Passed The description explains the problem, the bundled PRX loading fix, resolution behavior, risks, and testing. It directly matches the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-10 11:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366#issuecomment-6097056353) · edited 2026-10-12 14:20 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1366?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `3b2d42e7-819a-4fe2-9cea-bffc85c7d082` <hr> </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 0c165987522a96a9831586cf5478e0d3aacc278d and 1357fc5c30417b18468ebd64a5987dd7ccbdd8e4. <hr> </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (1)</strong></summary> <dl> <dd> * `src/loader/runtimeLinker.cpp` <hr> </dd> </dl> </details> <details> <summary><strong>🚧 Files skipped from review as they are similar to previous changes (1)</strong></summary> <dl> <dd> * src/loader/runtimeLinker.cpp <hr> </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. <hr> </dd> </dl> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough `RuntimeLinker` finds imported modules for the first non-shared program and loads matching PRX files from a supplied folder when they exist and are not already loaded. `Execute` uses libc’s directory for this lookup. After relocation, it starts each loaded bundled module with a nonzero initializer. <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"1357fc5c30417b18468ebd64a5987dd7ccbdd8e4" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `1357f` <!-- final_review_risk_coverage:{"sourceCommitId":"1357fc5c30417b18468ebd64a5987dd7ccbdd8e4","coveredCommitId":"1357fc5c30417b18468ebd64a5987dd7ccbdd8e4","kind":"reviewed"} --> No established issue remains that prevents merging after normal checks. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v1.svg" width="14" height="17" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: loading bundled PRXs imported by the executable during startup. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the problem, the bundled PRX loading fix, resolution behavior, risks, and testing. It directly matches the changeset. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <hr> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1366)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) <hr> </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -1220,0 +1237,4 @@
if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {
modules.push_back(LoadProgram(path));
}
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-10 11:32 UTC · original · edited 2026-10-12 14:18 UTC

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'import_modules|ImportModule|imported\\.name|LoadImportedBundledModules|IsFileExisting|LoadProgram\\(' src/loader src/common
sed -n '1217,1242p' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 1182


🏁 Script executed:

set -u
printf '%s\n' '--- symbol locations ---'
for term in 'import_modules' 'LoadImportedBundledModules' 'IsFileExisting' 'LoadProgram' 'struct ImportModule' 'class ImportModule'; do
  printf '\n### %s\n' "$term"
  rg -n -F -- "$term" src/loader src/common src || test "$?" -eq 1
done

printf '%s\n' '--- runtime linker declarations and loading paths ---'
rg -n -F -- 'RuntimeLinker::LoadProgram' src/loader
rg -n -F -- 'LoadProgram(' src/loader/runtimeLinker.cpp src/loader/runtimeLinker.h
rg -n -F -- 'IsFileExisting' src/common src/loader

printf '%s\n' '--- candidate parser and type files ---'
rg --files src | rg -i '(elf|loader|linker|program|file)'

Repository: KytyPS5/KytyPS5

Length of output: 10113


🏁 Script executed:

set -u
for term in 'import_modules' 'LoadImportedBundledModules' 'IsFileExisting' 'RuntimeLinker::LoadProgram' 'LoadProgram('; do
  printf '\n### %s\n' "$term"
  rg -n -F -- "$term" src || test "$?" -eq 1
done
printf '\n### files\n'
rg --files src | rg -i '(elf|loader|linker|program|file)'

Repository: KytyPS5/KytyPS5

Length of output: 5617


🏁 Script executed:

set -u
printf '%s\n' '--- runtime linker types and loading ---'
sed -n '70,115p' src/loader/runtimeLinker.h
sed -n '1155,1240p' src/loader/runtimeLinker.cpp
sed -n '1275,1310p' src/loader/runtimeLinker.cpp
sed -n '1955,2010p' src/loader/runtimeLinker.cpp
sed -n '2035,2070p' src/loader/runtimeLinker.cpp

printf '%s\n' '--- file existence implementations ---'
sed -n '315,340p' src/common/file.cpp
sed -n '350,385p' src/common/platform/sysLinuxFileIO.cpp
sed -n '340,375p' src/common/platform/sysWindowsFileIO.cpp

printf '%s\n' '--- related ELF/module declarations ---'
rg -n -F -- 'struct ModuleId' src
rg -n -F -- 'class ModuleId' src
rg -n -F -- 'using ModuleId' src
rg -n -F -- 'GetDynModules' src/loader

Repository: KytyPS5/KytyPS5

Length of output: 13144


🏁 Script executed:

set -u
printf '%s\n' '--- ModuleId and dynamic-module parser ---'
sed -n '20,40p' src/loader/runtimeLinker.h
sed -n '755,805p' src/loader/runtimeLinker.cpp

printf '%s\n' '--- path-info implementations ---'
rg -n -F -- 'SysFileGetInfo' src/common/platform/sysLinuxFileIO.cpp src/common/platform/sysWindowsFileIO.cpp
sed -n '300,350p' src/common/platform/sysLinuxFileIO.cpp
sed -n '295,345p' src/common/platform/sysWindowsFileIO.cpp

Repository: KytyPS5/KytyPS5

Length of output: 6328


🏁 Script executed:

set -u
printf '%s\n' '--- path translation helpers ---'
rg -n -F -- 'get_internal_name' src/common/platform/sysLinuxFileIO.cpp src/common/platform/sysWindowsFileIO.cpp
sed -n '120,180p' src/common/platform/sysLinuxFileIO.cpp
sed -n '100,160p' src/common/platform/sysWindowsFileIO.cpp

Repository: KytyPS5/KytyPS5

Length of output: 5441


🏁 Script executed:

set -u
printf '%s\n' '--- Linux path helper ---'
sed -n '45,70p' src/common/platform/sysLinuxFileIO.cpp
printf '%s\n' '--- Windows file-info implementation ---'
sed -n '255,290p' src/common/platform/sysWindowsFileIO.cpp

Repository: KytyPS5/KytyPS5

Length of output: 2151


Constrain imported module names to a plain filename.

imported.name is copied from the ELF dynamic string table without validation. A name such as ../../outside or an absolute path can escape folder. IsFileExisting checks the resulting path, and LoadProgram opens that same path. Execute then starts the loaded module. A valid PRX outside the bundled directory can therefore be loaded.

Reject path components and root-qualified names before joining the path. A substring check for .. is broader than required; the filename check already prevents traversal.

Suggested fix
--- "a/src/loader/runtimeLinker.cpp"
+++ "b/src/loader/runtimeLinker.cpp"
@@ -1227,8 +1227,14 @@
 		return modules;
 	}
 	// A bundled PRX is named after the module it exports, e.g. libSceNpCppWebApi.prx.
 	for (const auto& imported: (*main)->dynamic_info->import_modules) {
+		const std::filesystem::path module_name(imported.name);
+		if (module_name.empty() || module_name.has_root_name() ||
+		    module_name.has_root_directory() || module_name.filename() != module_name ||
+		    imported.name.find('\\') != std::string::npos) {
+			continue;
+		}
 		const auto path = folder / (imported.name + ".prx");
 		if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {
 			modules.push_back(LoadProgram(path));
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	for (const auto& imported: (*main)->dynamic_info->import_modules) {
		const std::filesystem::path module_name(imported.name);
		if (module_name.empty() || module_name.has_root_name() ||
		    module_name.has_root_directory() || module_name.filename() != module_name ||
		    imported.name.find('\\') != std::string::npos) {
			continue;
		}
		const auto path = folder / (imported.name + ".prx");
		if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {
			modules.push_back(LoadProgram(path));
		}
	}

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'import_modules|LoadImportedBundledModules|LoadProgram\\(|FindProgramByFileName|Resolve.*Import|stub' src/loader
sed -n '1217,1242p' src/loader/runtimeLinker.cpp
sed -n '1270,1320p' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3206


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- symbol references ---'
rg -n -F --glob '*.{cpp,h,hpp}' 'LoadProgram(' src/loader src | head -200
rg -n -F --glob '*.{cpp,h,hpp}' 'FindProgramByFileName' src/loader src | head -100
rg -n -F --glob '*.{cpp,h,hpp}' 'import_modules' src/loader src | head -200
rg -n -i --glob '*.{cpp,h,hpp}' 'stub|resolve.*import|import.*resolve|RelocateAll|Relocate' src/loader | head -240
printf '%s\n' '--- declarations and definitions ---'
rg -n -F --glob '*.{cpp,h,hpp}' 'Program* RuntimeLinker::LoadProgram' src
rg -n -F --glob '*.{cpp,h,hpp}' 'void RuntimeLinker::RelocateAll' src
rg -n -F --glob '*.{cpp,h,hpp}' 'RuntimeLinker::Relocate' src
printf '%s\n' '--- surrounding runtime linker definitions ---'
sed -n '1,260p' src/loader/runtimeLinker.cpp
sed -n '260,620p' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 33935


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- symbol references ---'
rg -n -F --glob '*.{cpp,h,hpp}' 'LoadProgram(' src/loader src | head -200
rg -n -F --glob '*.{cpp,h,hpp}' 'FindProgramByFileName' src/loader src | head -100
rg -n -F --glob '*.{cpp,h,hpp}' 'import_modules' src/loader src | head -200
rg -n -i --glob '*.{cpp,h,hpp}' 'stub|resolve.*import|import.*resolve|RelocateAll|Relocate' src/loader | head -240
printf '%s\n' '--- declarations and definitions ---'
rg -n -F --glob '*.{cpp,h,hpp}' 'Program* RuntimeLinker::LoadProgram' src
rg -n -F --glob '*.{cpp,h,hpp}' 'void RuntimeLinker::RelocateAll' src
rg -n -F --glob '*.{cpp,h,hpp}' 'RuntimeLinker::Relocate' src
printf '%s\n' '--- runtime linker source ranges ---'
sed -n '1,620p' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 33901


🏁 Script executed:

rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'LoadProgram(' src/loader src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'FindProgramByFileName' src/loader src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'import_modules' src/loader src
rg -n -i --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'stub|resolve.*import|import.*resolve|RelocateAll|Relocate' src/loader
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RuntimeLinker::LoadProgram' src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RuntimeLinker::RelocateAll' src
sed -n '1,620p' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 33652


🌐 Web query:

KytyPS5 runtimeLinker.cpp LoadImportedBundledModules LoadProgram

💡 Result:

In the current `main` branch, `src/loader/runtimeLinker.cpp` exists, but I couldn’t find either `LoadImportedBundledModules` or `LoadProgram` in it. That only establishes they aren’t in the version I checked; they may exist in another branch or an older commit. ([github.com](https://github.com/KytyPS5/KytyPS5/blob/main/src/loader/runtimeLinker.cpp?utm_source=openai))

[Open the file on GitHub](https://github.com/KytyPS5/KytyPS5/blob/main/src/loader/runtimeLinker.cpp). If you share a commit hash or tell me whether you want an explanation or help locating an older version, I can narrow it down.

Citations:

- 1: https://github.com/KytyPS5/KytyPS5/blob/main/src/loader/runtimeLinker.cpp?utm_source=openai

🏁 Script executed:

set -o pipefail
printf '%s\n' '--- LoadProgram and adjacent loader paths ---'
sed -n '1168,1215p' src/loader/runtimeLinker.cpp
sed -n '1496,1518p' src/loader/runtimeLinker.cpp
sed -n '1660,1715p' src/loader/runtimeLinker.cpp
printf '%s\n' '--- relocation and unresolved-import path ---'
sed -n '850,925p' src/loader/runtimeLinker.cpp
sed -n '1088,1120p' src/loader/runtimeLinker.cpp
sed -n '1990,2075p' src/loader/runtimeLinker.cpp
printf '%s\n' '--- relevant declarations ---'
sed -n '80,195p' src/loader/runtimeLinker.h

Repository: KytyPS5/KytyPS5

Length of output: 15708


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- relocation symbol resolution ---'
sed -n '730,875p' src/loader/runtimeLinker.cpp
printf '%s\n' '--- Resolve implementation and callers ---'
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RuntimeLinker::Resolve' src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' '->Resolve(' src/loader src/libs src
sed -n '1840,2015p' src/loader/runtimeLinker.cpp
printf '%s\n' '--- symbol database lookup declarations and definitions ---'
rg -n -i --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'class SymbolDatabase|FindSymbol|ResolveSymbol|AddSymbol' src/loader

Repository: KytyPS5/KytyPS5

Length of output: 13888


🏁 Script executed:

set -o pipefail
sed -n '1338,1435p' src/loader/runtimeLinker.cpp
sed -n '1,180p' src/loader/symbolDatabase.h
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'm_symbols->' src/loader/runtimeLinker.cpp
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'export_symbols->' src/loader/runtimeLinker.cpp
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'import_symbols->' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 4905


🏁 Script executed:

sed -n '1348,1435p' src/loader/runtimeLinker.cpp
sed -n '1,180p' src/loader/symbolDatabase.h
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'm_symbols->' src/loader/runtimeLinker.cpp
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'export_symbols->' src/loader/runtimeLinker.cpp
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'import_symbols->' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 4580


🏁 Script executed:

sed -n '1420,1490p' src/loader/runtimeLinker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 2008


Load the bundled PRX dependency closure before relocation.

When a bundled PRX imports another bundled PRX that is not listed by the executable, LoadImportedBundledModules does not load the transitive dependency. LoadProgram loads only the requested ELF and does not recurse. If the dependency's symbol is not provided by HLE or another loaded export, relocation sets its address to zero and patches function imports to UnresolvedImportStub, which returns zero. This can break the importing PRX or its initializer.

Suggested fix
--- "a/src/loader/runtimeLinker.cpp"
+++ "b/src/loader/runtimeLinker.cpp"
@@ -1227,12 +1227,24 @@
 		return modules;
 	}
 	// A bundled PRX is named after the module it exports, e.g. libSceNpCppWebApi.prx.
-	for (const auto& imported: (*main)->dynamic_info->import_modules) {
-		const auto path = folder / (imported.name + ".prx");
-		if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {
-			modules.push_back(LoadProgram(path));
-		}
-	}
+	std::vector<Program*> pending {*main};
+	for (size_t i = 0; i < pending.size(); ++i) {
+		for (const auto& imported: pending[i]->dynamic_info->import_modules) {
+			const auto path = folder / (imported.name + ".prx");
+			if (!Common::File::IsFileExisting(path)) {
+				continue;
+			}
+
+			auto* module = FindProgramByFileName(path);
+			if (module == nullptr) {
+				module = LoadProgram(path);
+				modules.push_back(module);
+			}
+			if (std::find(pending.begin(), pending.end(), module) == pending.end()) {
+				pending.push_back(module);
+			}
+		}
+	}
 
 	return modules;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	std::vector<Program*> pending {*main};
	for (size_t i = 0; i < pending.size(); ++i) {
		for (const auto& imported: pending[i]->dynamic_info->import_modules) {
			const auto path = folder / (imported.name + ".prx");
			if (!Common::File::IsFileExisting(path)) {
				continue;
			}

			auto* module = FindProgramByFileName(path);
			if (module == nullptr) {
				module = LoadProgram(path);
				modules.push_back(module);
			}
			if (std::find(pending.begin(), pending.end(), module) == pending.end()) {
				pending.push_back(module);
			}
		}
	}

✅ Confirmed as addressed by @⁠LukaszRozmej

**@⁠coderabbitai[bot]** on GitHub · 2026-10-10 11:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366#discussion_r4237473315) · edited 2026-10-12 14:18 UTC **🔒 Security & Privacy** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash rg -n 'import_modules|ImportModule|imported\\.name|LoadImportedBundledModules|IsFileExisting|LoadProgram\\(' src/loader src/common sed -n '1217,1242p' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 1182 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- symbol locations ---' for term in 'import_modules' 'LoadImportedBundledModules' 'IsFileExisting' 'LoadProgram' 'struct ImportModule' 'class ImportModule'; do printf '\n### %s\n' "$term" rg -n -F -- "$term" src/loader src/common src || test "$?" -eq 1 done printf '%s\n' '--- runtime linker declarations and loading paths ---' rg -n -F -- 'RuntimeLinker::LoadProgram' src/loader rg -n -F -- 'LoadProgram(' src/loader/runtimeLinker.cpp src/loader/runtimeLinker.h rg -n -F -- 'IsFileExisting' src/common src/loader printf '%s\n' '--- candidate parser and type files ---' rg --files src | rg -i '(elf|loader|linker|program|file)' ``` Repository: KytyPS5/KytyPS5 Length of output: 10113 --- 🏁 Script executed: ```bash set -u for term in 'import_modules' 'LoadImportedBundledModules' 'IsFileExisting' 'RuntimeLinker::LoadProgram' 'LoadProgram('; do printf '\n### %s\n' "$term" rg -n -F -- "$term" src || test "$?" -eq 1 done printf '\n### files\n' rg --files src | rg -i '(elf|loader|linker|program|file)' ``` Repository: KytyPS5/KytyPS5 Length of output: 5617 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- runtime linker types and loading ---' sed -n '70,115p' src/loader/runtimeLinker.h sed -n '1155,1240p' src/loader/runtimeLinker.cpp sed -n '1275,1310p' src/loader/runtimeLinker.cpp sed -n '1955,2010p' src/loader/runtimeLinker.cpp sed -n '2035,2070p' src/loader/runtimeLinker.cpp printf '%s\n' '--- file existence implementations ---' sed -n '315,340p' src/common/file.cpp sed -n '350,385p' src/common/platform/sysLinuxFileIO.cpp sed -n '340,375p' src/common/platform/sysWindowsFileIO.cpp printf '%s\n' '--- related ELF/module declarations ---' rg -n -F -- 'struct ModuleId' src rg -n -F -- 'class ModuleId' src rg -n -F -- 'using ModuleId' src rg -n -F -- 'GetDynModules' src/loader ``` Repository: KytyPS5/KytyPS5 Length of output: 13144 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- ModuleId and dynamic-module parser ---' sed -n '20,40p' src/loader/runtimeLinker.h sed -n '755,805p' src/loader/runtimeLinker.cpp printf '%s\n' '--- path-info implementations ---' rg -n -F -- 'SysFileGetInfo' src/common/platform/sysLinuxFileIO.cpp src/common/platform/sysWindowsFileIO.cpp sed -n '300,350p' src/common/platform/sysLinuxFileIO.cpp sed -n '295,345p' src/common/platform/sysWindowsFileIO.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 6328 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- path translation helpers ---' rg -n -F -- 'get_internal_name' src/common/platform/sysLinuxFileIO.cpp src/common/platform/sysWindowsFileIO.cpp sed -n '120,180p' src/common/platform/sysLinuxFileIO.cpp sed -n '100,160p' src/common/platform/sysWindowsFileIO.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 5441 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- Linux path helper ---' sed -n '45,70p' src/common/platform/sysLinuxFileIO.cpp printf '%s\n' '--- Windows file-info implementation ---' sed -n '255,290p' src/common/platform/sysWindowsFileIO.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 2151 --- </details> **Constrain imported module names to a plain filename.** `imported.name` is copied from the ELF dynamic string table without validation. A name such as `../../outside` or an absolute path can escape `folder`. `IsFileExisting` checks the resulting path, and `LoadProgram` opens that same path. `Execute` then starts the loaded module. A valid PRX outside the bundled directory can therefore be loaded. Reject path components and root-qualified names before joining the path. A substring check for `..` is broader than required; the filename check already prevents traversal. <details> <summary>Suggested fix</summary> ```diff --- "a/src/loader/runtimeLinker.cpp" +++ "b/src/loader/runtimeLinker.cpp" @@ -1227,8 +1227,14 @@ return modules; } // A bundled PRX is named after the module it exports, e.g. libSceNpCppWebApi.prx. for (const auto& imported: (*main)->dynamic_info->import_modules) { + const std::filesystem::path module_name(imported.name); + if (module_name.empty() || module_name.has_root_name() || + module_name.has_root_directory() || module_name.filename() != module_name || + imported.name.find('\\') != std::string::npos) { + continue; + } const auto path = folder / (imported.name + ".prx"); if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) { modules.push_back(LoadProgram(path)); } ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion for (const auto& imported: (*main)->dynamic_info->import_modules) { const std::filesystem::path module_name(imported.name); if (module_name.empty() || module_name.has_root_name() || module_name.has_root_directory() || module_name.filename() != module_name || imported.name.find('\\') != std::string::npos) { continue; } const auto path = folder / (imported.name + ".prx"); if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) { modules.push_back(LoadProgram(path)); } } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:7209a7911ccba09743353579 --> --- **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash rg -n 'import_modules|LoadImportedBundledModules|LoadProgram\\(|FindProgramByFileName|Resolve.*Import|stub' src/loader sed -n '1217,1242p' src/loader/runtimeLinker.cpp sed -n '1270,1320p' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3206 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- symbol references ---' rg -n -F --glob '*.{cpp,h,hpp}' 'LoadProgram(' src/loader src | head -200 rg -n -F --glob '*.{cpp,h,hpp}' 'FindProgramByFileName' src/loader src | head -100 rg -n -F --glob '*.{cpp,h,hpp}' 'import_modules' src/loader src | head -200 rg -n -i --glob '*.{cpp,h,hpp}' 'stub|resolve.*import|import.*resolve|RelocateAll|Relocate' src/loader | head -240 printf '%s\n' '--- declarations and definitions ---' rg -n -F --glob '*.{cpp,h,hpp}' 'Program* RuntimeLinker::LoadProgram' src rg -n -F --glob '*.{cpp,h,hpp}' 'void RuntimeLinker::RelocateAll' src rg -n -F --glob '*.{cpp,h,hpp}' 'RuntimeLinker::Relocate' src printf '%s\n' '--- surrounding runtime linker definitions ---' sed -n '1,260p' src/loader/runtimeLinker.cpp sed -n '260,620p' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 33935 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- symbol references ---' rg -n -F --glob '*.{cpp,h,hpp}' 'LoadProgram(' src/loader src | head -200 rg -n -F --glob '*.{cpp,h,hpp}' 'FindProgramByFileName' src/loader src | head -100 rg -n -F --glob '*.{cpp,h,hpp}' 'import_modules' src/loader src | head -200 rg -n -i --glob '*.{cpp,h,hpp}' 'stub|resolve.*import|import.*resolve|RelocateAll|Relocate' src/loader | head -240 printf '%s\n' '--- declarations and definitions ---' rg -n -F --glob '*.{cpp,h,hpp}' 'Program* RuntimeLinker::LoadProgram' src rg -n -F --glob '*.{cpp,h,hpp}' 'void RuntimeLinker::RelocateAll' src rg -n -F --glob '*.{cpp,h,hpp}' 'RuntimeLinker::Relocate' src printf '%s\n' '--- runtime linker source ranges ---' sed -n '1,620p' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 33901 --- 🏁 Script executed: ```bash rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'LoadProgram(' src/loader src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'FindProgramByFileName' src/loader src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'import_modules' src/loader src rg -n -i --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'stub|resolve.*import|import.*resolve|RelocateAll|Relocate' src/loader rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RuntimeLinker::LoadProgram' src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RuntimeLinker::RelocateAll' src sed -n '1,620p' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 33652 --- 🌐 Web query: `KytyPS5 runtimeLinker.cpp LoadImportedBundledModules LoadProgram` 💡 Result: ``` In the current `main` branch, `src/loader/runtimeLinker.cpp` exists, but I couldn’t find either `LoadImportedBundledModules` or `LoadProgram` in it. That only establishes they aren’t in the version I checked; they may exist in another branch or an older commit. ([github.com](https://github.com/KytyPS5/KytyPS5/blob/main/src/loader/runtimeLinker.cpp?utm_source=openai)) [Open the file on GitHub](https://github.com/KytyPS5/KytyPS5/blob/main/src/loader/runtimeLinker.cpp). If you share a commit hash or tell me whether you want an explanation or help locating an older version, I can narrow it down. Citations: - 1: https://github.com/KytyPS5/KytyPS5/blob/main/src/loader/runtimeLinker.cpp?utm_source=openai ``` --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- LoadProgram and adjacent loader paths ---' sed -n '1168,1215p' src/loader/runtimeLinker.cpp sed -n '1496,1518p' src/loader/runtimeLinker.cpp sed -n '1660,1715p' src/loader/runtimeLinker.cpp printf '%s\n' '--- relocation and unresolved-import path ---' sed -n '850,925p' src/loader/runtimeLinker.cpp sed -n '1088,1120p' src/loader/runtimeLinker.cpp sed -n '1990,2075p' src/loader/runtimeLinker.cpp printf '%s\n' '--- relevant declarations ---' sed -n '80,195p' src/loader/runtimeLinker.h ``` Repository: KytyPS5/KytyPS5 Length of output: 15708 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- relocation symbol resolution ---' sed -n '730,875p' src/loader/runtimeLinker.cpp printf '%s\n' '--- Resolve implementation and callers ---' rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RuntimeLinker::Resolve' src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' '->Resolve(' src/loader src/libs src sed -n '1840,2015p' src/loader/runtimeLinker.cpp printf '%s\n' '--- symbol database lookup declarations and definitions ---' rg -n -i --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'class SymbolDatabase|FindSymbol|ResolveSymbol|AddSymbol' src/loader ``` Repository: KytyPS5/KytyPS5 Length of output: 13888 --- 🏁 Script executed: ```bash set -o pipefail sed -n '1338,1435p' src/loader/runtimeLinker.cpp sed -n '1,180p' src/loader/symbolDatabase.h rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'm_symbols->' src/loader/runtimeLinker.cpp rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'export_symbols->' src/loader/runtimeLinker.cpp rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'import_symbols->' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 4905 --- 🏁 Script executed: ```bash sed -n '1348,1435p' src/loader/runtimeLinker.cpp sed -n '1,180p' src/loader/symbolDatabase.h rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'm_symbols->' src/loader/runtimeLinker.cpp rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'export_symbols->' src/loader/runtimeLinker.cpp rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'import_symbols->' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 4580 --- 🏁 Script executed: ```bash sed -n '1420,1490p' src/loader/runtimeLinker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 2008 --- </details> **Load the bundled PRX dependency closure before relocation.** When a bundled PRX imports another bundled PRX that is not listed by the executable, `LoadImportedBundledModules` does not load the transitive dependency. `LoadProgram` loads only the requested ELF and does not recurse. If the dependency's symbol is not provided by HLE or another loaded export, relocation sets its address to zero and patches function imports to `UnresolvedImportStub`, which returns zero. This can break the importing PRX or its initializer. <details> <summary>Suggested fix</summary> ```diff --- "a/src/loader/runtimeLinker.cpp" +++ "b/src/loader/runtimeLinker.cpp" @@ -1227,12 +1227,24 @@ return modules; } // A bundled PRX is named after the module it exports, e.g. libSceNpCppWebApi.prx. - for (const auto& imported: (*main)->dynamic_info->import_modules) { - const auto path = folder / (imported.name + ".prx"); - if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) { - modules.push_back(LoadProgram(path)); - } - } + std::vector<Program*> pending {*main}; + for (size_t i = 0; i < pending.size(); ++i) { + for (const auto& imported: pending[i]->dynamic_info->import_modules) { + const auto path = folder / (imported.name + ".prx"); + if (!Common::File::IsFileExisting(path)) { + continue; + } + + auto* module = FindProgramByFileName(path); + if (module == nullptr) { + module = LoadProgram(path); + modules.push_back(module); + } + if (std::find(pending.begin(), pending.end(), module) == pending.end()) { + pending.push_back(module); + } + } + } return modules; } ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion std::vector<Program*> pending {*main}; for (size_t i = 0; i < pending.size(); ++i) { for (const auto& imported: pending[i]->dynamic_info->import_modules) { const auto path = folder / (imported.name + ".prx"); if (!Common::File::IsFileExisting(path)) { continue; } auto* module = FindProgramByFileName(path); if (module == nullptr) { module = LoadProgram(path); modules.push_back(module); } if (std::find(pending.begin(), pending.end(), module) == pending.end()) { pending.push_back(module); } } } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:3feb46b9dc134abc46a34811 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠LukaszRozmej <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-10 11:32 UTC · original · reviewed

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/loader/runtimeLinker.cpp (1)

1304-1308: 🩺 Stability & Availability | 🔵 Trivial

Handle bundled module initializer failures explicitly.

RuntimeLinker::Execute discards the int returned by each bundled module's StartModule call. If an initializer returns an error, boot can continue to the main entry without reporting it. KernelLoadStartModule logs this result and applies a failure policy for negative results. Apply an explicit policy here as well, and log the module path and result.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94280364-be65-475e-8b7f-f0025537398c
📥 Commits

Reviewing files that changed from the base of the PR and between 307fdcf7ad and 0c16598752.

📒 Files selected for processing (2)
  • src/loader/runtimeLinker.cpp
  • src/loader/runtimeLinker.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-10 11:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366#pullrequestreview-5478791437) · **reviewed** **Actionable comments posted: 2** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>src/loader/runtimeLinker.cpp (1)</summary><blockquote> `1304-1308`: **🩺 Stability & Availability** | **🔵 Trivial** **Handle bundled module initializer failures explicitly.** `RuntimeLinker::Execute` discards the `int` returned by each bundled module's `StartModule` call. If an initializer returns an error, boot can continue to the main entry without reporting it. `KernelLoadStartModule` logs this result and applies a failure policy for negative results. Apply an explicit policy here as well, and log the module path and result. <!-- cr-comment:v1:02d2485077fd651096c63aba --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `94280364-be65-475e-8b7f-f0025537398c` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 307fdcf7ad5d9d15b5966288fcc598ac9dbca188 and 0c165987522a96a9831586cf5478e0d3aacc278d. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/loader/runtimeLinker.cpp` * `src/loader/runtimeLinker.h` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=f890ce0a-19fb-4b0a-8463-01810d2ae4fb attempt=56b78db5-73df-465f-890f-36ac50448d91 batch=1/1 -->
@ -1220,0 +1237,4 @@
if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {
modules.push_back(LoadProgram(path));
}
}
Author
Owner

@⁠LukaszRozmej on GitHub · 2026-10-12 14:18 UTC · original

Fixed in 1357fc5: the import name plus .prx must be a plain file name (filename() == path), which rejects .., separators and root-qualified names on both platforms.

**@⁠LukaszRozmej** on GitHub · 2026-10-12 14:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366#discussion_r4249044113) Fixed in 1357fc5: the import name plus `.prx` must be a plain file name (`filename() == path`), which rejects `..`, separators and root-qualified names on both platforms.
@ -1220,0 +1237,4 @@
if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {
modules.push_back(LoadProgram(path));
}
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original

@LukaszRozmej, thanks for the fix. The supplied code checks filename() == file_name before joining the path to folder. This addresses the path traversal finding.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-12 14:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366#discussion_r4249048179) `@LukaszRozmej`, thanks for the fix. The supplied code checks `filename() == file_name` before joining the path to `folder`. This addresses the path traversal finding. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=%40coderabbitai%20caught%20two%20loader%20risks%3A%20dependency%20PRXs%20need%20recursive%20loading%20before%20relocation%2C%20and%20import%20names%20must%20stay%20plain%20filenames%20to%20block%20path%20traversal.%20Try%20CodeRabbit%20for%20sharp%20code%20reviews!%20%F0%9F%94%92%F0%9F%9B%A0%EF%B8%8F&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1366%23discussion_r4237473315)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠socket1001 on GitHub · 2026-11-19 16:05 UTC · original

Astro Bot (PPSA21564) data point for this PR — crash inside the bundled-PRX load path on two builds.

Environment: Linux (Ubuntu 26.04, kernel 7.0), AMD RX 9070 / RADV (Vulkan 1.3+), official release builds.

Dump: DUPLEX dump of the retail title (fresh usenet re-download, SFV-verified), PPSA21564-app0 with sce_module/ (10 modules incl. libSceNpCppWebApi.prx), data/, eboot.bin (251 MB).

What happens (identical on KytyPS5-2026-11-17-faec1f4 and the pre-regression KytyPS5-2026-09-28-8e61798 from #1070):

Initialized: Graphics
Title ID: PPSA21564
version = 13
Shaders: VS 0 | PS 0 | CS 1 | GS 0 | LS 0 | HS 0 | TES 0
thread: OdxAsyncLoader
Unhandled host exception: type=1 code=11 pc=0x00000009005ae8fa access=2 address=0x0000000000000000
 in src/loader/runtimeLinker.cpp:719

So the emulator gets through init, Vulkan pipeline cache, title detection and starts compiling shaders, then dies on a null dereference in the loader thread that services module loads — which looks like the same code path this PR is about (the game's eboot imports ~800 NpCppWebApi functions, and the load of the bundled modules appears to be what trips the fault).

Register context at fault: rdi=0x9101942b8 rsi=0x707f20000930 r13=0x0, faulting instruction is a call with rcx=deadbeef00000007 (poison value) — suggesting an uninitialized/garbage function pointer rather than a data NULL.

Two notes that may help triage:

  • The dump's sce_module/ also ships libScePfs.prx, libSceFontGsm.prx, libSceJobManager.prx, libSceNpCppWebApi.prx etc. — Astro's module import surface is larger than the single-libc case the current loader handles.
  • Our run never printed any Unresolved import stub called line before the fault, so the crash happens during/before binding, not after binding to stubs.

Happy to test a build that changes the module load order or guards runtimeLinker.cpp:719, and can provide the full emulator log or a repro command line (kyty_emulator --game <dir>) on request.

(Comment prepared with AI assistance; tested and verified on hardware by me.)

**@⁠socket1001** on GitHub · 2026-11-19 16:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1366#issuecomment-7014606670) **Astro Bot (PPSA21564) data point for this PR — crash inside the bundled-PRX load path on two builds.** Environment: Linux (Ubuntu 26.04, kernel 7.0), AMD RX 9070 / RADV (Vulkan 1.3+), official release builds. Dump: DUPLEX dump of the retail title (fresh usenet re-download, SFV-verified), `PPSA21564-app0` with `sce_module/` (10 modules incl. `libSceNpCppWebApi.prx`), `data/`, `eboot.bin` (251 MB). What happens (identical on **KytyPS5-2026-11-17-faec1f4** and the pre-regression **KytyPS5-2026-09-28-8e61798** from #1070): ``` Initialized: Graphics Title ID: PPSA21564 version = 13 Shaders: VS 0 | PS 0 | CS 1 | GS 0 | LS 0 | HS 0 | TES 0 thread: OdxAsyncLoader Unhandled host exception: type=1 code=11 pc=0x00000009005ae8fa access=2 address=0x0000000000000000 in src/loader/runtimeLinker.cpp:719 ``` So the emulator gets through init, Vulkan pipeline cache, title detection and starts compiling shaders, then dies on a null dereference in the loader thread that services module loads — which looks like the same code path this PR is about (the game's eboot imports ~800 `NpCppWebApi` functions, and the load of the bundled modules appears to be what trips the fault). Register context at fault: `rdi=0x9101942b8 rsi=0x707f20000930 r13=0x0`, faulting instruction is a call with `rcx=deadbeef00000007` (poison value) — suggesting an uninitialized/garbage function pointer rather than a data NULL. Two notes that may help triage: - The dump's `sce_module/` also ships `libScePfs.prx`, `libSceFontGsm.prx`, `libSceJobManager.prx`, `libSceNpCppWebApi.prx` etc. — Astro's module import surface is larger than the single-`libc` case the current loader handles. - Our run never printed any `Unresolved import stub called` line before the fault, so the crash happens during/before binding, not after binding to stubs. Happy to test a build that changes the module load order or guards `runtimeLinker.cpp:719`, and can provide the full emulator log or a repro command line (`kyty_emulator --game <dir>`) on request. *(Comment prepared with AI assistance; tested and verified on hardware by me.)*
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1366/head:github-bot/gh-1366'
git switch 'github-bot/gh-1366'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1366'
git switch 'github-bot/gh-1366'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1366'
git switch 'github-bot/gh-1366'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1366'
git switch 'main'
git merge --squash 'github-bot/gh-1366'
git switch 'main'
git merge --ff-only 'github-bot/gh-1366'
git switch 'main'
git merge 'github-bot/gh-1366'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.