mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-22 11:56:58 +02:00
@@ -6,7 +6,6 @@
|
||||
#include "common/file.h"
|
||||
#include "common/hostException.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/magicEnum.h"
|
||||
#include "common/platform/sysDbg.h"
|
||||
#include "common/profiler.h"
|
||||
#include "common/singleton.h"
|
||||
@@ -29,6 +28,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <magic_enum.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -330,7 +330,7 @@ static KYTY_SYSV_ABI uint64_t ResolveImportStubWithId(uint64_t record_id) {
|
||||
LOGF("Unresolved import stub called [%u]: patch_vaddr=0x%016" PRIx64
|
||||
" jmprela_index=%" PRIu32 " symbol=%s type=%s bind=%s program=%s\n",
|
||||
log_index, record.patch_vaddr, record.index, record.name.c_str(),
|
||||
Common::EnumName(record.type).c_str(), Common::EnumName(record.bind).c_str(),
|
||||
magic_enum::enum_name(record.type), magic_enum::enum_name(record.bind),
|
||||
record.program.c_str());
|
||||
} else {
|
||||
printf("Unresolved import stub called: <bad-record>\n");
|
||||
@@ -1046,8 +1046,8 @@ static void RelocateRecord(uint32_t index, Elf64_Rela* r, Program* program, bool
|
||||
patched = PatchGuestMemory64(ri.vaddr, value);
|
||||
} else {
|
||||
auto dbg_str = fmt::format("[{:016x}] <- {:016x}, {}, {}, {}, {}", ri.vaddr, ri.value,
|
||||
ri.name.c_str(), Common::EnumName(ri.type).c_str(),
|
||||
Common::EnumName(ri.bind).c_str(), ri.dbg_name.c_str());
|
||||
ri.name.c_str(), magic_enum::enum_name(ri.type),
|
||||
magic_enum::enum_name(ri.bind), ri.dbg_name.c_str());
|
||||
|
||||
if (unresolved != nullptr) {
|
||||
unresolved->push_back(dbg_str);
|
||||
@@ -1077,14 +1077,14 @@ static void RelocateRecord(uint32_t index, Elf64_Rela* r, Program* program, bool
|
||||
const auto thunk = RegisterStubbedImport(index, program, ri);
|
||||
LOGF("Relocate: unresolved PLT import patched to stub [%u] [%016" PRIx64 "] <- %016" PRIx64
|
||||
", %s, %s, %s, %s\n",
|
||||
index, ri.vaddr, thunk, ri.name.c_str(), Common::EnumName(ri.type).c_str(),
|
||||
Common::EnumName(ri.bind).c_str(), Common::PathToString(program->file_name).c_str());
|
||||
index, ri.vaddr, thunk, ri.name.c_str(), magic_enum::enum_name(ri.type),
|
||||
magic_enum::enum_name(ri.bind), Common::PathToString(program->file_name).c_str());
|
||||
} else if (patched && stubbed_func) {
|
||||
const auto thunk = RegisterStubbedImport(index, program, ri);
|
||||
LOGF("Relocate: unresolved non-PLT function patched to stub [%u] [%016" PRIx64
|
||||
"] <- %016" PRIx64 ", %s, %s, %s, %s\n",
|
||||
index, ri.vaddr, thunk, ri.name.c_str(), Common::EnumName(ri.type).c_str(),
|
||||
Common::EnumName(ri.bind).c_str(), Common::PathToString(program->file_name).c_str());
|
||||
index, ri.vaddr, thunk, ri.name.c_str(), magic_enum::enum_name(ri.type),
|
||||
magic_enum::enum_name(ri.bind), Common::PathToString(program->file_name).c_str());
|
||||
}
|
||||
|
||||
if (program->dbg_print_reloc) {
|
||||
@@ -1092,8 +1092,8 @@ static void RelocateRecord(uint32_t index, Elf64_Rela* r, Program* program, bool
|
||||
(ri.bind == BindType::Global || ri.bind == BindType::Weak ||
|
||||
ri.type == SymbolType::TlsModule)) {
|
||||
auto dbg_str = fmt::format("[{:016x}] <- {:016x}, {}, {}, {}, {}", ri.vaddr, ri.value,
|
||||
ri.name.c_str(), Common::EnumName(ri.type).c_str(),
|
||||
Common::EnumName(ri.bind).c_str(), ri.dbg_name.c_str());
|
||||
ri.name.c_str(), magic_enum::enum_name(ri.type),
|
||||
magic_enum::enum_name(ri.bind), ri.dbg_name.c_str());
|
||||
|
||||
LOGF("Relocate: %s\n", dbg_str.c_str());
|
||||
}
|
||||
@@ -2082,7 +2082,7 @@ void RuntimeLinker::LoadProgramToMemory(Program* program) {
|
||||
"[%d] memory_size = %" PRIu64 "\n"
|
||||
"[%d] mode = %s\n",
|
||||
i, segment_addr, i, segment_file_size, i, segment_memory_size, i,
|
||||
Common::EnumName(mode).c_str());
|
||||
magic_enum::enum_name(mode));
|
||||
|
||||
program->elf->LoadSegment(segment_addr, phdr[i].p_offset, segment_file_size);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "loader/symbolDatabase.h"
|
||||
|
||||
#include "common/file.h"
|
||||
#include "common/magicEnum.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <magic_enum.hpp>
|
||||
|
||||
namespace Loader {
|
||||
|
||||
@@ -18,7 +18,7 @@ std::string SymbolDatabase::GenerateName(const SymbolResolve& s) {
|
||||
auto module = UpdateName(s.module);
|
||||
return fmt::format("{}[{}_v{}][{}_v{}.{}][{}]", s.name.c_str(), library.c_str(),
|
||||
s.library_version, module.c_str(), s.module_version_major,
|
||||
s.module_version_minor, Common::EnumName(s.type).c_str());
|
||||
s.module_version_minor, magic_enum::enum_name(s.type));
|
||||
}
|
||||
|
||||
void SymbolDatabase::Add(const SymbolResolve& s, uint64_t vaddr) {
|
||||
@@ -67,7 +67,7 @@ const SymbolRecord* SymbolDatabase::Find(const SymbolResolve& s) const {
|
||||
|
||||
const SymbolRecord* SymbolDatabase::FindByNid(const std::string& nid, SymbolType type) const {
|
||||
auto prefix = nid + "[";
|
||||
auto suffix = fmt::format("[{}]", Common::EnumName(type).c_str());
|
||||
auto suffix = fmt::format("[{}]", magic_enum::enum_name(type));
|
||||
|
||||
for (const auto& symbol: m_symbols) {
|
||||
if (Common::StartsWith(symbol.name, prefix) && Common::EndsWith(symbol.name, suffix)) {
|
||||
@@ -80,7 +80,7 @@ const SymbolRecord* SymbolDatabase::FindByNid(const std::string& nid, SymbolType
|
||||
|
||||
const SymbolRecord* SymbolDatabase::FindByName(const std::string& name, SymbolType type) const {
|
||||
auto prefix = name + "[";
|
||||
auto suffix = fmt::format("[{}]", Common::EnumName(type).c_str());
|
||||
auto suffix = fmt::format("[{}]", magic_enum::enum_name(type));
|
||||
|
||||
for (const auto& symbol: m_symbols) {
|
||||
if (Common::StartsWith(symbol.name, prefix) && Common::EndsWith(symbol.name, suffix)) {
|
||||
|
||||
Reference in New Issue
Block a user