mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #5242 from sepalani/nop-pad
PPCAnalyst: Skip nop alignment
This commit is contained in:
commit
78f4ca6d79
@ -94,7 +94,6 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
|
||||
if (func.size >= CODEBUFFER_SIZE * 4) // weird
|
||||
return false;
|
||||
|
||||
const UGeckoInstruction instr = PowerPC::HostRead_Instruction(addr);
|
||||
if (max_size && func.size > max_size)
|
||||
{
|
||||
func.address = startAddr;
|
||||
@ -104,7 +103,9 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
|
||||
func.flags |= FFLAG_STRAIGHT;
|
||||
return true;
|
||||
}
|
||||
if (PPCTables::IsValidInstruction(instr))
|
||||
const PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(addr);
|
||||
const UGeckoInstruction instr = read_result.hex;
|
||||
if (read_result.valid && PPCTables::IsValidInstruction(instr))
|
||||
{
|
||||
if (instr.hex == 0x4e800020) // 4e800021 is blrl, not the end of a function
|
||||
{
|
||||
@ -271,9 +272,10 @@ static void FindFunctionsFromBranches(u32 startAddr, u32 endAddr, SymbolDB* func
|
||||
{
|
||||
for (u32 addr = startAddr; addr < endAddr; addr += 4)
|
||||
{
|
||||
const UGeckoInstruction instr = PowerPC::HostRead_Instruction(addr);
|
||||
const PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(addr);
|
||||
const UGeckoInstruction instr = read_result.hex;
|
||||
|
||||
if (PPCTables::IsValidInstruction(instr))
|
||||
if (read_result.valid && PPCTables::IsValidInstruction(instr))
|
||||
{
|
||||
switch (instr.OPCD)
|
||||
{
|
||||
@ -309,11 +311,17 @@ static void FindFunctionsAfterBLR(PPCSymbolDB* func_db)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// skip zeroes that sometimes pad function to 16 byte boundary (e.g. Donkey Kong Country
|
||||
// Returns)
|
||||
while (PowerPC::HostRead_Instruction(location) == 0 && ((location & 0xf) != 0))
|
||||
// Skip zeroes (e.g. Donkey Kong Country Returns) and nop (e.g. libogc)
|
||||
// that sometimes pad function to 16 byte boundary.
|
||||
PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(location);
|
||||
while (read_result.valid && (location & 0xf) != 0)
|
||||
{
|
||||
if (read_result.hex != 0 && read_result.hex != 0x60000000)
|
||||
break;
|
||||
location += 4;
|
||||
if (PPCTables::IsValidInstruction(PowerPC::HostRead_Instruction(location)))
|
||||
read_result = PowerPC::TryReadInstruction(location);
|
||||
}
|
||||
if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex))
|
||||
{
|
||||
// check if this function is already mapped
|
||||
Symbol* f = func_db->AddFunction(location);
|
||||
|
Loading…
Reference in New Issue
Block a user