shadPS4/src/core/loader/symbols_resolver.h

69 lines
1.5 KiB
C
Raw Normal View History

2024-02-23 21:32:32 +00:00
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2023-06-26 15:12:19 +00:00
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
2023-11-05 11:41:10 +00:00
#include "common/types.h"
2023-06-26 15:12:19 +00:00
2023-11-05 23:11:54 +00:00
namespace Core::Loader {
enum class SymbolType {
Unknown,
Function,
Object,
Tls,
NoType,
};
2023-11-05 23:11:54 +00:00
struct SymbolRecord {
std::string name;
u64 virtual_address;
2023-06-26 15:12:19 +00:00
};
struct SymbolResolver {
2023-11-05 23:11:54 +00:00
std::string name;
std::string nidName;
std::string library;
u16 library_version;
std::string module;
2024-02-23 21:32:32 +00:00
u8 module_version_major;
u8 module_version_minor;
SymbolType type;
2023-06-26 15:12:19 +00:00
};
2023-11-05 23:11:54 +00:00
class SymbolsResolver {
2023-06-26 15:12:19 +00:00
public:
SymbolsResolver() = default;
virtual ~SymbolsResolver() = default;
2023-06-26 15:12:19 +00:00
void AddSymbol(const SymbolResolver& s, u64 virtual_addr);
const SymbolRecord* FindSymbol(const SymbolResolver& s) const;
static std::string GenerateName(const SymbolResolver& s);
static std::string_view SymbolTypeToS(SymbolType sym_type) {
switch (sym_type) {
case SymbolType::Unknown:
return "Unknown";
case SymbolType::Function:
return "Function";
case SymbolType::Object:
return "Object";
case SymbolType::Tls:
return "Tls";
case SymbolType::NoType:
return "NoType";
}
}
void DebugDump(const std::filesystem::path& file_name);
2023-06-26 15:12:19 +00:00
private:
2023-11-05 23:11:54 +00:00
std::vector<SymbolRecord> m_symbols;
2023-11-05 11:41:10 +00:00
};
2023-11-05 23:11:54 +00:00
} // namespace Core::Loader