Merge pull request #5475 from sepalani/map-vaddr

PPCSymbolDB: Fix LoadMap corrupting virtual addresses
This commit is contained in:
Leo Lam 2017-05-26 10:21:38 +02:00 committed by GitHub
commit 933767f1bd
1 changed files with 8 additions and 8 deletions

View File

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