Skip to content

fix(relinker): reject a second PT_DYNAMIC segment - #10403

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
roboterspinne:fix/relinker-reject-second-pt-dynamic
Oct 26, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
roboterspinne:fix/relinker-reject-second-pt-dynamic

Conversation

@roboterspinne

Copy link
Copy Markdown
Contributor

What

The PT_DYNAMIC loop in RelinkerPipeline::Relink() took the first header and stopped (break, RelinkerPipeline.cpp:109 on main), so Linux output silently ignored a second PT_DYNAMIC and converted with exit 0. The other readers already refuse it: RelativeRelocationIndex.cpp:172 throws Multiple PT_DYNAMIC segments and guest modules fail with Duplicate dynamic segment (GuestImageReader.cpp:52).

  • A second PT_DYNAMIC now fails with Multiple PT_DYNAMIC segments at its file offset (RelinkerPipeline.cpp:106-107), the wording RelativeRelocationIndex.cpp:172 already uses. The check is in the pipeline, so all targets report it.
  • On main, Windows and macOS failed later with Code analysis: invalid dynamic segment (CodeInstructionCollector.cpp:74) and now report the pipeline message.
  • Unchanged: a single PT_DYNAMIC is read as before, and a missing one still fails with No PT_DYNAMIC segment found.

Tested

Ubuntu 24.04.5 x86_64, GCC 13.3, CMake 3.28, Python 3.13. Relinker-only Release build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Ninja). Synthetic fixtures only, no title or homebrew.

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 (Claude Code)

The PT_DYNAMIC loop used the first header and ignored any later one, so
the Linux target converted an input with two PT_DYNAMIC headers. A
second PT_DYNAMIC now fails with "Multiple PT_DYNAMIC segments" at its
file offset on every target.
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10561 core/relinker/relinker/tests/test_dynamic_segment.py L25, L28-29, L74

@roboterspinne

Copy link
Copy Markdown
Contributor Author

Checked manually: #8076 changes RelinkerPipeline.cpp from line 374 on; this PR changes lines 103-110. No overlap.

@MarcZX10 MarcZX10 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.

Reviewed the three-line guard and the duplicate-header fixture. The pipeline now applies the same multiple-segment rejection already used for PT_SCE_DYNLIBDATA, and the test checks Linux, Windows, and macOS diagnostics plus no output. The hosted relinker matrix and conventions checks pass; full Linux and Windows product jobs are skipped by the repository workflow. No blocking issue found.

@MarcZX10 MarcZX10 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.

Reviewed the duplicate-header check and its regression fixture. The loop now rejects a second PT_DYNAMIC with the existing diagnostic before replacing the first segment’s tags, and the new fixture exercises Linux, Windows, and macOS output modes. The reported 240/240 focused suite and 241/241 combined suite cover the change; hosted relinker jobs for Linux, Windows, macOS arm64, macOS x86_64, and ASan also pass. I found no blocking issue.

@oneandonlydean oneandonlydean self-assigned this Oct 25, 2026
@oneandonlydean
oneandonlydean merged commit 98891b5 into boykopovar:main Oct 26, 2026
13 checks passed
@roboterspinne
roboterspinne deleted the fix/relinker-reject-second-pt-dynamic branch October 26, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants