Skip to content

fix(relinker): stop code scans at the PLT for PS4 executables - #3142

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/carry-sce-scan-3093
Oct 11, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/carry-sce-scan-3093

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Limit syscall and import-call-site scans in PS4 executables with PT_SCE_DYNLIBDATA to executable code through the PLT, rather than decoding the read-only data that follows the code. If relocations require a PLT and no PLT can be located, the relinker reports an error instead of guessing.

Carried Get-fix's issue-linked commit from fix/relinker-scan-code-extent; the original commit author is preserved. The limitation in --to-intel and the unused-filter analyses remains documented in TechnicalDebt.

Tested

Linux, GCC 12.2, Release: dynamic_table_bounds and sce_code_extent pass on the combined validation branch. The full relinker-only suite was 104/105; the unrelated import_audit test fails because its test JSON has no source_commit in this environment. The source author reports the sce_code_extent regression, mutation checks, and byte-identical PS5 conversion checks passing; see #3093.

Windows 11, WinLibs GCC 15.2, Release, merged onto main d31b57a4: sce_code_extent and string_table_bounds pass. The only full-suite failure not present on plain main was agc_driver_dcc_keys_first_write, which the reporter bisected to #3158.

Checklist

  • Based on current main; no other open pull request implements this scan boundary
  • One topic per pull request
  • Conventions and diff checks pass; no code comments added
  • No silent stubs added
  • No investigation files or images added
  • No third-party code added
  • Generic behavior gated on PT_SCE_DYNLIBDATA
  • Depends on: none
  • AI-assisted: yes

…DYNLIBDATA

A PS4 executable (CUSA00900) keeps 37 MiB of read-only data in its
executable segment after the code. The syscall scan and the call-site
resolution decoded the whole segment linearly, reached a float table and
failed with "Unsupported 0F 79 opcode without SSE4A prefix". In
executables with a PT_SCE_DYNLIBDATA segment they now stop at the end of
the PLT that follows the last function of the unwind table. The PLT is
found by searching forward from that function for its first entry, which
pushes the GOT entry at PLTGOT + 8 and jumps through PLTGOT + 16, since
code without unwind entries can sit in between (680 bytes of start-up
code in an OpenOrbis-built sample). When the executable has PLT
relocations and no such entry follows, the relinker fails instead of
guessing. Executables without the segment are scanned as before.

(cherry picked from commit a21e8fe)

@Dextroid17 Dextroid17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review of #3141 covers both of these — they are one idea applied twice, since both are about what PT_SCE_DYNLIBDATA means for a PS4 executable. The part belonging to this one: limiting the code scan by the .eh_frame function extents and finding the PLT by its actual bytes (ff 35 … ff 25, with the two displacements landing at GOT+8 and GOT+16, and the search bounded to size - 16 so the whole 16-byte header stays in range) is the honest version of that scan. Requiring a located PLT when relocations need one, rather than guessing at an extent, is the piece I would single out — a wrong scan boundary fails silently, and an error does not.

Also from that review, and true of both: the import_audit failure is an environment difference (it wants a source_commit stamp that already exists on main, and fails when git cannot resolve HEAD for the audited root), and the mutation and byte-identical conversion checks belong to the source author in #3093, which is where both bodies attribute them.

Written with AI assistance.

@Silverash-i8

Copy link
Copy Markdown
Contributor

Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto main d31b57a in one build with #3213, #3159, #3158, #3142, #3141 and #2977, on an RTX 5060 Laptop and the Arrow Lake iGPU (ANYPS5_GPU=Intel).

  • string_table_bounds and sce_code_extent pass on Windows (they don't use the GPU).

In the full ctest of that build, the only failure not also on plain main is agc_driver_dcc_keys_first_write, which I bisected to #3158 alone (reported there).

AI-assisted (Claude Code); I ran this on my machine.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for checking the Windows build and distinguishing the sce_code_extent result from the unrelated #3158 failure. I added the Windows focused-test result and that full-suite context to the PR's Tested section.

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on Linux: relinker build + ctest 95/95, including sce_code_extent; the test fails when the pipeline change is reverted. Merges cleanly with #3141, and the TechnicalDebt line sits in the right section. Merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants