From cdc0441405eda0cf91ae959b39f3722c94995d4e Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 7 Aug 2023 21:33:36 +0300 Subject: [PATCH 1/3] PPU: Fixup interpreter and analyzer --- rpcs3/Emu/Cell/PPUAnalyser.cpp | 2 +- rpcs3/Emu/Cell/PPUThread.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index f680b6907eb9..2a774d0fd35d 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -1463,7 +1463,7 @@ bool ppu_module::analyse(u32 lib_toc, u32 entry, const u32 sec_end, const std::b { const u32 target = (op.aa ? 0 : iaddr) + (type == ppu_itype::B ? +op.bt24 : +op.bt14); - if (target >= start && target < end && (op.aa && verify_func(iaddr))) + if (target >= start && target < end && (!op.aa || verify_func(iaddr))) { if (target < func.addr || target >= func.addr + func.size) { diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 9936fc40763a..27067bb33bab 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -3769,9 +3769,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only) { for (auto& block : func.blocks) { - const auto targets = g_fxo->get().get_targets(block.first, block.second); - - if (!targets.empty()) + if (g_fxo->is_init() && !g_fxo->get().get_targets(block.first, block.second).empty()) { // Replace the block with ppu_far_jump continue; From df24305698acee9a40332317d70546cfa658de55 Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 8 Aug 2023 09:48:12 +0300 Subject: [PATCH 2/3] PPU/Debugger: Fix op_branch_targets --- rpcs3/Emu/Cell/PPUThread.cpp | 4 +--- rpcs3/util/fixed_typemap.hpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 27067bb33bab..eb9f967fcee3 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1206,9 +1206,7 @@ std::array op_branch_targets(u32 pc, ppu_opcode_t op) { std::array res{pc + 4, umax}; - g_fxo->need(); - - if (u32 target = g_fxo->get().get_target(pc)) + if (u32 target = g_fxo->is_init() ? g_fxo->get().get_target(pc) : 0) { res[0] = target; return res; diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 896d8ae779c3..3c2ee8e7f268 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -347,7 +347,7 @@ namespace stx } // Check if object is not initialized but shall be initialized first (to use in initializing other objects) - template + template requires (std::is_constructible_v || std::is_default_constructible_v) void need() noexcept { if (!m_init[stx::typeindex>()]) From bd7715b18068332dbafac7064312a410457d7314 Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 8 Aug 2023 10:01:51 +0300 Subject: [PATCH 3/3] ELF.h: fix warning --- rpcs3/Loader/ELF.h | 1 - 1 file changed, 1 deletion(-) diff --git a/rpcs3/Loader/ELF.h b/rpcs3/Loader/ELF.h index 831e58dea1f4..abb9979c1973 100644 --- a/rpcs3/Loader/ELF.h +++ b/rpcs3/Loader/ELF.h @@ -456,7 +456,6 @@ class elf_object // Rely on previous sh_offset value! if (hdr.p_offset <= shdr.sh_offset && shdr.sh_offset + shdr.sh_size - 1 <= hdr.p_offset + hdr.p_filesz - 1) { - const auto& prog = ::at32(progs, p_index); out.sh_offset = data_base + shdr.sh_offset - hdr.p_offset; result = true; break;