refactor(relinker): unify guest module diagnostics
This commit is contained in:
parent
41126bfa5b
commit
400a496792
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ std::string ModuleStem(std::string name, const bool windows) {
|
|||
|
||||
std::vector<GuestArtifact> 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<std::string>& 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<GuestArtifact> 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<std::filesystem::path> directories;
|
||||
if (hasSingular || hasPlural) directories.push_back(hasSingular ? singular : plural);
|
||||
if (hasPrx) directories.push_back(prx);
|
||||
|
|
@ -119,7 +120,7 @@ std::vector<GuestArtifact> 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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue