kernel: retain modules until their final explicit unload

This commit is contained in:
nmzik
2026-09-25 21:09:15 +04:00
parent e056d55dd5
commit 0fb3ac5605
2 changed files with 8 additions and 0 deletions
+7
View File
@@ -1226,6 +1226,7 @@ static KYTY_SYSV_ABI KernelModule KernelLoadStartModule(const char* module_file_
auto* program = rt->FindProgramByFileName(module_path);
if (program != nullptr) {
++program->load_count;
if (res != nullptr) {
*res = OK;
}
@@ -1240,6 +1241,7 @@ static KYTY_SYSV_ABI KernelModule KernelLoadStartModule(const char* module_file_
rt->RelocateProgram(program);
program->load_count = 1;
int result = rt->StartModule(program, args, argp, nullptr);
LOGF("\tmodule_start() result = %d\n", result);
@@ -1269,6 +1271,11 @@ static int KYTY_SYSV_ABI KernelStopUnloadModule(KernelModule handle, size_t args
if (program == nullptr) {
LOGF("\tinvalid module handle = %" PRId32 "\n", handle);
return KERNEL_ERROR_ESRCH;
}
if (program->load_count > 1) {
--program->load_count;
return OK;
}
+1
View File
@@ -115,6 +115,7 @@ struct Program {
int32_t unique_id = -1;
RuntimeLinker* rt = nullptr;
uint32_t load_count = 0; // Successful sceKernelLoadStartModule calls.
std::filesystem::path file_name;
std::unique_ptr<Elf64> elf;
std::unique_ptr<DynamicInfo> dynamic_info;