fix(relinker): name the SELF container and the bytes read when the input is not an ELF #184

Merged
YossiYad merged 1 commit from upstream-pr/184 into main 2026-10-01 08:53:19 +00:00
YossiYad commented 2026-09-30 12:12:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-09-30T12:12:41Z.


What

ElfReader::ReadHeader tells the two kinds of wrong input apart instead of reporting "Invalid ELF magic number" for both:

  • A file starting with 4f 15 3d 1d is a SELF container. The message says so and that the relinker takes the decrypted ELF, which is the case behind #173 (the reporter's eboot.bin starts with exactly those bytes).
  • Any other non-ELF input has its first four bytes printed in the message, so a report carries the information without a separate hex dump.

test_input_magic.py covers the SELF magic, a \x7fCNT package header and a file shorter than the ELF header; it is registered next to the other Python relinker tests.

Closes #173

Tested

Linux (Ubuntu 24.04 container, GCC 13, Ninja, -DBUILD_TESTING=ON): full ctest passes (65 tests including the new one). Ran the relinker by hand on a 4 KB file with the SELF magic and on one with the \x7fCNT magic; both exit 2 with the new messages and no output file. Not tested on Windows.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4690289637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/184). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-09-30T12:12:41Z. --- ### What `ElfReader::ReadHeader` tells the two kinds of wrong input apart instead of reporting "Invalid ELF magic number" for both: - A file starting with `4f 15 3d 1d` is a SELF container. The message says so and that the relinker takes the decrypted ELF, which is the case behind #173 (the reporter's `eboot.bin` starts with exactly those bytes). - Any other non-ELF input has its first four bytes printed in the message, so a report carries the information without a separate hex dump. `test_input_magic.py` covers the SELF magic, a `\x7fCNT` package header and a file shorter than the ELF header; it is registered next to the other Python relinker tests. Closes #173 ### Tested Linux (Ubuntu 24.04 container, GCC 13, Ninja, `-DBUILD_TESTING=ON`): full `ctest` passes (65 tests including the new one). Ran the relinker by hand on a 4 KB file with the SELF magic and on one with the `\x7fCNT` magic; both exit 2 with the new messages and no output file. Not tested on Windows. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!184
No description provided.