shadPS4/src/core/loader/symbols_resolver.h
georgemoralis af1e3c02ad LLE libc + other fixes part1 (#97)
* app0 folder is absolute

* some improvements on symbols types

* clang format

* missing libs.h

* improved symbols_resolver

* moved config to config folder

* functions to dump import functions

* improved logging output

* option for debugdump and improvements

* Apply suggestions from code review

Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com>

* clang format

---------

Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com>
2024-03-11 13:26:33 +02:00

69 lines
1.5 KiB
C++

// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
#include "common/types.h"
namespace Core::Loader {
enum class SymbolType {
Unknown,
Function,
Object,
Tls,
NoType,
};
struct SymbolRecord {
std::string name;
u64 virtual_address;
};
struct SymbolResolver {
std::string name;
std::string nidName;
std::string library;
u16 library_version;
std::string module;
u8 module_version_major;
u8 module_version_minor;
SymbolType type;
};
class SymbolsResolver {
public:
SymbolsResolver() = default;
virtual ~SymbolsResolver() = default;
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);
private:
std::vector<SymbolRecord> m_symbols;
};
} // namespace Core::Loader