fix(relinker): preserve GNU stack program headers #5305

Closed
Ondra97 wants to merge 1 commit from upstream-pr/5305 into main
Ondra97 commented 2026-10-13 16:49:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-13T16:49:47Z.


What

The broad OS-specific segment filter discarded PT_GNU_STACK, so converted executables lost the original stack permission request. Preserve this standard GNU header and its flags, as guest library conversion already does. The Linux ELF loader uses PF_X on this header to select stack execution permissions.

Tested

Windows, supported WinLibs GCC 15.2, Release full relinker-only build and 150/150 CTest tests passed. The new regression failed before the fix because neither stack header survived conversion. Both RW and RWX headers, their alignment and output program header order are checked. On x86-64 Linux the registered regression additionally executes a stack-written INT3: RW must fault with SIGSEGV, RWX must reach SIGTRAP. That native Linux check is delegated to CI; no Windows claim of Linux execution is made. No title run is claimed.

Local conventions and whitespace checks passed. Current open PRs were checked for overlapping files, lines and functions.

CI relinker builds and test suites passed on Linux, Windows and macOS for 391795961 (Build). Full runtime-library jobs were skipped by the automatic PR policy.

Combined local validation of #5283, #5286, #5298, #5302, #5305, #5308 and #5310 on main 61b8742b6: all seven patches merge without conflicts; the full relinker-only build and 150/150 CTest tests 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 (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

  • Unblocks: none

  • GPUs tested: n/a

  • AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846542932 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5305). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-13T16:49:47Z. --- ### What The broad OS-specific segment filter discarded PT_GNU_STACK, so converted executables lost the original stack permission request. Preserve this standard GNU header and its flags, as guest library conversion already does. The [Linux ELF loader](https://github.com/torvalds/linux/blob/v6.12/fs/binfmt_elf.c#L869-L874) uses PF_X on this header to select stack execution permissions. ### Tested Windows, supported WinLibs GCC 15.2, Release full relinker-only build and 150/150 CTest tests passed. The new regression failed before the fix because neither stack header survived conversion. Both RW and RWX headers, their alignment and output program header order are checked. On x86-64 Linux the registered regression additionally executes a stack-written INT3: RW must fault with SIGSEGV, RWX must reach SIGTRAP. That native Linux check is delegated to CI; no Windows claim of Linux execution is made. No title run is claimed. Local conventions and whitespace checks passed. Current open PRs were checked for overlapping files, lines and functions. CI relinker builds and test suites passed on Linux, Windows and macOS for `391795961` ([Build](https://github.com/boykopovar/AnyPS5/actions/runs/38434897100)). Full runtime-library jobs were skipped by the automatic PR policy. Combined local validation of #5283, #5286, #5298, #5302, #5305, #5308 and #5310 on main `61b8742b6`: all seven patches merge without conflicts; the full relinker-only build and 150/150 CTest tests 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](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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-13 23:28:14 +00:00 (Migrated from github.com)

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


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/relinker/tests/test_linux_program_header_order.py L108
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157370567 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5305#issuecomment-6157370567). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T23:28:14Z. --- <!-- 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/relinker/tests/test_linux_program_header_order.py` [L108](https://github.com/boykopovar/AnyPS5/blob/0b6d033b80083ca4468c38c4b7e88053eb238d01/core/relinker/relinker/tests/test_linux_program_header_order.py#L108) | | |
oneandonlydean commented 2026-10-14 05:36:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:36:31Z.


Closing: none of the 14 retail executables we checked carries PT_GNU_STACK, so this changes no converted title, and with the queue this high we only take converter changes a real file needs. Reopen with the title or file that hits it on current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161698163 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5305#issuecomment-6161698163). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:36:31Z. --- Closing: none of the 14 retail executables we checked carries PT_GNU_STACK, so this changes no converted title, and with the queue this high we only take converter changes a real file needs. Reopen with the title or file that hits it 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!5305
No description provided.