From 2c565f2a2647727d360bdd12df94a8049ba1db9b Mon Sep 17 00:00:00 2001 From: Nokk Date: Fri, 6 Sep 2024 16:10:52 +1000 Subject: [PATCH] Moved FindByName to Cpp --- src/core/linker.cpp | 2 -- src/core/linker.h | 1 + src/core/module.cpp | 9 +++++++++ src/core/module.h | 9 +-------- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/linker.cpp b/src/core/linker.cpp index af8ee470..d2c65ec7 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include - #include "common/alignment.h" #include "common/assert.h" #include "common/config.h" diff --git a/src/core/linker.h b/src/core/linker.h index 5b700a31..6b52c18e 100644 --- a/src/core/linker.h +++ b/src/core/linker.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include "core/module.h" diff --git a/src/core/module.cpp b/src/core/module.cpp index f48848bb..d62d73a4 100644 --- a/src/core/module.cpp +++ b/src/core/module.cpp @@ -69,6 +69,15 @@ Module::Module(Core::MemoryManager* memory_, const std::filesystem::path& file_, Module::~Module() = default; +void* Module::FindByName(std::string_view name) { + const auto symbols = export_sym.GetSymbols(); + const auto it = std::ranges::find(symbols, name, &Loader::SymbolRecord::nid_name); + if (it != symbols.end()) { + return reinterpret_cast(it->virtual_address); + } + return nullptr; +} + s32 Module::Start(size_t args, const void* argp, void* param) { LOG_INFO(Core_Linker, "Module started : {}", name); const VAddr addr = dynamic_info.init_virtual_addr + GetBaseAddress(); diff --git a/src/core/module.h b/src/core/module.h index 007501f0..df651d8b 100644 --- a/src/core/module.h +++ b/src/core/module.h @@ -165,14 +165,7 @@ public: return elf.IsSharedLib(); } - void* FindByName(std::string_view name) { - const auto symbols = export_sym.GetSymbols(); - const auto it = std::ranges::find(symbols, name, &Loader::SymbolRecord::nid_name); - if (it != symbols.end()) { - return reinterpret_cast(it->virtual_address); - } - return nullptr; - } + void* FindByName(std::string_view name); template T GetProcParam() const noexcept {