mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
PPU: clean linkage info
This commit is contained in:
parent
bb563b3eb7
commit
7702eb2fa7
@ -119,6 +119,7 @@ struct ppu_linkage_info
|
||||
std::unordered_map<u32, info, value_hash<u32>> functions;
|
||||
std::unordered_map<u32, info, value_hash<u32>> variables;
|
||||
|
||||
// Obsolete
|
||||
bool imported = false;
|
||||
};
|
||||
|
||||
@ -578,8 +579,10 @@ static auto ppu_load_exports(const std::shared_ptr<ppu_linkage_info>& link, u32
|
||||
return result;
|
||||
}
|
||||
|
||||
static void ppu_load_imports(std::vector<ppu_reloc>& relocs, const std::shared_ptr<ppu_linkage_info>& link, u32 imports_start, u32 imports_end)
|
||||
static auto ppu_load_imports(std::vector<ppu_reloc>& relocs, const std::shared_ptr<ppu_linkage_info>& link, u32 imports_start, u32 imports_end)
|
||||
{
|
||||
std::unordered_map<u32, void*> result;
|
||||
|
||||
for (u32 addr = imports_start; addr < imports_end;)
|
||||
{
|
||||
const auto& lib = vm::_ref<const ppu_prx_module_info>(addr);
|
||||
@ -613,6 +616,7 @@ static void ppu_load_imports(std::vector<ppu_reloc>& relocs, const std::shared_p
|
||||
auto& flink = link->modules[module_name].functions[fnid];
|
||||
|
||||
// Add new import
|
||||
result.emplace(faddr, &flink);
|
||||
flink.imports.emplace(faddr);
|
||||
mlink.imported = true;
|
||||
|
||||
@ -625,6 +629,7 @@ static void ppu_load_imports(std::vector<ppu_reloc>& relocs, const std::shared_p
|
||||
// Patch refs if necessary (0x2000 seems to be correct flag indicating the presence of additional info)
|
||||
if (const u32 frefs = (lib.attributes & 0x2000) ? +fnids[i + lib.num_func] : 0)
|
||||
{
|
||||
result.emplace(frefs, &flink);
|
||||
flink.frefss.emplace(frefs);
|
||||
ppu_patch_refs(&relocs, frefs, link_addr);
|
||||
}
|
||||
@ -645,6 +650,7 @@ static void ppu_load_imports(std::vector<ppu_reloc>& relocs, const std::shared_p
|
||||
auto& vlink = link->modules[module_name].variables[vnid];
|
||||
|
||||
// Add new import
|
||||
result.emplace(vref, &vlink);
|
||||
vlink.imports.emplace(vref);
|
||||
mlink.imported = true;
|
||||
|
||||
@ -656,6 +662,8 @@ static void ppu_load_imports(std::vector<ppu_reloc>& relocs, const std::shared_p
|
||||
|
||||
addr += lib.size ? lib.size : sizeof(ppu_prx_module_info);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::string& path)
|
||||
@ -870,8 +878,7 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
|
||||
LOG_WARNING(LOADER, "Library %s (rtoc=0x%x):", lib_name, lib_info->toc);
|
||||
|
||||
prx->specials = ppu_load_exports(link, lib_info->exports_start, lib_info->exports_end);
|
||||
|
||||
ppu_load_imports(prx->relocs, link, lib_info->imports_start, lib_info->imports_end);
|
||||
prx->imports = ppu_load_imports(prx->relocs, link, lib_info->imports_start, lib_info->imports_end);
|
||||
|
||||
prx->analyse(lib_info->toc, 0);
|
||||
}
|
||||
@ -892,6 +899,14 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
|
||||
|
||||
void ppu_unload_prx(const lv2_prx& prx)
|
||||
{
|
||||
// Clean linkage info
|
||||
for (auto& imp : prx.imports)
|
||||
{
|
||||
auto pinfo = static_cast<ppu_linkage_info::module::info*>(imp.second);
|
||||
pinfo->frefss.erase(imp.first);
|
||||
pinfo->imports.erase(imp.first);
|
||||
}
|
||||
|
||||
for (auto& seg : prx.segs)
|
||||
{
|
||||
vm::dealloc(seg.addr, vm::main);
|
||||
|
@ -115,6 +115,7 @@ struct lv2_prx final : lv2_obj, ppu_module
|
||||
bool is_started = false;
|
||||
|
||||
std::unordered_map<u32, u32> specials;
|
||||
std::unordered_map<u32, void*> imports;
|
||||
|
||||
vm::ps3::ptr<s32(u32 argc, vm::ps3::ptr<void> argv)> start = vm::null;
|
||||
vm::ps3::ptr<s32(u32 argc, vm::ps3::ptr<void> argv)> stop = vm::null;
|
||||
|
Loading…
Reference in New Issue
Block a user