fix(relinker): put extra PT_LOAD on a fresh page #4919

Closed
MarcZX10 wants to merge 1 commit from upstream-pr/4919 into main
MarcZX10 commented 2026-10-13 04:10:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T04:10:10Z.


What

Fixes #4913. Carries Leandro Soares's c3aa504ab commit and preserves his original commit authorship. The relinker's extra RWX PT_LOAD now starts on a fresh page above the highest guest segment, so its mapping cannot replace the last page of a guest segment when that segment ends in the middle of a page.

Adds the two reported range cases while keeping the existing layout expectation.

Tested

Linux, GCC 12.2, Release, relinker-only build:

  • program_layout_ranges: passed (1/1).
  • Full relinker-only CTest excluding progress_history: passed (142/142).
  • tools/check_conventions.py --base upstream/main: passed.
  • git diff --check upstream/main...HEAD: passed.

The unfiltered 143-test run passed 142 tests. progress_history fails in the local Python 3.11.2 because tarfile.TarFile.extractall() does not accept the filter argument used by that test; this is unrelated to the relinker change. No real title was relinked in this session.

  • The initial hosted conventions run reported an incomplete template field; the current title and body pass the local template check.

Checklist

  • Based on current main; no open pull request implements the same change
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes or investigation files added to the repository
  • No new third-party code
  • Generic behavior, not title-specific
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4838237242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4919). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T04:10:10Z. --- ### What Fixes #4913. Carries Leandro Soares's `c3aa504ab` commit and preserves his original commit authorship. The relinker's extra RWX `PT_LOAD` now starts on a fresh page above the highest guest segment, so its mapping cannot replace the last page of a guest segment when that segment ends in the middle of a page. Adds the two reported range cases while keeping the existing layout expectation. ### Tested Linux, GCC 12.2, Release, relinker-only build: - `program_layout_ranges`: passed (1/1). - Full relinker-only CTest excluding `progress_history`: passed (142/142). - `tools/check_conventions.py --base upstream/main`: passed. - `git diff --check upstream/main...HEAD`: passed. The unfiltered 143-test run passed 142 tests. `progress_history` fails in the local Python 3.11.2 because `tarfile.TarFile.extractall()` does not accept the `filter` argument used by that test; this is unrelated to the relinker change. No real title was relinked in this session. - The initial hosted conventions run reported an incomplete template field; the current title and body pass the local template check. ### Checklist - [x] Based on current `main`; no open pull request implements the same change - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes or investigation files added to the repository - [x] No new third-party code - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 09:27:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T09:27:58Z.


Windows test: head a5758f12f merged onto current main 2a2a3dc65 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest -R ^program_layout_ranges$ passed (1 of 1); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142520843 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4919#issuecomment-6142520843). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T09:27:58Z. --- Windows test: head `a5758f12f` merged onto current `main` `2a2a3dc65` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; `ctest -R ^program_layout_ranges$` passed (1 of 1); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-13 23:25:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T23:25:41Z.


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
#5543 core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp L123-130, L132-145
core/relinker/elfpatcher/tests/ProgramLayoutRangeTests.cpp L24, L49
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157338584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4919#issuecomment-6157338584). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T23:25:41Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #5543 | `core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp` [L123-130](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp#L123-L130), [L132-145](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp#L132-L145)<br>`core/relinker/elfpatcher/tests/ProgramLayoutRangeTests.cpp` [L24](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/relinker/elfpatcher/tests/ProgramLayoutRangeTests.cpp#L24), [L49](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/relinker/elfpatcher/tests/ProgramLayoutRangeTests.cpp#L49) | | |
MarcZX10 commented 2026-10-13 23:27:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T23:27:06Z.


The overlap check now includes #5543, which addresses the same extra-PT_LOAD page-placement issue and adds broader structural and end-to-end regression coverage. These two changes should not be merged together; #5543 is the more complete candidate. I am leaving this PR open, but calling out the duplicate so the merge order is clear.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157356389 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4919#issuecomment-6157356389). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T23:27:06Z. --- The overlap check now includes #5543, which addresses the same extra-PT_LOAD page-placement issue and adds broader structural and end-to-end regression coverage. These two changes should not be merged together; #5543 is the more complete candidate. I am leaving this PR open, but calling out the duplicate so the merge order is clear.
oneandonlydean commented 2026-10-14 02:33:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:33:24Z.


Closing: same change as #5543, which fixes the same extra PT_LOAD placement with wider tests and is further along.
Reopen if something here is still missing on current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159592987 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4919#issuecomment-6159592987). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:33:24Z. --- Closing: same change as #5543, which fixes the same extra PT_LOAD placement with wider tests and is further along. Reopen if something here is still missing on current main.

Pull request closed

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!4919
No description provided.