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>
This commit is contained in:
georgemoralis 2024-03-11 13:26:33 +02:00 committed by GitHub
parent 00d401e103
commit 02dcf4d45c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 130 additions and 36 deletions

View file

@ -1,25 +1,28 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/io_file.h"
#include "common/logging/log.h"
#include "common/string_util.h"
#include "common/types.h"
#include "core/aerolib/aerolib.h"
#include "core/loader/symbols_resolver.h"
namespace Core::Loader {
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr) {
void SymbolsResolver::AddSymbol(const SymbolResolver& s, u64 virtual_addr) {
SymbolRecord r{};
r.name = GenerateName(s);
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);
std::string SymbolsResolver::GenerateName(const SymbolResolver& s) {
return fmt::format("{}#{}#{}#{}#{}#{}#{}", s.name, s.library, s.library_version, s.module,
s.module_version_major, s.module_version_minor, SymbolTypeToS(s.type));
}
const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolRes& s) const {
const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolResolver& 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) {
@ -31,4 +34,22 @@ const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolRes& s) const {
return nullptr;
}
void SymbolsResolver::DebugDump(const std::filesystem::path& file_name) {
Common::FS::IOFile f{file_name, Common::FS::FileAccessMode::Write,
Common::FS::FileType::TextFile};
for (const auto& symbol : m_symbols) {
const auto ids = Common::SplitString(symbol.name, '#');
std::string nidName = "";
auto aeronid = AeroLib::FindByNid(ids.at(0).c_str());
if (aeronid != nullptr) {
nidName = aeronid->name;
} else {
nidName = "UNK";
}
f.WriteString(fmt::format("{:<20} {:<16} {:<60} {:<30} {:<2} {:<30} {:<2} {:<2} {:<10}\n",
symbol.virtual_address, ids.at(0), nidName, ids.at(1), ids.at(2),
ids.at(3), ids.at(4), ids.at(5), ids.at(6)));
}
}
} // namespace Core::Loader