Repository navigation
fix(relinker): keep code analysis inside the code extent of PS4 executables - #5195
Merged
oneandonlydean merged 1 commit intoOct 14, 2026
Conversation
10 tasks done
…tables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SandstromPL
force-pushed
the
fix/relinker-sce-code-analysis-extent
branch
from
October 13, 2026 14:43
1ed2915 to
78f620c
Compare
Contributor
|
Windows test: head AI-assisted (Claude Code). |
Contributor
Author
|
Thanks for testing on Windows! The head you tested ( |
12 tasks done
5 of 29 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This is the #3093 item "Keep code analysis inside the code extent and out of PT_INTERP. The CFG followed pointers into
/libexec/ld-elf.so.1." It was found in Get-fix's experimental run of the OpenOrbisgraphicssample (#3094).The code analysis that the Windows TLS builder and the macOS image run (
CodeInstructionCollector) treats every byte of an executablePT_LOADas code. In the PS4 layout that segment also holds thePT_INTERPstring before the code and read-only data after the PLT. A pointer into either becomes a code root and is decoded, for example anR_X86_64_RELATIVEaddend or a REX.W rip-relativeleatarget:/libexec/ld-elf.so.1can decode into an fs-prefixed instruction (64 2d 65 6c 66 2e, the "d-elf."), and the conversion fails withUnsupported Windows guest TLS instruction(macOS:Unsupported macOS guest TLS instruction); the error depends on the bytes after the string;Code analysis: overlapping instruction boundaries.For executables and guest modules with
PT_SCE_DYNLIBDATA, the code analysis now follows code only from the end ofPT_INTERPto the end of the PLT after the last function of the unwind table. The end is the one #3142 gave the syscall and import call-site scans. #3142's PLT search moves unchanged into one helper (FindSceCodeEnd) that the pipeline and the code analysis share. A guest module in this layout with PLT relocations and no PLT after its last unwind function now fails the same way the executable does. The narrowed headers are used only to decide what is code; data is still read through the original headers. Executables withoutPT_SCE_DYNLIBDATAare not changed. A new debt entry, next to #3142's, records the code analysis extent and what it means for code after the PLT: that code is not analyzed, and a function symbol or init/fini array entry pointing into it fails. It is a separate line so that it does not touch #4717's neighbouring entry.Linux is not affected: its patcher does not run the code analysis.
Tested
Ubuntu 24.04, GCC 13.3, relinker-only build with
BUILD_TESTING=ON: 153/153 tests pass.test_sce_code_extent.pygains two cases, each converted with--windowsand with--macos:sce-interpreter-pointer: aPT_INTERPwith/libexec/ld-elf.so.1in front of the function, and a RELATIVE relocation pointing at it.sce-data-pointer-after-plt: a REX.Wleainto read-only data after the PLT whose bytes decode as overlapping instructions.On main they fail with
Unsupported Windows guest TLS instruction (bytes: 64 2d 65 6c 66 2e)/Unsupported macOS guest TLS instruction (...)and withCode analysis: overlapping instruction boundaries. They pass here. The interpreter case usesgap=0x60so that the bytes after the string decode into the fs-prefixed instruction.A third case,
sce-code-before-plt, places an unsupported fs-prefixed instruction at the entry point between the last unwind function and the PLT. Relinker rejects PS4 executables: SCE dynamic tables and data in the code segment (two ready branches) + remaining PS4 work #3093 notes that the OpenOrbis sample has 680 bytes of start-up code there. It must still fail with the TLS error, which shows that code is still analyzed. It passes on main as well. The four existing cases still pass.Each part is needed:
PT_INTERPlower bound, the interpreter cases fail.PT_SCE_DYNLIBDATAgate,tls_function_coverage_metadataandtls_function_coverage_paddingfail.Inputs without
PT_SCE_DYNLIBDATAconvert byte-identically on main and on this branch:--to-intel×unused-filter=0and1(264 conversions).The OpenOrbis sample was not run here. After fix(relinker): load a PT_SCE_RELRO segment that no PT_LOAD covers #4542 it stops on Windows and macOS at
Code analysis: overlapping instruction boundaries (offset 0xde39f), which fix(relinker): load a PT_SCE_RELRO segment that no PT_LOAD covers #4542 attributes to the inline jump tables item. Whether this PR moves that stop is not known.tools/check_conventions.pyfrom main passes with this title and body.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)🤖 Generated with Claude Code