fix(relinker): read SCE dynamic tables from PT_SCE_DYNLIBDATA #3141
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3141"
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 MarcZX10 on 2026-10-10T22:58:48Z.
What
Read
DT_SCE_*dynamic-table values relative toPT_SCE_DYNLIBDATAwhen that PS4 segment is present, while preserving the current file-offset behavior for executables without it. The parser rejects a table range that extends beyond the input file and rejects duplicatePT_SCE_DYNLIBDATAsegments instead of silently choosing the last base.Carried Get-fix's issue-linked commit from
fix/relinker-sce-dynamic-tables; the original commit author is preserved. Theunused-filter=1andunused-filter=2readers remain documented as follow-up work.Tested
Linux, GCC 12.2, Release: the relinker-only build and all 105 CTests pass, including the arithmetic overflow, out-of-file table, and duplicate-segment cases. Conventions and
git diff --checkpass.Windows 11, WinLibs GCC 15.2, Release, on updated head
16adcd48merged onto currentmain:string_table_bounds,elf_header,elf_offsets,windows_import_modules, andguest_elf_phdr_matchpass. The non-GPU suite is 420/421;guest_filesystemalso fails on plainmainon that host because it lacks symlink privilege (#3169).Checklist
main; no other open pull request implements this PS4 table handlingPT_SCE_DYNLIBDATAImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T23:19:00Z.
Review: COMMENTED
Two PRs from one carried branch, both about the same thing: what
PT_SCE_DYNLIBDATAmeans for a PS4 executable. Read together they are one idea — that segment defines a block whose offsets are relative to it — applied to the dynamic-table base and to the code scan.#3141, the table base. Reading
DT_SCE_*relative toPT_SCE_DYNLIBDATAwhen the segment is present, and keeping file offsets when it is not, is the difference between a PS4 executable's tables resolving and everything downstream resolving to the wrong place, so the shape is right. Guarding the addition against overflow is the correct check to have first, and the range checks further down (Dynamic string table is out of boundsand its siblings) still bound the result against the file, so between them they cover both halves. The one thing I would change is the message: "outside the file" is only what the overflow path tests, and naming the arithmetic it actually guards would read truer. Also, the base is taken from the lastPT_SCE_DYNLIBDATAseen; if more than one is legal, a uniqueness requirement would match therequireExactlyOneOfshape used elsewhere in this file.#3142, the code scan. Limiting the scan by the
.eh_framefunction extents and finding the PLT by its actual bytes is the honest version of this: the pattern you look for —ff 35…ff 25with the two displacements landing at GOT+8 and GOT+16 — is the real PLT0/PLT1 pair, and bounding the search tosize - 16keeps the whole 16-byte header in range. Requiring a located PLT when relocations need one, rather than guessing at an extent, is the part I would single out: a wrong scan boundary is silent, and an error is not.On the test result both descriptions mention. The single failing test,
import_audit, expects asource_commitstamp that already exists onmain, and it fails when git cannot resolveHEADfor the audited root — so it is an environment difference rather than anything in these branches, which is what both descriptions say and the right reason to give. The mutation and byte-identical conversion checks are attributed in both bodies to the source author in #3093, which is also the right place for them.And the provenance is handled properly in both — Get-fix's issue-linked commits carried with authorship intact, and the remaining limitations in
--to-inteland theunused-filterreaders left documented rather than quietly widened by the new scan boundary.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:51:18Z.
Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto
maind31b57a4in 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_boundsandsce_code_extentpass on Windows (they don't use the GPU).In the full
ctestof that build, the only failure not also on plainmainisagc_driver_dcc_keys_first_write, which I bisected to #3158 alone (reported there).AI-assisted (Claude Code); I ran this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T03:30:52Z.
I addressed both review suggestions in
16adcd487(fix(relinker): validate SCE dynamic data segment). The offset error now names the arithmetic it checks, and the tests distinguish addition overflow from a non-overflowing out-of-file table. The parser also rejects a secondPT_SCE_DYNLIBDATAinstead of silently replacing the first base; the documented PS4 ELF layout lists a single segment. The relinker-only Release build and all 105 CTests pass on currentmain, including the new overflow and duplicate-segment cases. Conventions andgit diff --checkpass.Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T03:37:56Z.
Windows check of the updated head
16adcd48(merged onto currentmain, Windows 11, WinLibs GCC 15.2.0 r7, Release):string_table_boundspasses with the new overflow and duplicate-segment cases, along withelf_header,elf_offsets,windows_import_modulesandguest_elf_phdr_match.The whole non-GPU suite (
ctest -E "^agc_") is 420/421; the one failure isguest_filesystem, which needs the symlink privilege on Windows (#3169) and fails the same way onmainhere.AI-assisted (Claude Code); I ran this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T03:44:15Z.
Thanks for rerunning the updated head on Windows and for separating the unrelated symlink-privilege failure from this change. I added the passing
string_table_boundsand adjacent ELF checks, plus the 420/421 non-GPU suite result and its plain-mainguest_filesystemlimitation, to the Tested section.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:15:53Z.
Checked the new
string_table_boundscases (tables in the SCE block, addition overflow, out-of-file table, duplicate segment); they fail without the change and pass with it. The relinker build and ctest are green locally, and Windows was confirmed by @Silverash-i8; merging once CI is green.