diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 562e03a8b9..004f04865c 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -326,7 +326,7 @@ namespace ppu_patterns }; } -std::vector ppu_analyse(const std::vector>& segs, const std::vector>& secs, u32 lib_toc) +std::vector ppu_analyse(const std::vector>& segs, const std::vector>& secs, u32 lib_toc, u32 entry) { // Assume first segment is executable const u32 start = segs[0].first; @@ -467,6 +467,12 @@ std::vector ppu_analyse(const std::vector>& se } } + // Register TOC from entry point + if (entry && !lib_toc) + { + lib_toc = vm::read32(entry) ? vm::read32(entry + 4) : vm::read32(entry + 20); + } + // Secondary attempt if (TOCs.empty() && lib_toc) { diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index a4e6bc2b14..8744e4f20b 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -111,7 +111,7 @@ struct ppu_pattern_matrix extern void ppu_validate(const std::string& fname, const std::vector& funcs, u32 reloc); -extern std::vector ppu_analyse(const std::vector>& segs, const std::vector>& secs, u32 lib_toc); +extern std::vector ppu_analyse(const std::vector>& segs, const std::vector>& secs, u32 lib_toc, u32 entry); // PPU Instruction Type struct ppu_itype diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 7dd65a4e0e..7ee42966a3 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -802,7 +802,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, const std::stri ppu_load_imports(link, lib_info->imports_start, lib_info->imports_end); - prx->funcs = ppu_analyse(segments, sections, lib_info->toc); + prx->funcs = ppu_analyse(segments, sections, lib_info->toc, 0); } else { @@ -1269,7 +1269,7 @@ void ppu_load_exec(const ppu_exec_object& elf) { // Analyse executable - std::vector main_funcs = ppu_analyse(segments, sections, vm::read32(elf.header.e_entry + 4)); + std::vector main_funcs = ppu_analyse(segments, sections, 0, elf.header.e_entry); ppu_validate(vfs::get(Emu.GetPath()), main_funcs, 0);