PPCSymbolDB. Bugfix. Fix .data symbols not loading, unless they were aligned to 4 bytes.

.data symbols point to memory values and can be any byte or length of bytes (such as a string).
This commit is contained in:
TryTwo 2023-12-02 23:59:49 -07:00
parent 163acb5d2c
commit 92532c8d3a

View File

@ -408,27 +408,39 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string&
// Check if this is a valid entry. // Check if this is a valid entry.
if (strlen(name) > 0) if (strlen(name) > 0)
{ {
// Can't compute the checksum if not in RAM bool good;
bool good = !bad && PowerPC::MMU::HostIsInstructionRAMAddress(guard, vaddress) && const Common::Symbol::Type type = section_name == ".text" || section_name == ".init" ?
PowerPC::MMU::HostIsInstructionRAMAddress(guard, vaddress + size - 4); Common::Symbol::Type::Function :
if (!good) Common::Symbol::Type::Data;
if (type == Common::Symbol::Type::Function)
{ {
// check for BLR before function // Can't compute the checksum if not in RAM
PowerPC::TryReadInstResult read_result = good = !bad && PowerPC::MMU::HostIsInstructionRAMAddress(guard, vaddress) &&
guard.GetSystem().GetMMU().TryReadInstruction(vaddress - 4); PowerPC::MMU::HostIsInstructionRAMAddress(guard, vaddress + size - 4);
if (read_result.valid && read_result.hex == 0x4e800020) if (!good)
{ {
// check for BLR at end of function // check for BLR before function
read_result = guard.GetSystem().GetMMU().TryReadInstruction(vaddress + size - 4); PowerPC::TryReadInstResult read_result =
good = read_result.valid && read_result.hex == 0x4e800020; guard.GetSystem().GetMMU().TryReadInstruction(vaddress - 4);
if (read_result.valid && read_result.hex == 0x4e800020)
{
// check for BLR at end of function
read_result = guard.GetSystem().GetMMU().TryReadInstruction(vaddress + size - 4);
good = read_result.valid && read_result.hex == 0x4e800020;
}
} }
} }
else
{
// Data type, can have any length.
good = !bad && PowerPC::MMU::HostIsRAMAddress(guard, vaddress) &&
PowerPC::MMU::HostIsRAMAddress(guard, vaddress + size - 1);
}
if (good) if (good)
{ {
++good_count; ++good_count;
const Common::Symbol::Type type = section_name == ".text" || section_name == ".init" ?
Common::Symbol::Type::Function :
Common::Symbol::Type::Data;
AddKnownSymbol(guard, vaddress, size, name, type); AddKnownSymbol(guard, vaddress, size, name, type);
} }
else else