ppu_analyse: use entry point

This commit is contained in:
Nekotekina 2017-04-08 15:09:01 +03:00
parent adefd1fd63
commit d7c66fc949
3 changed files with 10 additions and 4 deletions

View File

@ -326,7 +326,7 @@ namespace ppu_patterns
};
}
std::vector<ppu_function> ppu_analyse(const std::vector<std::pair<u32, u32>>& segs, const std::vector<std::pair<u32, u32>>& secs, u32 lib_toc)
std::vector<ppu_function> ppu_analyse(const std::vector<std::pair<u32, u32>>& segs, const std::vector<std::pair<u32, u32>>& secs, u32 lib_toc, u32 entry)
{
// Assume first segment is executable
const u32 start = segs[0].first;
@ -467,6 +467,12 @@ std::vector<ppu_function> ppu_analyse(const std::vector<std::pair<u32, u32>>& 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)
{

View File

@ -111,7 +111,7 @@ struct ppu_pattern_matrix
extern void ppu_validate(const std::string& fname, const std::vector<ppu_function>& funcs, u32 reloc);
extern std::vector<ppu_function> ppu_analyse(const std::vector<std::pair<u32, u32>>& segs, const std::vector<std::pair<u32, u32>>& secs, u32 lib_toc);
extern std::vector<ppu_function> ppu_analyse(const std::vector<std::pair<u32, u32>>& segs, const std::vector<std::pair<u32, u32>>& secs, u32 lib_toc, u32 entry);
// PPU Instruction Type
struct ppu_itype

View File

@ -802,7 +802,7 @@ std::shared_ptr<lv2_prx> 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<ppu_function> main_funcs = ppu_analyse(segments, sections, vm::read32(elf.header.e_entry + 4));
std::vector<ppu_function> main_funcs = ppu_analyse(segments, sections, 0, elf.header.e_entry);
ppu_validate(vfs::get(Emu.GetPath()), main_funcs, 0);