diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index 7661743872..1443b29a22 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -137,9 +137,10 @@ struct ppu_module : public Type std::vector applied_patches; // Patch addresses std::deque> allocations; // Segment memory allocations std::map addr_to_seg_index; // address->segment ordered translator map - ppu_module* parent = nullptr; + ppu_module* parent = nullptr; // For compilation: refers to original structure (is whole, not partitioned) std::pair local_bounds{0, u32{umax}}; // Module addresses range std::shared_ptr> jit_bounds; // JIT instance modules addresses range + bool is_relocatable = false; // Is code relocatable(?) template auto as_span(T&& arg, bool bound_local, bool bound_jit) const diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 6a7ce4312b..3ecb55e32e 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -1951,6 +1951,7 @@ shared_ptr ppu_load_prx(const ppu_prx_object& elf, bool virtual_load, c } prx->applied_patches = applied; + prx->is_relocatable = true; prx->analyse(toc, 0, end, applied, exported_funcs); if (!ar && !virtual_load) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 17d5abe790..4502ca3616 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -4713,7 +4713,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_s usz module_counter = 0; // Difference between function name and current location - const u32 reloc = info.relocs.empty() ? 0 : ::at32(info.segs, 0).addr; + const u32 reloc = info.is_relocatable ? ::at32(info.segs, 0).addr : 0; // Info sent to threads std::vector>> workload; @@ -5622,7 +5622,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module }, false); // Difference between function name and current location - const u32 reloc = module_part.get_relocs().empty() ? 0 : ::at32(module_part.segs, 0).addr; + const u32 reloc = module_part.is_relocatable ? ::at32(module_part.segs, 0).addr : 0; // Initialize function list for (const auto& func : module_part.get_funcs()) diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 3abf91c8c1..66cac9f5ba 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -162,7 +162,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* _module, const ppu_mo } } - if (!m_info.get_relocs().empty()) + if (m_info.is_relocatable) { m_reloc = &m_info.segs[0]; }