Moved FindByName to Cpp

This commit is contained in:
Nokk 2024-09-06 16:10:52 +10:00
parent 32d5912d90
commit 2c565f2a26
4 changed files with 11 additions and 10 deletions

View File

@ -1,8 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include "common/alignment.h"
#include "common/assert.h"
#include "common/config.h"

View File

@ -3,6 +3,7 @@
#pragma once
#include <algorithm>
#include <mutex>
#include <vector>
#include "core/module.h"

View File

@ -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<void*>(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();

View File

@ -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<void*>(it->virtual_address);
}
return nullptr;
}
void* FindByName(std::string_view name);
template <typename T = VAddr>
T GetProcParam() const noexcept {