2023-06-26 17:12:19 +02:00
|
|
|
#include "../../../types.h"
|
|
|
|
#include "SymbolsResolver.h"
|
2023-08-13 15:54:56 +02:00
|
|
|
#include <Util/log.h>
|
2023-06-26 17:12:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr)
|
|
|
|
{
|
|
|
|
SymbolRecord r{};
|
2023-07-11 17:50:29 +02:00
|
|
|
r.name = GenerateName(s);
|
2023-06-26 17:12:19 +02:00
|
|
|
r.virtual_address = virtual_addr;
|
|
|
|
m_symbols.push_back(r);
|
2023-07-11 17:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SymbolsResolver::GenerateName(const SymbolRes& s) {
|
|
|
|
char str[256];
|
|
|
|
sprintf(str, "%s lib[%s_v%d]mod[%s_v%d.%d]", s.name.c_str(),s.library.c_str(), s.library_version, s.module.c_str(),
|
|
|
|
s.module_version_major, s.module_version_minor);
|
|
|
|
return std::string(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolRes& s) const {
|
|
|
|
std::string name = GenerateName(s);
|
|
|
|
int index = 0;
|
|
|
|
for (auto symbol : m_symbols) {
|
|
|
|
if (symbol.name.compare(name) == 0) {
|
|
|
|
return &m_symbols.at(index);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
2023-07-13 11:56:36 +02:00
|
|
|
LOG_INFO_IF(true, "unresolved! {}\n", name);
|
2023-07-11 17:50:29 +02:00
|
|
|
return nullptr;
|
2023-06-26 17:12:19 +02:00
|
|
|
}
|