Write program headers at e_phoff #19906

Merged
Cri4Key opened 2:23pm on October 21, 2026 wanted to merge 4 Ξ” into rpcs3/rpcs3 master from
patch-1

Details

First broken build <img width="410" height="1222" alt="Image" src="https://github.com/user-attachments/assets/66a05ff1-d8df-41ac-ae52-cec46b8e95e3" />

Latest master build <img width="423" height="1226" alt="Image" src="https://github.com/user-attachments/assets/9c0bff34-ccc6-49e1-9842-46443bec253f" />

Last working build

v0.0.43.20353-5935028e

First broken build

v0.0.43.20354-b77d4a52

Attach 3 log files

LAST_WORKING_BUILD.log.gz FIRST_BROKEN_BUILD.log LATEST_MASTER_BUILD.log

I have attached all 3 required log files

Yes

Attach the RSX (.rrc) or RenderDoc (.rdc) capture files for visual issues

No response

System configuration

Ryzen 5 [email protected] 16GB DDR4 3200MHz RX 9060XT 16GB | Driver version 26.8.1 Windows 11 Pro Insider Preview Build 26100.ge_release.240331-1435

Diff Delta:
4
About 31 Diff Delta/hour
Classified as:  General

Cri4Key's Description of Work #19901 [Regression] LBP1 doesnt work on versions 0.0.43.20354 and above

WriteElf always wrote the program headers right after the ELF header, which only matches e_phoff set to 0x40. ELFs patched with SPRXPatcher have the table relocated to the end of the file, so the rebuilt ELF has no program headers at e_phoff and fails to load as of PR #19889

Write the program headers at the e_phoff value after the segment data and the section headers so that the segment data cannot overwrite it. Retail SELFs are unaffected (e_phoff is 0x40 and segment 0 already contains identical bytes).

Fixes #19901 (it affects LBP games patched with Refresher using SPRXPatcher in order to patch a dangerous multiplayer exploit and in general any ELF patched by SPRXPatcher), as long as the patched EBOOT provides a correct phdr_offset value (Refresher doesn't, but this is a fix on their tool, not on RPCS3. RPCS3 just needs to handle relocated program headers in order to support SPRXPatcher ELFs again).

Tested on both retail SELF and SPRXPatcher fSELF

1 total changed file
Loading changes...
Review complete πŸ’ͺ
You have reached the final β€œwhy is this here?”