mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
Merge pull request #6309 from sepalani/rsbk-sym-map
PPCSymbolDB: two columns symbol map support added
This commit is contained in:
commit
28176d0117
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -73,7 +74,10 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
|
|||||||
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
||||||
checksumToFunction[tf.hash].insert(&functions[startAddr]);
|
checksumToFunction[tf.hash].insert(&functions[startAddr]);
|
||||||
}
|
}
|
||||||
tf.size = size;
|
else
|
||||||
|
{
|
||||||
|
tf.size = size;
|
||||||
|
}
|
||||||
functions[startAddr] = tf;
|
functions[startAddr] = tf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,8 +223,10 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
|
|||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// four columns are used in American Mensa Academy map files and perhaps other games
|
// Two columns are used by Super Smash Bros. Brawl Korean map file
|
||||||
bool four_columns = false;
|
// Three columns are commonly used
|
||||||
|
// Four columns are used in American Mensa Academy map files and perhaps other games
|
||||||
|
int column_count = 0;
|
||||||
int good_count = 0;
|
int good_count = 0;
|
||||||
int bad_count = 0;
|
int bad_count = 0;
|
||||||
|
|
||||||
@ -234,7 +240,7 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
|
|||||||
|
|
||||||
if (length == 34 && strcmp(line, " address Size address offset\n") == 0)
|
if (length == 34 && strcmp(line, " address Size address offset\n") == 0)
|
||||||
{
|
{
|
||||||
four_columns = true;
|
column_count = 4;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,9 +293,19 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
|
|||||||
if (section_name.empty())
|
if (section_name.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Detect two columns with three columns fallback
|
||||||
|
if (column_count == 0)
|
||||||
|
{
|
||||||
|
const std::string stripped_line = StripSpaces(line);
|
||||||
|
if (std::count(stripped_line.begin(), stripped_line.end(), ' ') == 1)
|
||||||
|
column_count = 2;
|
||||||
|
else
|
||||||
|
column_count = 3;
|
||||||
|
}
|
||||||
|
|
||||||
u32 address, vaddress, size, offset, alignment;
|
u32 address, vaddress, size, offset, alignment;
|
||||||
char name[512], container[512];
|
char name[512], container[512];
|
||||||
if (four_columns)
|
if (column_count == 4)
|
||||||
{
|
{
|
||||||
// sometimes there is no alignment value, and sometimes it is because it is an entry of
|
// sometimes there is no alignment value, and sometimes it is because it is an entry of
|
||||||
// something else
|
// something else
|
||||||
@ -317,32 +333,44 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
|
|||||||
&alignment, name);
|
&alignment, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// some entries in the table have a function name followed by " (entry of " followed by a
|
else if (column_count == 3)
|
||||||
// container name, followed by ")"
|
|
||||||
// instead of a space followed by a number followed by a space followed by a name
|
|
||||||
else if (length > 27 && line[27] != ' ' && strstr(line, "(entry of "))
|
|
||||||
{
|
{
|
||||||
alignment = 0;
|
// some entries in the table have a function name followed by " (entry of " followed by a
|
||||||
sscanf(line, "%08x %08x %08x %511s", &address, &size, &vaddress, name);
|
// container name, followed by ")"
|
||||||
char* s = strstr(line, "(entry of ");
|
// instead of a space followed by a number followed by a space followed by a name
|
||||||
if (s)
|
if (length > 27 && line[27] != ' ' && strstr(line, "(entry of "))
|
||||||
{
|
{
|
||||||
sscanf(s + 10, "%511s", container);
|
alignment = 0;
|
||||||
char* s2 = (strchr(container, ')'));
|
sscanf(line, "%08x %08x %08x %511s", &address, &size, &vaddress, name);
|
||||||
if (s2 && container[0] != '.')
|
char* s = strstr(line, "(entry of ");
|
||||||
|
if (s)
|
||||||
{
|
{
|
||||||
s2[0] = '\0';
|
sscanf(s + 10, "%511s", container);
|
||||||
strcat(container, "::");
|
char* s2 = (strchr(container, ')'));
|
||||||
strcat(container, name);
|
if (s2 && container[0] != '.')
|
||||||
strcpy(name, container);
|
{
|
||||||
|
s2[0] = '\0';
|
||||||
|
strcat(container, "::");
|
||||||
|
strcat(container, name);
|
||||||
|
strcpy(name, container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sscanf(line, "%08x %08x %08x %i %511s", &address, &size, &vaddress, &alignment, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (column_count == 2)
|
||||||
|
{
|
||||||
|
sscanf(line, "%08x %511s", &address, name);
|
||||||
|
vaddress = address;
|
||||||
|
size = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sscanf(line, "%08x %08x %08x %i %511s", &address, &size, &vaddress, &alignment, name);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* namepos = strstr(line, name);
|
const char* namepos = strstr(line, name);
|
||||||
if (namepos != nullptr) // would be odd if not :P
|
if (namepos != nullptr) // would be odd if not :P
|
||||||
strcpy(name, namepos);
|
strcpy(name, namepos);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user