fix(tools): read a PS4 executable's dynamic table from its library data segment in unwrap_self #19959

Merged
Gag21 merged 1 commit from upstream-pr/19959 into main 2026-11-15 13:46:27 +00:00
Gag21 commented 2026-11-14 09:42:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gag21 on 2026-11-14T09:42:13Z.


What

A PS4 executable keeps PT_DYNAMIC without a vaddr, inside PT_SCE_DYNLIBDATA. unwrap_self.py placed every PT_DYNAMIC by the vaddr-to-file mapping of a PT_LOAD, so for these files it pointed the dynamic table at the start of the first load segment, and the relinker stopped with Unterminated dynamic segment (offset 0x4000). A PT_DYNAMIC without a vaddr whose stale range lies inside a recorded segment without a vaddr is now read from that segment. A PT_DYNAMIC at vaddr zero inside a load segment is placed as before.

Tested

Windows 11, Python 3.14.0: python -m unittest test_unwrap_self from tools/tests runs 92 tests, OK (3 skipped); the new test fails on main. On a PS4 title's executable and its bundled libc.prx (CUSA01709, my own dump, no game files shared) the dynamic table now lands at its offset inside PT_SCE_DYNLIBDATA, and relinker --dry-run passes the dynamic-segment check and stops later at Undefined non-weak symbol has non-default visibility, which #17105 covers. python tools/check_conventions.py --base origin/main passes; python tools/pr_overlap.py --branch reports no overlap. Not run on Linux or macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5309824083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19959). Originally posted by [Gag21](https://github.com/Gag21) on 2026-11-14T09:42:13Z. --- ### What A PS4 executable keeps `PT_DYNAMIC` without a vaddr, inside `PT_SCE_DYNLIBDATA`. `unwrap_self.py` placed every `PT_DYNAMIC` by the vaddr-to-file mapping of a `PT_LOAD`, so for these files it pointed the dynamic table at the start of the first load segment, and the relinker stopped with `Unterminated dynamic segment (offset 0x4000)`. A `PT_DYNAMIC` without a vaddr whose stale range lies inside a recorded segment without a vaddr is now read from that segment. A `PT_DYNAMIC` at vaddr zero inside a load segment is placed as before. ### Tested Windows 11, Python 3.14.0: `python -m unittest test_unwrap_self` from `tools/tests` runs 92 tests, OK (3 skipped); the new test fails on `main`. On a PS4 title's executable and its bundled `libc.prx` (CUSA01709, my own dump, no game files shared) the dynamic table now lands at its offset inside `PT_SCE_DYNLIBDATA`, and `relinker --dry-run` passes the dynamic-segment check and stops later at `Undefined non-weak symbol has non-default visibility`, which #17105 covers. `python tools/check_conventions.py --base origin/main` passes; `python tools/pr_overlap.py --branch` reports no overlap. Not run on Linux or macOS. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!19959
No description provided.