diff --git a/src/core/libraries/sysmodule/sysmodule_internal.cpp b/src/core/libraries/sysmodule/sysmodule_internal.cpp index bebf64c65..b2853e2fa 100644 --- a/src/core/libraries/sysmodule/sysmodule_internal.cpp +++ b/src/core/libraries/sysmodule/sysmodule_internal.cpp @@ -253,6 +253,10 @@ s32 loadModuleInternal(s32 index, s32 argc, const void* argv, s32* res_out) { if (init_func) { LOG_INFO(Loader, "Can't Load {} switching to HLE", mod_name); init_func(&linker->GetHLESymbols()); + + // When loading HLEs, we need to relocate imports + // This ensures later module loads can see our HLE functions. + linker->RelocateAllImports(); } else { LOG_INFO(Loader, "No HLE available for {} module", mod_name); } diff --git a/src/core/linker.h b/src/core/linker.h index 0f6b19d83..895901f08 100644 --- a/src/core/linker.h +++ b/src/core/linker.h @@ -124,6 +124,13 @@ public: } } + void RelocateAllImports() { + std::scoped_lock lk{mutex}; + for (auto& module : m_modules) { + Relocate(module.get()); + } + } + void SetHeapAPI(void* func[]) { heap_api = reinterpret_cast(func); }