From 400a496792575a4c97b5dd50d18d48e91863c3a4 Mon Sep 17 00:00:00 2001 From: boykopovar Date: Sat, 10 Oct 2026 14:02:00 +0300 Subject: [PATCH] refactor(relinker): unify guest module diagnostics --- core/relinker/main.cpp | 2 +- core/relinker/relinker/include/relinker/guest/GuestImage.hpp | 1 + core/relinker/relinker/src/guest/GuestModuleBuilder.cpp | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/relinker/main.cpp b/core/relinker/main.cpp index 3a3cec579..bed24bfdb 100644 --- a/core/relinker/main.cpp +++ b/core/relinker/main.cpp @@ -88,7 +88,7 @@ int main(const int argc, char* argv[]) { ); std::cout << "System: " << (args.toWindows ? "Windows" : args.toMacos ? "macOS" : "Linux") << "; unused-filter=" << args.unusedFilterLevel << "\n"; - std::cout << "sce_module/sce_modules/prx processing: " << (args.skipSceModule ? "disabled (--skip-sce-module)" : "enabled") << '\n'; + std::cout << Relinker::GuestModulePattern << " processing: " << (args.skipSceModule ? "disabled (--skip-sce-module)" : "enabled") << '\n'; for (const auto& name : args.excludedSceModules) std::cout << "Guest module excluded: " << name << '\n'; auto result = pipeline->Relink(sourceBytes); for (const auto& patch : result.Patches) { diff --git a/core/relinker/relinker/include/relinker/guest/GuestImage.hpp b/core/relinker/relinker/include/relinker/guest/GuestImage.hpp index 6a861e1bd..6eb1f1b8b 100644 --- a/core/relinker/relinker/include/relinker/guest/GuestImage.hpp +++ b/core/relinker/relinker/include/relinker/guest/GuestImage.hpp @@ -12,6 +12,7 @@ namespace Relinker { inline constexpr char GuestSymbolSuffix[] = "#guest"; inline constexpr char GuestModuleSuffix[] = ".guest.prx"; +inline constexpr char GuestModulePattern[] = "sce_module/*.prx"; inline constexpr std::uint16_t AbsoluteSection = 0xfff1; struct GuestSymbol { diff --git a/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp b/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp index 9079396f9..fc88bc17b 100644 --- a/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp +++ b/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp @@ -51,6 +51,7 @@ std::string ModuleStem(std::string name, const bool windows) { std::vector GuestModuleBuilder::Build(const std::filesystem::path& inputPath, const std::filesystem::path& outputPath, Domain::SysVDynamicSection& dynamic, const bool windows, const bool macos, const bool toIntel, ISyscallScanner& syscallScanner, const bool lazyBinding, const std::string& runPath, const std::set& excludedModules) const { const auto root = std::filesystem::absolute(inputPath).parent_path(); + const auto missingModuleMessage = std::string(GuestModulePattern) + " was not found beside the input executable: " + inputPath.string() + ". Use --skip-sce-module to disable guest module processing."; const auto singular = root / "sce_module"; const auto plural = root / "sce_modules"; const auto prx = root / "prx"; @@ -58,7 +59,7 @@ std::vector GuestModuleBuilder::Build(const std::filesystem::path const bool hasPlural = std::filesystem::exists(plural); const bool hasPrx = std::filesystem::exists(prx); if (hasSingular && hasPlural) throw Domain::RelinkerException("Both sce_module and sce_modules exist beside the input executable"); - if (!hasSingular && !hasPlural && !hasPrx) throw Domain::RelinkerException("sce_module/sce_modules/prx was not found beside the input executable: " + root.string() + ". Use --skip-sce-module only if this game can run without these modules."); + if (!hasSingular && !hasPlural && !hasPrx) throw Domain::RelinkerException(missingModuleMessage); std::vector directories; if (hasSingular || hasPlural) directories.push_back(hasSingular ? singular : plural); if (hasPrx) directories.push_back(prx); @@ -119,7 +120,7 @@ std::vector GuestModuleBuilder::Build(const std::filesystem::path (windows && foldFilename(path.filename().string()) == foldFilename(name)) || matchesIdentity(name, image.ModuleNames); })) unresolved.insert(name); } - if (!unresolved.empty()) throw Domain::RelinkerException("sce_module folder not found for required dependency: " + *unresolved.begin() + ". Expected the module directly in sce_module/sce_modules/prx beside " + inputPath.string() + ". Use --skip-sce-module to disable guest module processing."); + if (!unresolved.empty()) throw Domain::RelinkerException(missingModuleMessage + " Missing dependency: " + *unresolved.begin()); if (!unmatchedExclusions.empty()) throw Domain::RelinkerException("Excluded guest module file not found: " + *unmatchedExclusions.begin()); std::sort(paths.begin(), paths.end()); paths.erase(std::unique(paths.begin(), paths.end()), paths.end());