fix(relinker): accept only ET_EXEC, ET_DYN and the SCE dynamic ELF types as executable input #10401
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10401"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-23T21:33:12Z.
What
RelinkerPipeline::Relink()rejected onlyET_REL,ET_NONEandET_CORE(RelinkerPipeline.cpp:62-67). Linux output therefore converted every othere_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.Relink()now rejects every type other thanET_EXEC(2),ET_DYN(3), 0xfe10 and 0xfe18 withUnsupported ELF object type 0x..: expected ET_EXEC, ET_DYN, 0xfe10 or 0xfe18at 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. Onmain, Windows and macOS printedWindows output requires a position-independent ELF image.ET_EXECstays accepted on Linux, because #5812 uses it as a positive control. Windows and macOS still reject it inWindowsLoadImage. 0xfe10 and 0xfe18 convert as before on every target. The guest module reader and its allowlist are unchanged.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: theobject_type_casesmatrix now includes 5, 0x1234, 0xfe00, 0xfe01, 0xfe04 and 0xffff, across all six target modes (Linux,--windows,--to-intel,--macosand 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.main(run at6a740e702a;core/relinkeris unchanged up to11e8ad2934):elf_headerfails attype-0-0-5, where the Linux output converts with exit 0.main11e8ad2934:ctest --test-dir build -R '^(elf_header|dynamic_segment|input_magic)$'3/3 passed (elf_header1.3 s).ctest --test-dir build -j2240/240 passed.fix/relinker-linux-load-bounds: no conflicts,ctest241/241 passed. #10017 and #8076 also editRelinkerPipeline.cpp, at line 346 and later; this patch applies cleanly on top of both PR heads.python3 tools/check_conventions.py --base upstream/mainwith this title and description passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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.