PPCAnalyst: Support return from interrupt

This commit is contained in:
Sepalani 2017-04-10 17:25:33 +01:00
parent a2cba6d72f
commit 7cee62bbb3
1 changed files with 9 additions and 9 deletions

View File

@ -67,12 +67,11 @@ static u32 EvaluateBranchTarget(UGeckoInstruction instr, u32 pc)
} }
// To find the size of each found function, scan // To find the size of each found function, scan
// forward until we hit blr. In the meantime, collect information // forward until we hit blr or rfi. In the meantime, collect information
// about which functions this function calls. // about which functions this function calls.
// Also collect which internal branch goes the farthest // Also collect which internal branch goes the farthest.
// If any one goes farther than the blr, assume that there is more than // If any one goes farther than the blr or rfi, assume that there is more than
// one blr, and keep scanning. // one blr or rfi, and keep scanning.
bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size) bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
{ {
if (!func.name.size()) if (!func.name.size())
@ -106,9 +105,10 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
} }
if (PPCTables::IsValidInstruction(instr)) if (PPCTables::IsValidInstruction(instr))
{ {
if (instr.hex == 0x4e800020) // 4e800021 is blrl, not the end of a function // BLR or RFI
// 4e800021 is blrl, not the end of a function
if (instr.hex == 0x4e800020 || instr.hex == 0x4C000064)
{ {
// BLR
if (farthestInternalBranchTarget > addr) if (farthestInternalBranchTarget > addr)
{ {
// bah, not this one, continue.. // bah, not this one, continue..
@ -298,7 +298,7 @@ static void FindFunctionsFromBranches(u32 startAddr, u32 endAddr, SymbolDB* func
} }
} }
static void FindFunctionsAfterBLR(PPCSymbolDB* func_db) static void FindFunctionsAfterReturnInstruction(PPCSymbolDB* func_db)
{ {
std::vector<u32> funcAddrs; std::vector<u32> funcAddrs;
@ -332,7 +332,7 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
{ {
// Step 1: Find all functions // Step 1: Find all functions
FindFunctionsFromBranches(startAddr, endAddr, func_db); FindFunctionsFromBranches(startAddr, endAddr, func_db);
FindFunctionsAfterBLR(func_db); FindFunctionsAfterReturnInstruction(func_db);
// Step 2: // Step 2:
func_db->FillInCallers(); func_db->FillInCallers();