diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/loader/elf.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index cfcde9167..055bc39de 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 | |||
| 364 | namespace Loader { | 364 | namespace Loader { |
| 365 | 365 | ||
| 366 | FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { | 366 | FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { |
| 367 | u32 magic; | 367 | static constexpr u16 ELF_MACHINE_ARM{0x28}; |
| 368 | |||
| 369 | u32 magic = 0; | ||
| 368 | file.Seek(0, SEEK_SET); | 370 | file.Seek(0, SEEK_SET); |
| 369 | if (1 != file.ReadArray<u32>(&magic, 1)) | 371 | if (1 != file.ReadArray<u32>(&magic, 1)) |
| 370 | return FileType::Error; | 372 | return FileType::Error; |
| 371 | 373 | ||
| 372 | if (MakeMagic('\x7f', 'E', 'L', 'F') == magic) | 374 | u16 machine = 0; |
| 375 | file.Seek(18, SEEK_SET); | ||
| 376 | if (1 != file.ReadArray<u16>(&machine, 1)) | ||
| 377 | return FileType::Error; | ||
| 378 | |||
| 379 | if (MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine) | ||
| 373 | return FileType::ELF; | 380 | return FileType::ELF; |
| 374 | 381 | ||
| 375 | return FileType::Error; | 382 | return FileType::Error; |