initial work on linker

This commit is contained in:
georgemoralis 2023-05-23 07:48:25 +03:00
parent 76987fb932
commit a09e2eb65a
4 changed files with 68 additions and 1 deletions

View file

@ -26,7 +26,14 @@ add_executable(shadps4
src/Loader/Elf.cpp src/Loader/Elf.cpp
src/Loader/Elf.h src/Loader/Elf.h
src/GUI/ElfViewer.cpp src/GUI/ElfViewer.cpp
src/GUI/ElfViewer.h "src/Util/Log.h" "src/Util/Log.cpp" "src/Core/Memory.cpp" "src/Core/Memory.h") src/GUI/ElfViewer.h
src/Util/Log.h
src/Util/Log.cpp
src/Core/Memory.cpp
src/Core/Memory.h
src/Core/PS4/Linker.cpp
src/Core/PS4/Linker.h
"src/Util/Singleton.h")
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)

16
src/Core/PS4/Linker.cpp Normal file
View file

@ -0,0 +1,16 @@
#include "Linker.h"
Linker::Linker()
{
}
Linker::~Linker()
{
}
Module* Linker::LoadModule(const std::string& elf_name)
{
auto* m = new Module;
return m;
}

17
src/Core/PS4/Linker.h Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include "../../Loader/Elf.h"
/*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/
struct Module
{
Elf* elf = nullptr;
};
class Linker
{
public:
Linker();
virtual ~Linker();
Module* LoadModule(const std::string& elf_name);
};

27
src/Util/Singleton.h Normal file
View file

@ -0,0 +1,27 @@
#pragma once
#include <cstdlib>
#include <new>
template <class T>
class Singleton
{
public:
static T* Instance()
{
if (!m_instance)
{
m_instance = static_cast<T*>(std::malloc(sizeof(T)));
new (m_instance) T;
}
return m_instance;
}
protected:
Singleton();
~Singleton();
private:
static inline T* m_instance = nullptr;
};