small improvements on linker Resolve method

This commit is contained in:
georgemoralis 2024-03-26 12:31:46 +02:00
parent 365ae2aac9
commit 596831947e
1 changed files with 28 additions and 33 deletions

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <Zydis/Zydis.h> #include <Zydis/Zydis.h>
#include <common/assert.h>
#include "common/config.h" #include "common/config.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/path_util.h" #include "common/path_util.h"
@ -577,12 +578,12 @@ void Linker::Relocate(Module* m) {
void Linker::Resolve(const std::string& name, Loader::SymbolType Symtype, Module* m, void Linker::Resolve(const std::string& name, Loader::SymbolType Symtype, Module* m,
Loader::SymbolRecord* return_info) { Loader::SymbolRecord* return_info) {
const auto ids = Common::SplitString(name, '#'); const auto ids = Common::SplitString(name, '#');
if (ids.size() == 3) // symbols are 3 parts name , library , module ASSERT_MSG(ids.size() == 3, "Symbols must be 3 parts name, library, module");
{
const auto* library = FindLibrary(*m, ids.at(1)); const auto* library = FindLibrary(*m, ids.at(1));
const auto* module = FindModule(*m, ids.at(2)); const auto* module = FindModule(*m, ids.at(2));
ASSERT_MSG(library && module, "Unable to find library and module");
if (library != nullptr && module != nullptr) {
Loader::SymbolResolver sr{}; Loader::SymbolResolver sr{};
sr.name = ids.at(0); sr.name = ids.at(0);
sr.library = library->name; sr.library = library->name;
@ -609,12 +610,6 @@ void Linker::Resolve(const std::string& name, Loader::SymbolType Symtype, Module
LOG_ERROR(Core_Linker, "Linker: Stub resolved {} as {} (lib: {}, mod: {})", sr.name, LOG_ERROR(Core_Linker, "Linker: Stub resolved {} as {} (lib: {}, mod: {})", sr.name,
return_info->name, library->name, module->name); return_info->name, library->name, module->name);
} }
} else {
//__debugbreak();//den tha prepei na ftasoume edo
}
} else {
//__debugbreak();//oute edo mallon
}
} }
using exit_func_t = PS4_SYSV_ABI void (*)(); using exit_func_t = PS4_SYSV_ABI void (*)();