some more progress on linker , elf is now load from there

This commit is contained in:
georgemoralis 2023-05-23 10:47:56 +03:00
parent a09e2eb65a
commit b27942c46b
3 changed files with 29 additions and 4 deletions

View file

@ -11,6 +11,22 @@ Linker::~Linker()
Module* Linker::LoadModule(const std::string& elf_name) Module* Linker::LoadModule(const std::string& elf_name)
{ {
auto* m = new Module; auto* m = new Module;
m->elf = new Elf;
m->elf->Open(elf_name);//load elf
m_modules.push_back(m);//added it to load modules
return m; return m;
} }
Module* Linker::FindModule(/*u32 id*/)
{
//find module . TODO atm we only have 1 module so we don't need to iterate on vector
Module* m = m_modules.at(0);
if (m)
{
return m;
}
return nullptr;
}

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "../../Loader/Elf.h" #include "../../Loader/Elf.h"
#include <vector>
/*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/ /*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/
struct Module struct Module
@ -14,4 +15,8 @@ public:
virtual ~Linker(); virtual ~Linker();
Module* LoadModule(const std::string& elf_name); Module* LoadModule(const std::string& elf_name);
Module* FindModule(/*u32 id*/);
private:
std::vector<Module*> m_modules;
}; };

View file

@ -24,14 +24,18 @@
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#include "../libs/emscripten/emscripten_mainloop_stub.h" #include "../libs/emscripten/emscripten_mainloop_stub.h"
#endif #endif
#include "Core/PS4/Linker.h"
#include "Util/Singleton.h"
// Main code // Main code
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
logging::init(true);//init logging logging::init(true);//init logging
const char* const path = argv[1]; //argument 1 is the path of self file to boot const char* const path = argv[1]; //argument 1 is the path of self file to boot
Elf* elf = new Elf; auto* linker = Singleton<Linker>::Instance();
elf->Open(path); auto *module =linker->LoadModule(path);//load main executable
// Setup SDL // Setup SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0)
@ -188,8 +192,8 @@ int main(int argc, char* argv[])
show_another_window = false; show_another_window = false;
ImGui::End(); ImGui::End();
} }
auto* linker = Singleton<Linker>::Instance();
ElfViewer elfview(elf); ElfViewer elfview(linker->FindModule()->elf);
elfview.display(show_another_window); elfview.display(show_another_window);
// Rendering // Rendering
ImGui::Render(); ImGui::Render();