test(relinker): keep the guest_module_args fixture's GOT out of executable memory #5362

Merged
thuanquang merged 1 commit from upstream-pr/5362 into main 2026-10-14 18:58:31 +00:00
thuanquang commented 2026-10-13 18:00:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-13T18:00:12Z.


What

guest_module_args fails when its macOS branch runs, which needs an x86-64 Python on macOS (an Intel Mac, or Rosetta 2 on Apple silicon). The relinker job runs on macos-latest with an arm64 Python, so CI skips that branch.

OSError: dlopen(.../macos/app0/sce_module/args.prx.guest.prx, 0x0006): tried: '.../args.prx.guest.prx' (BIND_OPCODE_DO_BIND pointer bind is in executable segment '__ELF0')

The fixture module is a single RWX PT_LOAD, so its GOT slot (0x2820) lands in executable memory and the converted Mach-O binds RecordArgs into __ELF0 (initprot 7). dyld on macOS 27.0.1 refuses that bind. The relinker built at 1b865fc3 (#3492, which added this branch) fails the same way here, so this is the host, not a later change.

The fixture now has an RX code segment (0x0–0x2000) and an RW data segment (0x2000–0x3000: dynamic section, tables and GOT), as modules are laid out. Only the test changes.

Tested

macOS 27.0.1 on Apple silicon with Rosetta 2, relinker-only Release builds of main 18c438b10:

  • x86-64 build (-DCMAKE_OSX_ARCHITECTURES=x86_64) with an x86-64 Python (arch -x86_64 /usr/bin/python3): guest_module_args fails on main with the error above and passes with this change; the macOS branch loads the module and checks the recorded args/argp and the returned result.
  • arm64 build and Python: passes before and after (structure checks only).
  • Full relinker suite, both builds: every test passes except three that also fail on main on this machine (pr_overlap_encoding, progress_history, stubgen_stdout_newlines).

The Linux branch, which loads the same fixture with ld.so, was not run here.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4847352691 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5362). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-13T18:00:12Z. --- ### What `guest_module_args` fails when its macOS branch runs, which needs an x86-64 Python on macOS (an Intel Mac, or Rosetta 2 on Apple silicon). The relinker job runs on `macos-latest` with an arm64 Python, so CI skips that branch. ``` OSError: dlopen(.../macos/app0/sce_module/args.prx.guest.prx, 0x0006): tried: '.../args.prx.guest.prx' (BIND_OPCODE_DO_BIND pointer bind is in executable segment '__ELF0') ``` The fixture module is a single RWX `PT_LOAD`, so its GOT slot (0x2820) lands in executable memory and the converted Mach-O binds `RecordArgs` into `__ELF0` (initprot 7). dyld on macOS 27.0.1 refuses that bind. The relinker built at 1b865fc3 (#3492, which added this branch) fails the same way here, so this is the host, not a later change. The fixture now has an RX code segment (0x0–0x2000) and an RW data segment (0x2000–0x3000: dynamic section, tables and GOT), as modules are laid out. Only the test changes. ### Tested macOS 27.0.1 on Apple silicon with Rosetta 2, relinker-only Release builds of `main` 18c438b10: - x86-64 build (`-DCMAKE_OSX_ARCHITECTURES=x86_64`) with an x86-64 Python (`arch -x86_64 /usr/bin/python3`): `guest_module_args` fails on `main` with the error above and passes with this change; the macOS branch loads the module and checks the recorded `args`/`argp` and the returned result. - arm64 build and Python: passes before and after (structure checks only). - Full relinker suite, both builds: every test passes except three that also fail on `main` on this machine (`pr_overlap_encoding`, `progress_history`, `stubgen_stdout_newlines`). The Linux branch, which loads the same fixture with `ld.so`, was not run here. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
simonbronk commented 2026-10-13 18:13:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-13T18:13:31Z.


Tested on macOS 27.0.1, Apple silicon, relinker-only Release (Apple clang 21), with this PR (058b40530) merged into main 18c438b10. To run the branch CI skips, I used an x86-64 CPython 3.12 under Rosetta 2 and built guest_module_args_host.prx for x86-64.

  • main: guest_module_args fails with the same dyld error quoted above (BIND_OPCODE_DO_BIND pointer bind is in executable segment '__ELF0').
  • This PR: Guest module argument tests passed.

The full relinker suite (arm64) passes 146/146 on both.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152116268 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5362#issuecomment-6152116268). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-13T18:13:31Z. --- Tested on macOS 27.0.1, Apple silicon, relinker-only Release (Apple clang 21), with this PR (`058b40530`) merged into `main` `18c438b10`. To run the branch CI skips, I used an x86-64 CPython 3.12 under Rosetta 2 and built `guest_module_args_host.prx` for x86-64. - `main`: `guest_module_args` fails with the same dyld error quoted above (`BIND_OPCODE_DO_BIND pointer bind is in executable segment '__ELF0'`). - This PR: `Guest module argument tests passed`. The full relinker suite (arm64) passes 146/146 on both. AI-assisted: yes (Claude Code).
adriadam10 commented 2026-10-14 18:34:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:34:53Z.


Checked the new layout (RX 0x0–0x2000, RW 0x2000–0x3000 with dynamic section, tables and GOT): the four program headers fit before the code, offsets and sizes match the image, and the GOT slot at 0x2820 is now in the RW segment. Linux relinker ctest is green (131/131 in scope, incl. guest_module_args); the macOS branch is confirmed by @simonbronk on macOS 27.0.1 (x86-64 Python under Rosetta). Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175545899 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5362#issuecomment-6175545899). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:34:53Z. --- Checked the new layout (RX 0x0–0x2000, RW 0x2000–0x3000 with dynamic section, tables and GOT): the four program headers fit before the code, offsets and sizes match the image, and the GOT slot at 0x2820 is now in the RW segment. Linux relinker ctest is green (131/131 in scope, incl. `guest_module_args`); the macOS branch is confirmed by @simonbronk on macOS 27.0.1 (x86-64 Python under Rosetta). Merging.
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!5362
No description provided.