diff options
Diffstat (limited to 'src/core/loader/elf.cpp')
-rw-r--r-- | src/core/loader/elf.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index e36e42120..9969a8c39 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -364,12 +364,19 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const namespace Loader { FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { - u32 magic; + static constexpr u16 ELF_MACHINE_ARM{0x28}; + + u32 magic = 0; file.Seek(0, SEEK_SET); if (1 != file.ReadArray<u32>(&magic, 1)) return FileType::Error; - if (MakeMagic('\x7f', 'E', 'L', 'F') == magic) + u16 machine = 0; + file.Seek(18, SEEK_SET); + if (1 != file.ReadArray<u16>(&machine, 1)) + return FileType::Error; + + if (MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine) return FileType::ELF; return FileType::Error; @@ -394,7 +401,8 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) { SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR); codeset->name = filename; - process = Kernel::Process::Create(std::move(codeset)); + process = Kernel::Process::Create("main"); + process->LoadModule(codeset, codeset->entrypoint); process->svc_access_mask.set(); process->address_mappings = default_address_mappings; @@ -402,7 +410,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) { process->resource_limit = Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); - process->Run(48, Kernel::DEFAULT_STACK_SIZE); + process->Run(codeset->entrypoint, 48, Kernel::DEFAULT_STACK_SIZE); is_loaded = true; return ResultStatus::Success; |