PPCSymbolDB: Do not truncate fixed size symbols

Fix comparison warning
This commit is contained in:
Sepalani 2018-04-10 09:58:35 +04:00
parent 9b8866ba78
commit 7d36165489
4 changed files with 12 additions and 5 deletions

View File

@ -39,7 +39,7 @@ struct Symbol
u32 hash = 0; // use for HLE function finding u32 hash = 0; // use for HLE function finding
u32 address = 0; u32 address = 0;
u32 flags = 0; u32 flags = 0;
int size = 0; u32 size = 0;
int numCalls = 0; int numCalls = 0;
Type type = Type::Function; Type type = Type::Function;
int index = 0; // only used for coloring the disasm view int index = 0; // only used for coloring the disasm view

View File

@ -83,7 +83,7 @@ static u32 EvaluateBranchTarget(UGeckoInstruction instr, u32 pc)
// Also collect which internal branch goes the farthest. // Also collect which internal branch goes the farthest.
// If any one goes farther than the blr or rfi, assume that there is more than // If any one goes farther than the blr or rfi, assume that there is more than
// one blr or rfi, and keep scanning. // one blr or rfi, and keep scanning.
bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size) bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
{ {
if (func.name.empty()) if (func.name.empty())
func.Rename(StringFromFormat("zz_%08x_", startAddr)); func.Rename(StringFromFormat("zz_%08x_", startAddr));
@ -176,7 +176,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
} }
} }
bool ReanalyzeFunction(u32 start_addr, Symbol& func, int max_size) bool ReanalyzeFunction(u32 start_addr, Symbol& func, u32 max_size)
{ {
ASSERT_MSG(SYMBOLS, func.analyzed, "The function wasn't previously analyzed!"); ASSERT_MSG(SYMBOLS, func.analyzed, "The function wasn't previously analyzed!");

View File

@ -225,7 +225,7 @@ private:
void LogFunctionCall(u32 addr); void LogFunctionCall(u32 addr);
void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db); void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db);
bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size = 0); bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size = 0);
bool ReanalyzeFunction(u32 start_addr, Symbol& func, int max_size = 0); bool ReanalyzeFunction(u32 start_addr, Symbol& func, u32 max_size = 0);
} // namespace } // namespace

View File

@ -68,6 +68,13 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
if (tf.type == Symbol::Type::Function) if (tf.type == Symbol::Type::Function)
{ {
PPCAnalyst::AnalyzeFunction(startAddr, tf, size); PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
// Do not truncate symbol when a size is expected
if (size != 0 && tf.size != size)
{
WARN_LOG(SYMBOLS, "Analysed symbol (%s) size mismatch, %u expected but %u computed",
name.c_str(), size, tf.size);
tf.size = size;
}
checksumToFunction[tf.hash].insert(&functions[startAddr]); checksumToFunction[tf.hash].insert(&functions[startAddr]);
} }
else else