fix(relinker): rebase the grown Linux program header table #6403

Closed
MarcZX10 wants to merge 1 commit from upstream-pr/6403 into main
MarcZX10 commented 2026-10-15 14:09:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T14:09:58Z.


What

  • Rebase the program header table at the output tableOff, which may differ from the input phOff when the output table grows.
  • Add a fixed-base regression fixture with too few input table slots and verify the moved output table's entry maps to a rebased PT_LOAD.
  • Fixes #6393.

Tested

  • Linux x86-64: relinker-only Release build completed.
  • python3 core/relinker/relinker/tests/test_linux_fixed_base.py /tmp/AnyPS5-6393-build/core/relinker/relinker passed.
  • The new regression fails against the unmodified main binary (0x401118 is unmapped).
  • python3 tools/check_conventions.py --base upstream/main and git diff --check passed.

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 or are documented; not applicable
  • No notes, investigation .md files or images added
  • New third-party code is a submodule built from source; not applicable
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4874624062 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T14:09:58Z. --- ### What - Rebase the program header table at the output `tableOff`, which may differ from the input `phOff` when the output table grows. - Add a fixed-base regression fixture with too few input table slots and verify the moved output table's entry maps to a rebased PT_LOAD. - Fixes #6393. ### Tested - Linux x86-64: relinker-only Release build completed. - `python3 core/relinker/relinker/tests/test_linux_fixed_base.py /tmp/AnyPS5-6393-build/core/relinker/relinker` passed. - The new regression fails against the unmodified main binary (`0x401118` is unmapped). - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` passed. ### 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 - [x] Unimplemented paths throw or are documented; not applicable - [x] No notes, investigation `.md` files or images added - [x] New third-party code is a submodule built from source; not applicable - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 14:23:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T14:23:27Z.


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 6224 core/relinker/relinker/tests/test_linux_fixed_base.py L34, L37

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6447 core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194385796 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403#issuecomment-6194385796). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T14:23:27Z. --- <!-- 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 | |---|---|---|---| | [PR 6224](https://www.github.com/boykopovar/AnyPS5/pull/6224) | `core/relinker/relinker/tests/test_linux_fixed_base.py` [L34](https://github.com/boykopovar/AnyPS5/blob/f26eb67c89bfe8a06ccfb51cc6e64dde03a099c2/core/relinker/relinker/tests/test_linux_fixed_base.py#L34), [L37](https://github.com/boykopovar/AnyPS5/blob/f26eb67c89bfe8a06ccfb51cc6e64dde03a099c2/core/relinker/relinker/tests/test_linux_fixed_base.py#L37) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp` |
MarcZX10 commented 2026-10-15 15:03:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T15:03:30Z.


I rebased the focused #6393 fix commit onto current main and removed the old parent history from the PR branch. The current-main Release relinker build and test_linux_fixed_base.py pass; the relocated-table regression confirms the entry is mapped at the fixed base. Conventions and git diff --check also pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195244956 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403#issuecomment-6195244956). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T15:03:30Z. --- I rebased the focused #6393 fix commit onto current main and removed the old parent history from the PR branch. The current-main Release relinker build and `test_linux_fixed_base.py` pass; the relocated-table regression confirms the entry is mapped at the fixed base. Conventions and `git diff --check` also pass.
saxopa commented 2026-10-16 14:20:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by saxopa on 2026-10-16T14:20:56Z.


Ran this on a real x86-64 kernel (QEMU system emulation, Linux 6.6.134, Ubuntu 24.04 glibc), with the fixture from this PR's test_linux_fixed_base.py, relinker-only builds of main 82ddae75b and this branch:

output main this PR
6 slots, --linux-fixed-base SIGTRAP (expected) SIGTRAP
3 slots (table moves), --linux-fixed-base SIGSEGV SIGTRAP

So the moved-table case crashes at start on main and runs at the base with this change. The new test case only inspects the file; running grown_path next to fixed_path in the Linux execution block would cover the crash itself.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217535650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403#issuecomment-6217535650). Originally posted by [saxopa](https://github.com/saxopa) on 2026-10-16T14:20:56Z. --- Ran this on a real x86-64 kernel (QEMU system emulation, Linux 6.6.134, Ubuntu 24.04 glibc), with the fixture from this PR's `test_linux_fixed_base.py`, relinker-only builds of `main` 82ddae75b and this branch: | output | `main` | this PR | |---|---|---| | 6 slots, `--linux-fixed-base` | SIGTRAP (expected) | SIGTRAP | | 3 slots (table moves), `--linux-fixed-base` | SIGSEGV | SIGTRAP | So the moved-table case crashes at start on `main` and runs at the base with this change. The new test case only inspects the file; running `grown_path` next to `fixed_path` in the Linux execution block would cover the crash itself. AI-assisted: yes (Claude Code).
MarcZX10 commented 2026-10-16 15:34:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:34:35Z.


Thanks for the QEMU execution comparison. It confirms the moved-table fixture reaches the runtime failure on main and no longer crashes with this fix. The adjacent grown_path execution check is a useful addition to make that behavior part of CI; I have not changed the PR yet because #6224 already carries the overlapping moved-table regression.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218952415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403#issuecomment-6218952415). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:34:35Z. --- Thanks for the QEMU execution comparison. It confirms the moved-table fixture reaches the runtime failure on main and no longer crashes with this fix. The adjacent `grown_path` execution check is a useful addition to make that behavior part of CI; I have not changed the PR yet because #6224 already carries the overlapping moved-table regression.
MarcZX10 commented 2026-10-16 20:01:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T20:01:45Z.


Thanks for the QEMU runtime check. It confirms the moved-table input crashes on main and reaches the fixed base with this change. Your suggested grown_path execution check would make that runtime behavior part of CI. I have not added it because #6224 and #6447 also carry the same table-offset fix; I’ll leave this PR open and avoid duplicating their test changes pending consolidation guidance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223646678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403#issuecomment-6223646678). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T20:01:45Z. --- Thanks for the QEMU runtime check. It confirms the moved-table input crashes on main and reaches the fixed base with this change. Your suggested `grown_path` execution check would make that runtime behavior part of CI. I have not added it because #6224 and #6447 also carry the same table-offset fix; I’ll leave this PR open and avoid duplicating their test changes pending consolidation guidance.
oneandonlydean commented 2026-10-17 00:10:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:10:27Z.


Closing in favour of #6224, which has the same tableOff fix and now carries this PR's three-slot fixture (folded in 2cf75dbbf), as you offered on the 15th.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227129656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6403#issuecomment-6227129656). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T00:10:27Z. --- Closing in favour of #6224, which has the same `tableOff` fix and now carries this PR's three-slot fixture (folded in 2cf75dbbf), as you offered on the 15th.

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