shadPS4/src/core/PS4/Loader/SymbolsResolver.cpp

30 lines
861 B
C++
Raw Normal View History

2023-11-05 12:41:10 +01:00
#include "common/types.h"
2023-06-26 17:12:19 +02:00
#include "SymbolsResolver.h"
2023-11-05 12:41:10 +01:00
#include "common/log.h"
2023-06-26 17:12:19 +02:00
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr)
{
SymbolRecord r{};
r.name = GenerateName(s);
2023-06-26 17:12:19 +02:00
r.virtual_address = virtual_addr;
m_symbols.push_back(r);
}
std::string SymbolsResolver::GenerateName(const SymbolRes& s) {
return fmt::format("{} lib[{}_v{}]mod[{}_v{}.{}]",
s.name, s.library, s.library_version,
s.module, s.module_version_major, s.module_version_minor);
}
const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolRes& s) const {
const std::string name = GenerateName(s);
for (u32 i = 0; i < m_symbols.size(); i++) {
if (m_symbols[i].name.compare(name) == 0) {
return &m_symbols[i];
}
}
LOG_INFO("Unresolved! {}\n", name);
return nullptr;
}