fix(relinker): load a PT_SCE_RELRO segment that no PT_LOAD covers #4542
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4542"
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 saxopa on 2026-10-12T15:11:39Z.
What
The OpenOrbis
graphicssample (toolchain v0.5.4,samples/graphics) stops on currentmain(d592d54e) right after #4203. With--skip-sce-module --windows, and the same with--macos:The sample has
PT_SCE_RELRO(0x61000010,R) at 0x124000–0x134000, between the codePT_LOADand the dataPT_LOAD, and noPT_LOADcovers it. It holds the PLTGOT (0x130000), the init array (0x12a620) and the TLS image (0x12a798).SegmentFilterdrops the segment. Windows and macOS output then stop at the first relocation into it. Linux output finishes, but noPT_LOADmaps 0x124000–0x134000. In the synthetic test below,mainputs the relinker's extra block (RWX, 340 bytes) at the address of the dropped segment, with no error.ElfReader::ReadProgramHeadersnow reports aPT_SCE_RELROthat noPT_LOADcovers as a read-writePT_LOAD, so the Linux, Windows and macOS writers load it. Relocations need to write into it.PT_SCE_RELROinside aPT_LOAD(the PS5 layout usesPT_LOADRW plusPT_GNU_RELRO) is still skipped.PT_LOADthrowsPT_SCE_RELRO partially overlaps a PT_LOAD segment.The segment stays writable after relocation. FreeBSD rtld makes
PT_GNU_RELROread-only after relocation, and what the console does withPT_SCE_RELROis not checked. Both points are recorded in TechnicalDebt.Where the sample stops with this change (
--skip-sce-module, and the same with itssce_module):mainNot enough program header slots: need 10, available 9--windows,--macosELF address is not contained in PT_LOAD memory (offset 0x130000)Code analysis: overlapping instruction boundaries (offset 0xde39f)unused-filter=1Init/fini array is not file-backed (offset 0x12a620)On Linux the output program header table keeps the input count (9). On
mainthe sample already needsPT_GNU_EH_FRAMEdropped to fit, with the existing warning. With the segment loaded it needs 10, so it now fails with an explicit error instead of producing an image with unmapped data. Growing that table is a separate topic.The Windows and macOS code analysis stop is the "inline jump tables" item of #3093. The
unused-filter=1andunused-filter=2readers parse program headers themselves and are not changed here; this is recorded in TechnicalDebt.Tested
macOS 27 (Apple Silicon), relinker-only Release build.
sce_relro. It fails onmainand passes with the change.PT_SCE_RELROthat holds a RELATIVE-relocated pointer, relinked for Linux, Windows and macOS. The Linux output has one RWPT_LOADat 0x1000, size 0x1000, and the relocation(0x1000, 8, 0x210).PT_LOAD: no secondPT_LOAD.sce_module(libc.prx,libSceFios2.prx) converts without new errors. Not run: no x86-64 Linux or Windows host here.python3 tools/check_conventions.py --base origin/mainpasses;git diff --checkis clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt — none added.mdfiles or images added to the repository (attach them to this PR)