Skip to content
Snippets Groups Projects
Commit 1c4f9e82 authored by bunnei's avatar bunnei
Browse files

elf: Check if machine is ARM.

parent f2f39102
No related branches found
No related tags found
No related merge requests found
...@@ -364,12 +364,19 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const ...@@ -364,12 +364,19 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
namespace Loader { namespace Loader {
FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) {
u32 magic; static constexpr u16 ELF_MACHINE_ARM{0x28};
u32 magic = 0;
file.Seek(0, SEEK_SET); file.Seek(0, SEEK_SET);
if (1 != file.ReadArray<u32>(&magic, 1)) if (1 != file.ReadArray<u32>(&magic, 1))
return FileType::Error; 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::ELF;
return FileType::Error; return FileType::Error;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment