PPU LLVM: Fix compilation of PRX with no relocations

This commit is contained in:
Elad 2025-01-31 14:09:22 +02:00
parent a1a0333e56
commit 86b7078464
4 changed files with 6 additions and 4 deletions

View file

@ -137,9 +137,10 @@ struct ppu_module : public Type
std::vector<u32> applied_patches; // Patch addresses
std::deque<std::shared_ptr<void>> allocations; // Segment memory allocations
std::map<u32, u32> 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<u32, u32> local_bounds{0, u32{umax}}; // Module addresses range
std::shared_ptr<std::pair<u32, u32>> jit_bounds; // JIT instance modules addresses range
bool is_relocatable = false; // Is code relocatable(?)
template <typename T>
auto as_span(T&& arg, bool bound_local, bool bound_jit) const

View file

@ -1951,6 +1951,7 @@ shared_ptr<lv2_prx> 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)

View file

@ -4713,7 +4713,7 @@ bool ppu_initialize(const ppu_module<lv2_obj>& 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<std::pair<std::string, ppu_module<lv2_obj>>> workload;
@ -5622,7 +5622,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module<lv2_obj>& 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())

View file

@ -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];
}