fix(libc): define PF_R beside PF_X and PF_W for the macOS ELF types #10659

Merged
imellag merged 1 commit from upstream-pr/10659 into main 2026-10-27 05:04:30 +00:00
imellag commented 2026-10-24 15:38:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-24T15:38:54Z.


What

#9972 made GuestFlexibleMemoryModule.cpp describe its segment on macOS with header.p_flags = PF_R | PF_W. On macOS that file takes its ELF types from prx/libc/include/specifics/linux/ElfTypes.hpp, which defines PF_X and PF_W but not PF_R, so on current main the fixture fails to compile on macOS:

core/libs/tests/GuestFlexibleMemoryModule.cpp:22:22: error: use of undeclared identifier 'PF_R'

This adds PF_R = 4 (the ELF value) beside the other two. None of the files that include ElfTypes.hpp also include <elf.h> or <link.h>, so the name cannot meet the system macro, as with PF_X and PF_W. #7201 adds the same constant to the same header as part of the whole macOS port, inside its own #ifdef __APPLE__ block. The two lines are in different places, so a text merge of the second one to land is clean but leaves two PF_R definitions, a redefinition error on macOS. #7201's head (6687cbac29, 2026-10-16) conflicts with main and needs a rebase anyway, so the order proposed here is this PR first and PF_R dropped from #7201's block at its rebase; if #7201 lands first, this PR is not needed and I will close it.

Tested

Apple M4 Pro, macOS 27.0.1, Apple clang, x86-64 Release (-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja), on main fee6a14709, whose ElfTypes.hpp, GuestFlexibleMemoryModule.cpp and libkernel/CMakeLists.txt match this branch's base c9b75825f3: cmake --build build --target guest_flexible_memory_module fails with the error above without this change and compiles and links guest_flexible_memory_module.guest.prx with it. The test that loads the fixture needs libkernel, which does not build on main on macOS yet, so it was not run. Not built on Linux or Windows; the header only gains a constant, and the macOS block that uses it is the only user.

check_conventions.py --base upstream/main passes. pr_overlap.py lists only #7201 as a pull request it could not compare on ElfTypes.hpp, because #7201 conflicts with main.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4996752445 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10659). Originally posted by [imellag](https://github.com/imellag) on 2026-10-24T15:38:54Z. --- ### What #9972 made `GuestFlexibleMemoryModule.cpp` describe its segment on macOS with `header.p_flags = PF_R | PF_W`. On macOS that file takes its ELF types from `prx/libc/include/specifics/linux/ElfTypes.hpp`, which defines `PF_X` and `PF_W` but not `PF_R`, so on current `main` the fixture fails to compile on macOS: ``` core/libs/tests/GuestFlexibleMemoryModule.cpp:22:22: error: use of undeclared identifier 'PF_R' ``` This adds `PF_R = 4` (the ELF value) beside the other two. None of the files that include `ElfTypes.hpp` also include `<elf.h>` or `<link.h>`, so the name cannot meet the system macro, as with `PF_X` and `PF_W`. #7201 adds the same constant to the same header as part of the whole macOS port, inside its own `#ifdef __APPLE__` block. The two lines are in different places, so a text merge of the second one to land is clean but leaves two `PF_R` definitions, a redefinition error on macOS. #7201's head (`6687cbac29`, 2026-10-16) conflicts with `main` and needs a rebase anyway, so the order proposed here is this PR first and `PF_R` dropped from #7201's block at its rebase; if #7201 lands first, this PR is not needed and I will close it. ### Tested Apple M4 Pro, macOS 27.0.1, Apple clang, x86-64 Release (`-DCMAKE_OSX_ARCHITECTURES=x86_64`, Ninja), on `main` `fee6a14709`, whose `ElfTypes.hpp`, `GuestFlexibleMemoryModule.cpp` and `libkernel/CMakeLists.txt` match this branch's base `c9b75825f3`: `cmake --build build --target guest_flexible_memory_module` fails with the error above without this change and compiles and links `guest_flexible_memory_module.guest.prx` with it. The test that loads the fixture needs `libkernel`, which does not build on `main` on macOS yet, so it was not run. Not built on Linux or Windows; the header only gains a constant, and the macOS block that uses it is the only user. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` lists only #7201 as a pull request it could not compare on `ElfTypes.hpp`, because #7201 conflicts with `main`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 15:40:03 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


The one-line definition matches the ELF PF_R value (4), and the PR identifies the missing constant in the macOS ELF header as the compile failure. The focused macOS compile is author-reported; hosted policy checks pass, with relinker/register-context jobs still running. git diff --check passes.

Please coordinate the direct overlap with open #7201 before merging: it adds the same PF_R constant in the same header. The body acknowledges this, but the checklist says Depends on: none and does not record which branch lands first or how the second change will avoid a duplicate definition. Please agree and record the integration order (or clarify why the two patches will not conflict), then I can complete the review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638817269 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10659#pullrequestreview-5638817269). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T15:40:03Z. **Review:** CHANGES_REQUESTED --- The one-line definition matches the ELF `PF_R` value (4), and the PR identifies the missing constant in the macOS ELF header as the compile failure. The focused macOS compile is author-reported; hosted policy checks pass, with relinker/register-context jobs still running. `git diff --check` passes. Please coordinate the direct overlap with open #7201 before merging: it adds the same `PF_R` constant in the same header. The body acknowledges this, but the checklist says `Depends on: none` and does not record which branch lands first or how the second change will avoid a duplicate definition. Please agree and record the integration order (or clarify why the two patches will not conflict), then I can complete the review.
MarcZX10 commented 2026-10-24 15:45:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:45:36Z.

Review: APPROVED


Re-reviewed exact head 6dfd477eef25bc3a357c38208bfc0c4ad1eb2690. The missing ELF PF_R definition is the direct cause of the reported macOS fixture compile failure, and adding its value beside PF_X/PF_W is correct. The author has now documented the duplicate-definition hazard with #7201 and a workable ordering: this standalone fix first, then remove #7201’s duplicate at rebase; if #7201 lands first, close this PR. The focused macOS build is author-reported, not independently reproduced. Eligibility, conventions, intake, labels, report, all relinker platforms, ASan, register-context and write-watch checks pass; product build jobs are skipped. I found no remaining blocker on this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638832964 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10659#pullrequestreview-5638832964). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T15:45:36Z. **Review:** APPROVED --- Re-reviewed exact head `6dfd477eef25bc3a357c38208bfc0c4ad1eb2690`. The missing ELF `PF_R` definition is the direct cause of the reported macOS fixture compile failure, and adding its value beside `PF_X`/`PF_W` is correct. The author has now documented the duplicate-definition hazard with #7201 and a workable ordering: this standalone fix first, then remove #7201’s duplicate at rebase; if #7201 lands first, close this PR. The focused macOS build is author-reported, not independently reproduced. Eligibility, conventions, intake, labels, report, all relinker platforms, ASan, register-context and write-watch checks pass; product build jobs are skipped. I found no remaining blocker on this PR.
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!10659
No description provided.