mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-10-30 07:11:38 +00:00
Added ability to alias function names to ease of debugging and reversing.
This commit is contained in:
parent
5e945d81e9
commit
8782d4dbd7
3 changed files with 32 additions and 2 deletions
|
|
@ -171,7 +171,19 @@ void Recompiler::Analyse()
|
||||||
for (auto& [address, size] : config.functions)
|
for (auto& [address, size] : config.functions)
|
||||||
{
|
{
|
||||||
functions.emplace_back(address, size);
|
functions.emplace_back(address, size);
|
||||||
image.symbols.emplace(fmt::format("sub_{:X}", address), address, size, Symbol_Function);
|
// Check if there's a function alias for this address
|
||||||
|
auto aliasIt = config.functionAliases.find(address);
|
||||||
|
std::string symbolName;
|
||||||
|
if (aliasIt != config.functionAliases.end())
|
||||||
|
{
|
||||||
|
symbolName = aliasIt->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
symbolName = fmt::format("sub_{:X}", address);
|
||||||
|
}
|
||||||
|
|
||||||
|
image.symbols.emplace(symbolName, address, size, Symbol_Function);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& pdata = *image.Find(".pdata");
|
auto& pdata = *image.Find(".pdata");
|
||||||
|
|
@ -2784,7 +2796,13 @@ bool Recompiler::Recompile(const Function& fn)
|
||||||
|
|
||||||
auto symbol = image.symbols.find(fn.base);
|
auto symbol = image.symbols.find(fn.base);
|
||||||
std::string name;
|
std::string name;
|
||||||
if (symbol != image.symbols.end())
|
auto aliasIt = config.functionAliases.find(fn.base);
|
||||||
|
|
||||||
|
if (aliasIt != config.functionAliases.end())
|
||||||
|
{
|
||||||
|
name = aliasIt->second;
|
||||||
|
}
|
||||||
|
else if (symbol != image.symbols.end())
|
||||||
{
|
{
|
||||||
name = symbol->name;
|
name = symbol->name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,17 @@ void RecompilerConfig::Load(const std::string_view& configFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto functionAliasesArray = main["function_aliases"].as_array())
|
||||||
|
{
|
||||||
|
for (auto& alias : *functionAliasesArray)
|
||||||
|
{
|
||||||
|
auto& aliasTable = *alias.as_table();
|
||||||
|
uint32_t address = *aliasTable["address"].value<uint32_t>();
|
||||||
|
std::string name = fmt::format("_gfn_{}", *aliasTable["name"].value<std::string>());
|
||||||
|
functionAliases.emplace(address, std::move(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auto invalidArray = main["invalid_instructions"].as_array())
|
if (auto invalidArray = main["invalid_instructions"].as_array())
|
||||||
{
|
{
|
||||||
for (auto& instr : *invalidArray)
|
for (auto& instr : *invalidArray)
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ struct RecompilerConfig
|
||||||
std::unordered_map<uint32_t, uint32_t> functions;
|
std::unordered_map<uint32_t, uint32_t> functions;
|
||||||
std::unordered_map<uint32_t, uint32_t> invalidInstructions;
|
std::unordered_map<uint32_t, uint32_t> invalidInstructions;
|
||||||
std::unordered_map<uint32_t, RecompilerMidAsmHook> midAsmHooks;
|
std::unordered_map<uint32_t, RecompilerMidAsmHook> midAsmHooks;
|
||||||
|
std::unordered_map<uint32_t, std::string> functionAliases;
|
||||||
|
|
||||||
void Load(const std::string_view& configFilePath);
|
void Load(const std::string_view& configFilePath);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue