From 53f504bd412c208d23331b9dde2958f5df793e90 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 18 Apr 2023 11:33:53 +0300 Subject: [PATCH] let's see if magic enum can work part1 --- emulator/Loader/Elf.cpp | 4 ++-- emulator/Loader/Elf.h | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/emulator/Loader/Elf.cpp b/emulator/Loader/Elf.cpp index f75a1c8b..98ca88b4 100644 --- a/emulator/Loader/Elf.cpp +++ b/emulator/Loader/Elf.cpp @@ -222,7 +222,7 @@ bool Elf::isElfFile() const return false; } - if (m_elf_header->e_type != ET_DYNEXEC && m_elf_header->e_type != ET_DYNAMIC) + if (m_elf_header->e_type != ET_SCE_DYNEXEC && m_elf_header->e_type != ET_SCE_DYNAMIC) { printf("ERROR:e_type expected 0xFE10 OR 0xFE18 is (%04x)\n", m_elf_header->e_type); return false; @@ -302,7 +302,7 @@ void Elf::DebugDump() { } spdlog::info("\n"); - spdlog::info(" type .........: {:#06x}\n", m_elf_header->e_type); + //spdlog::info(" type .........: {:#06x}\n", m_elf_header->e_type); spdlog::info(" machine .......: {:#06x}\n", m_elf_header->e_machine); spdlog::info(" version .......: {:#010x}\n", m_elf_header->e_version); diff --git a/emulator/Loader/Elf.h b/emulator/Loader/Elf.h index c9925fd5..b27c7a8f 100644 --- a/emulator/Loader/Elf.h +++ b/emulator/Loader/Elf.h @@ -61,13 +61,25 @@ constexpr u08 ELFABIVERSION_AMDGPU_HSA_V2 = 0; constexpr u16 ET_DYNEXEC = 0xFE10; // Executable file constexpr u16 ET_DYNAMIC = 0xFE18; // Shared +typedef enum : u16 { + ET_NONE = 0x0, + ET_REL = 0x1, + ET_EXEC = 0x2, + ET_DYN = 0x3, + ET_CORE = 0x4, + ET_SCE_EXEC = 0xfe00, + ET_SCE_STUBLIB = 0xfe0c, + ET_SCE_DYNEXEC = 0xfe10, + ET_SCE_DYNAMIC = 0xfe18 +} e_type_s; + //machine field constexpr u16 EM_X86_64 = 62; // Advanced Micro Devices X86-64 processor struct elf_header { u08 e_ident[16]; /* ELF identification */ - u16 e_type; /* Object file type */ + e_type_s e_type; /* Object file type */ u16 e_machine; /* Machine type */ u32 e_version; /* Object file version */ u64 e_entry; /* Entry point address */