From 9fce570e95a88fbffae5d99f5bd9944d726472ad Mon Sep 17 00:00:00 2001 From: Dextroid17 <217507631+Dextroid17@users.noreply.github.com> Date: Wed, 7 Oct 2026 19:28:04 -0400 Subject: [PATCH] fix(relinker): name the second SELF container magic as a SELF input ElfReader::ReadHeader names 0x1D3D154F as a SELF container, but dumps also carry a second container magic, 0xEEF51454 (bytes 54 14 f5 ee), which fell through to "Invalid ELF magic number: 54 14 f5 ee". That message reads as a corrupt input rather than an encrypted one, so a user cannot tell that decryption is what stands between them and a relink. Both magics now report the SELF message. Measured on two retail dumps: PPSA03671's eboot.bin and libcohtml.Prospero.prx are 54 14 f5 ee; PPSA28997's eboot and modules are 4f 15 3d 1d. Tested: Linux (CachyOS, GCC, Release, BUILD_TESTING=ON), relinker rebuilt. The new case fails on the revert of the reader change with the exact message above and passes with it; elf_header, elf_offsets, dynamic_segment, string_table_bounds, guest_needed_modules, guest_module_directories and linux_load_alignment still pass. --- core/relinker/relinker/src/parsing/ElfReader.cpp | 3 ++- core/relinker/relinker/tests/test_input_magic.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/relinker/relinker/src/parsing/ElfReader.cpp b/core/relinker/relinker/src/parsing/ElfReader.cpp index 8401513b1..da17ce5ad 100644 --- a/core/relinker/relinker/src/parsing/ElfReader.cpp +++ b/core/relinker/relinker/src/parsing/ElfReader.cpp @@ -74,7 +74,8 @@ ElfHeader ElfReader::ReadHeader() const { throw RelinkerException("File too small for ELF header"); } - if (_fileBuffer[0] == 0x4f && _fileBuffer[1] == 0x15 && _fileBuffer[2] == 0x3d && _fileBuffer[3] == 0x1d) { + const std::uint32_t magic = _readU32At(0); + if (magic == 0x1d3d154f || magic == 0xeef51454) { throw RelinkerException("The input is a SELF container, not an ELF"); } diff --git a/core/relinker/relinker/tests/test_input_magic.py b/core/relinker/relinker/tests/test_input_magic.py index 348df5b15..e388e2d81 100644 --- a/core/relinker/relinker/tests/test_input_magic.py +++ b/core/relinker/relinker/tests/test_input_magic.py @@ -20,6 +20,7 @@ def main(): assert result.returncode == 2 and error in result.stderr and not output.exists(), (name, result) convert("eboot.self", b"\x4f\x15\x3d\x1d" + bytes(0x1000), "The input is a SELF container, not an ELF") + convert("eboot.self.kernel", b"\x54\x14\xf5\xee" + bytes(0x1000), "The input is a SELF container, not an ELF") convert("eboot.pkg", b"\x7fCNT" + bytes(0x1000), "Invalid ELF magic number: 7f 43 4e 54") convert("eboot.short", b"\x7fEL", "File too small for ELF header") print("Input magic diagnostics tests passed")