fix(relinker): accept only ET_EXEC, ET_DYN and the SCE dynamic ELF types as executable input #10401

Merged
roboterspinne merged 1 commit from upstream-pr/10401 into main 2026-10-26 21:54:17 +00:00
roboterspinne commented 2026-10-23 21:33:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-23T21:33:12Z.


What

RelinkerPipeline::Relink() rejected only ET_REL, ET_NONE and ET_CORE (RelinkerPipeline.cpp:62-67). Linux output therefore converted every other e_type, for example 5, 0x1234, 0xfe00, 0xfe01, 0xfe04 and 0xffff, with exit 0. Windows and macOS output (WindowsLoadImage.cpp:12) and guest modules (GuestImageReader.cpp:28) already use an allowlist. In the review of #5812, wachi35676 noted: "Linux output still accepts any other value (e.g. 5 or 0xFFFF convert), unlike the Windows/macOS allowlist; that could be a separate follow-up." This PR is that follow-up.

  • After the three named rejections, which keep their messages and their order, Relink() now rejects every type other than ET_EXEC (2), ET_DYN (3), 0xfe10 and 0xfe18 with Unsupported ELF object type 0x..: expected ET_EXEC, ET_DYN, 0xfe10 or 0xfe18 at offset 0x10 (RelinkerPipeline.cpp:69-73). This check runs before the Windows/macOS image check, so all three targets print the same message for these types. On main, Windows and macOS printed Windows output requires a position-independent ELF image.
  • Unchanged: ET_EXEC stays accepted on Linux, because #5812 uses it as a positive control. Windows and macOS still reject it in WindowsLoadImage. 0xfe10 and 0xfe18 convert as before on every target. The guest module reader and its allowlist are unchanged.
  • Rejected SCE types: 0xfe00 (ET_SCE_EXEC), 0xfe01 and 0xfe04 were already refused by the Windows and macOS targets. I know of no PS5 title that ships them: PS5 executables are 0xfe10 and modules are 0xfe18.

Tested

Ubuntu 24.04.5 x86_64, GCC 13.3, CMake 3.28, Python 3.13. Relinker-only Release build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Ninja). Synthetic fixtures only, no title or homebrew.

  • test_elf_header.py: the object_type_cases matrix now includes 5, 0x1234, 0xfe00, 0xfe01, 0xfe04 and 0xffff, across all six target modes (Linux, --windows, --to-intel, --macos and combinations) and unused-filter levels 0, 1 and 2. Each case expects exit 2, Unsupported ELF object type 0x.. and no output. 2, 3, 0xfe10 and 0xfe18 stay as positive controls.
  • Red on main (run at 6a740e702a; core/relinker is unchanged up to 11e8ad2934): elf_header fails at type-0-0-5, where the Linux output converts with exit 0.
  • Green on this branch, rebased on main 11e8ad2934: ctest --test-dir build -R '^(elf_header|dynamic_segment|input_magic)$' 3/3 passed (elf_header 1.3 s). ctest --test-dir build -j2 240/240 passed.
  • Merged with my other open pull requests (#10357, #10390, #10391) and fix/relinker-linux-load-bounds: no conflicts, ctest 241/241 passed. #10017 and #8076 also edit RelinkerPipeline.cpp, at line 346 and later; this patch applies cleanly on top of both PR heads.
  • python3 tools/check_conventions.py --base upstream/main with this title and description passed.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4989520819 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10401). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-10-23T21:33:12Z. --- ### What `RelinkerPipeline::Relink()` rejected only `ET_REL`, `ET_NONE` and `ET_CORE` (`RelinkerPipeline.cpp:62-67`). Linux output therefore converted every other `e_type`, for example 5, 0x1234, 0xfe00, 0xfe01, 0xfe04 and 0xffff, with exit 0. Windows and macOS output (`WindowsLoadImage.cpp:12`) and guest modules (`GuestImageReader.cpp:28`) already use an allowlist. In the review of #5812, wachi35676 noted: "Linux output still accepts any other value (e.g. 5 or 0xFFFF convert), unlike the Windows/macOS allowlist; that could be a separate follow-up." This PR is that follow-up. - After the three named rejections, which keep their messages and their order, `Relink()` now rejects every type other than `ET_EXEC` (2), `ET_DYN` (3), 0xfe10 and 0xfe18 with `Unsupported ELF object type 0x..: expected ET_EXEC, ET_DYN, 0xfe10 or 0xfe18` at offset 0x10 (`RelinkerPipeline.cpp:69-73`). This check runs before the Windows/macOS image check, so all three targets print the same message for these types. On `main`, Windows and macOS printed `Windows output requires a position-independent ELF image`. - Unchanged: `ET_EXEC` stays accepted on Linux, because #5812 uses it as a positive control. Windows and macOS still reject it in `WindowsLoadImage`. 0xfe10 and 0xfe18 convert as before on every target. The guest module reader and its allowlist are unchanged. - Rejected SCE types: 0xfe00 (`ET_SCE_EXEC`), 0xfe01 and 0xfe04 were already refused by the Windows and macOS targets. I know of no PS5 title that ships them: PS5 executables are 0xfe10 and modules are 0xfe18. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04.5 x86_64, GCC 13.3, CMake 3.28, Python 3.13. Relinker-only Release build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`, Ninja). Synthetic fixtures only, no title or homebrew. - `test_elf_header.py`: the `object_type_cases` matrix now includes 5, 0x1234, 0xfe00, 0xfe01, 0xfe04 and 0xffff, across all six target modes (Linux, `--windows`, `--to-intel`, `--macos` and combinations) and unused-filter levels 0, 1 and 2. Each case expects exit 2, `Unsupported ELF object type 0x..` and no output. 2, 3, 0xfe10 and 0xfe18 stay as positive controls. - Red on `main` (run at 6a740e702a; `core/relinker` is unchanged up to 11e8ad2934): `elf_header` fails at `type-0-0-5`, where the Linux output converts with exit 0. - Green on this branch, rebased on `main` 11e8ad2934: `ctest --test-dir build -R '^(elf_header|dynamic_segment|input_magic)$'` 3/3 passed (`elf_header` 1.3 s). `ctest --test-dir build -j2` 240/240 passed. - Merged with my other open pull requests (#10357, #10390, #10391) and `fix/relinker-linux-load-bounds`: no conflicts, `ctest` 241/241 passed. #10017 and #8076 also edit `RelinkerPipeline.cpp`, at line 346 and later; this patch applies cleanly on top of both PR heads. - `python3 tools/check_conventions.py --base upstream/main` with this title and description passed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-23 22:05:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T22:05:11Z.

Review: APPROVED


Reviewed the allowlist, preserved error ordering, synthetic matrix across output targets/filter levels, and reported positive controls. The check rejects unsupported e_type values before target-specific image handling while retaining ET_EXEC for Linux and the two SCE dynamic types. Hosted relinker matrix and conventions pass; product builds are skipped under repository policy. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5634936489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10401#pullrequestreview-5634936489). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T22:05:11Z. **Review:** APPROVED --- Reviewed the allowlist, preserved error ordering, synthetic matrix across output targets/filter levels, and reported positive controls. The check rejects unsupported e_type values before target-specific image handling while retaining ET_EXEC for Linux and the two SCE dynamic types. Hosted relinker matrix and conventions pass; product builds are skipped under repository policy. I found no blocking issue.
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!10401
No description provided.