From cc34a85c54abd04e9bb2ca6a6c6576af418ac4d2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 19 Jun 2023 07:51:56 +0300 Subject: [PATCH] more symbols work and refactoring --- CMakeLists.txt | 4 ++-- src/Core/Memory.cpp | 2 +- src/Core/PS4/Linker.cpp | 28 ++++++++++++++++++++++++++++ src/Core/PS4/Linker.h | 3 ++- src/{ => Core/PS4}/Loader/Elf.cpp | 2 +- src/{ => Core/PS4}/Loader/Elf.h | 4 ++-- src/GUI/ElfViewer.h | 2 +- src/main.cpp | 3 +-- 8 files changed, 38 insertions(+), 10 deletions(-) rename src/{ => Core/PS4}/Loader/Elf.cpp (99%) rename src/{ => Core/PS4}/Loader/Elf.h (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 023b1289..b6af454d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,8 @@ add_executable(shadps4 src/types.h src/Core/FsFile.cpp src/Core/FsFile.h - src/Loader/Elf.cpp - src/Loader/Elf.h + src/Core/PS4/Loader/Elf.cpp + src/Core/PS4/Loader/Elf.h src/GUI/ElfViewer.cpp src/GUI/ElfViewer.h src/Util/Log.h diff --git a/src/Core/Memory.cpp b/src/Core/Memory.cpp index e71612e1..935e8542 100644 --- a/src/Core/Memory.cpp +++ b/src/Core/Memory.cpp @@ -1,4 +1,4 @@ -#include "../Loader/Elf.h" +#include "../Core/PS4/Loader/Elf.h" #include #include "../Util/Log.h" diff --git a/src/Core/PS4/Linker.cpp b/src/Core/PS4/Linker.cpp index 8e2d33ec..401de024 100644 --- a/src/Core/PS4/Linker.cpp +++ b/src/Core/PS4/Linker.cpp @@ -427,6 +427,34 @@ void Linker::LoadSymbols(Module* m) auto visibility = sym->GetVisibility(); if (library != nullptr || module != nullptr) { + switch (bind) + { + case STB_GLOBAL: + case STB_WEAK: + break; + default: + LOG_INFO_IF(debug_loader, "Unsupported bind {} for name symbol {} \n", bind,ids.at(0)); + continue; + } + switch (type) + { + case STT_OBJECT: + case STT_FUN: + break; + default: + LOG_INFO_IF(debug_loader, "Unsupported type {} for name symbol {} \n", type, ids.at(0)); + continue; + } + switch (visibility) + { + case STV_DEFAULT: + break; + default: + LOG_INFO_IF(debug_loader, "Unsupported visibility {} for name symbol {} \n", visibility, ids.at(0)); + continue; + } + //if st_value!=0 then it's export symbol + bool is_sym_export = sym->st_value != 0; LOG_INFO_IF(debug_loader, "name {} library {} module {} bind {} type {} visibility {}\n", ids.at(0),library->name,module->name,bind,type,visibility); } } diff --git a/src/Core/PS4/Linker.h b/src/Core/PS4/Linker.h index e61d2440..75e4220e 100644 --- a/src/Core/PS4/Linker.h +++ b/src/Core/PS4/Linker.h @@ -1,6 +1,7 @@ #pragma once -#include "../../Loader/Elf.h" + #include +#include "Loader/Elf.h" struct DynamicModuleInfo; diff --git a/src/Loader/Elf.cpp b/src/Core/PS4/Loader/Elf.cpp similarity index 99% rename from src/Loader/Elf.cpp rename to src/Core/PS4/Loader/Elf.cpp index aa88c201..f9ec3686 100644 --- a/src/Loader/Elf.cpp +++ b/src/Core/PS4/Loader/Elf.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "../Util/Log.h" +#include "../../../Util/Log.h" constexpr bool debug_elf = true; diff --git a/src/Loader/Elf.h b/src/Core/PS4/Loader/Elf.h similarity index 99% rename from src/Loader/Elf.h rename to src/Core/PS4/Loader/Elf.h index 0e00f13e..58d096fe 100644 --- a/src/Loader/Elf.h +++ b/src/Core/PS4/Loader/Elf.h @@ -1,8 +1,8 @@ #pragma once #include #include -#include "../types.h" -#include "../Core/FsFile.h" +#include "../../../types.h" +#include "../../FsFile.h" struct self_header { diff --git a/src/GUI/ElfViewer.h b/src/GUI/ElfViewer.h index 9edc74c8..ee5cea92 100644 --- a/src/GUI/ElfViewer.h +++ b/src/GUI/ElfViewer.h @@ -1,5 +1,5 @@ #pragma once -#include "../Loader/Elf.h" +#include "../Core/PS4/Loader/Elf.h" class ElfViewer { private: diff --git a/src/main.cpp b/src/main.cpp index 4dc12208..023d13e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,7 +16,6 @@ #include "spdlog/spdlog.h" #include "types.h" -#include "Loader/Elf.h" #include "GUI/ElfViewer.h" #include "Util/Log.h" @@ -36,7 +35,7 @@ int main(int argc, char* argv[]) 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 auto* linker = Singleton::Instance(); auto *module =linker->LoadModule(path);//load main executable