PPCSymbolDB: Fix LoadMap corrupting virtual addresses

This commit is contained in:
Sepalani 2017-05-24 21:08:15 +01:00
parent 643b218c1d
commit 82695ccd99
1 changed files with 8 additions and 8 deletions

View File

@ -362,24 +362,24 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
// Check if this is a valid entry. // Check if this is a valid entry.
if (strcmp(name, ".text") != 0 && strcmp(name, ".init") != 0 && strlen(name) > 0) if (strcmp(name, ".text") != 0 && strcmp(name, ".init") != 0 && strlen(name) > 0)
{ {
vaddress |= 0x80000000; // Can't compute the checksum if not in RAM
bool good = !bad; bool good = !bad && PowerPC::HostIsInstructionRAMAddress(vaddress) &&
PowerPC::HostIsInstructionRAMAddress(vaddress + size - 4);
if (!good) if (!good)
{ {
// check for BLR before function // check for BLR before function
u32 opcode = PowerPC::HostRead_Instruction(vaddress - 4); PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(vaddress - 4);
if (opcode == 0x4e800020) if (read_result.valid && read_result.hex == 0x4e800020)
{ {
// check for BLR at end of function // check for BLR at end of function
opcode = PowerPC::HostRead_Instruction(vaddress + size - 4); read_result = PowerPC::TryReadInstruction(vaddress + size - 4);
if (opcode == 0x4e800020) good = read_result.valid && read_result.hex == 0x4e800020;
good = true;
} }
} }
if (good) if (good)
{ {
++good_count; ++good_count;
AddKnownSymbol(vaddress | 0x80000000, size, name); // ST_FUNCTION AddKnownSymbol(vaddress, size, name); // ST_FUNCTION
} }
else else
{ {