fix(relinker): drop Windows from errors the macOS target also reports #10391

Merged
roboterspinne merged 1 commit from upstream-pr/10391 into main 2026-10-26 18:10:02 +00:00
roboterspinne commented 2026-10-23 20:46:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-23T20:46:43Z.


What

The macOS output reuses the Windows load image and relocation builder (MacOsMachOPatcher.cpp:64, :67), so a --macos conversion failed with errors that name Windows. Relocation types 2 (PC32), 5 (COPY) and 10 (32) pass the relocation type check, but neither the PE nor the Mach-O output applies them, and the conversion failed with Unsupported Windows relocation type 2. An ET_EXEC input failed with Windows output requires a position-independent ELF image. These errors now read Relocation type 2 is not supported for this target and This target requires a position-independent ELF image, like the builder's other errors such as Executable DTPMOD64 relocation is not supported for this target. The ELF64 x86-64 check in the same constructor gets the same wording. Which inputs are accepted or rejected does not change.

  • executable_tls_relocations now checks the message for types 2 and 10 on --windows and --macos, and elf_header checks the ET_EXEC error on both targets, a case it used to skip.
  • Only the shared Windows components change, not MacOsMachOPatcher.cpp, which #9408 edits.

Tested

Ubuntu 24.04 x86_64, relinker-only Release build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON); synthetic fixtures only, no title or homebrew.

  • ctest --test-dir build-relinker: 240/240 passed.
  • The CLI line for a type 2 relocation reads FAIL: Relocation type 2 is not supported for this target (offset 0x1000) on --windows and --macos, and the same for type 10.
  • python3 tools/check_conventions.py --base upstream/main with this title and description 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4989052132 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10391). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-10-23T20:46:43Z. --- ### What The macOS output reuses the Windows load image and relocation builder (`MacOsMachOPatcher.cpp:64`, `:67`), so a `--macos` conversion failed with errors that name Windows. Relocation types 2 (`PC32`), 5 (`COPY`) and 10 (`32`) pass the relocation type check, but neither the PE nor the Mach-O output applies them, and the conversion failed with `Unsupported Windows relocation type 2`. An `ET_EXEC` input failed with `Windows output requires a position-independent ELF image`. These errors now read `Relocation type 2 is not supported for this target` and `This target requires a position-independent ELF image`, like the builder's other errors such as `Executable DTPMOD64 relocation is not supported for this target`. The ELF64 x86-64 check in the same constructor gets the same wording. Which inputs are accepted or rejected does not change. - `executable_tls_relocations` now checks the message for types 2 and 10 on `--windows` and `--macos`, and `elf_header` checks the `ET_EXEC` error on both targets, a case it used to skip. - Only the shared Windows components change, not `MacOsMachOPatcher.cpp`, which #9408 edits. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04 x86_64, relinker-only Release build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`); synthetic fixtures only, no title or homebrew. - `ctest --test-dir build-relinker`: 240/240 passed. - The CLI line for a type 2 relocation reads `FAIL: Relocation type 2 is not supported for this target (offset 0x1000)` on `--windows` and `--macos`, and the same for type 10. - `python3 tools/check_conventions.py --base upstream/main` with this title and description passed. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
harisibrar1 commented 2026-10-24 15:43:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:43:19Z.

Review: APPROVED


Checked against main c9b75825f3 and the relinker sources (MacOsMachOPatcher.cpp, WindowsLoadImage.cpp, WindowsRelocationBuilder.cpp, ValidationPolicy.cpp, ElfReader.cpp):

  • I confirmed from main's code that --macos goes through the same WindowsLoadImage and WindowsRelocationBuilder (MacOsMachOPatcher.cpp:64,67, with only the diagnostics check before them), so on main the macOS cases do print the "Windows output requires..." and "Unsupported Windows relocation type N" messages. That covers the macOS half the earlier test run couldn't reach.
  • Small note: R_X86_64_NONE (type 0) also passes ValidationPolicy and now gets "Relocation type 0 is not supported for this target", along with 2, 5 and 10.
  • The ELF64 x86-64 check in WindowsLoadImage looks unreachable in practice, because ElfReader::ReadHeader and GuestImageReader reject those inputs first, so the reword is fine without a test.
  • Optional, out of scope: for a non-JUMP_SLOT entry in DT_JMPREL (e.g. type 6), the message says the type is unsupported for the target, though it's fine in DT_RELA. Naming the table might help in a follow-up. Looks good to me.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638826522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10391#pullrequestreview-5638826522). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T15:43:19Z. **Review:** APPROVED --- Checked against main c9b75825f3 and the relinker sources (`MacOsMachOPatcher.cpp`, `WindowsLoadImage.cpp`, `WindowsRelocationBuilder.cpp`, `ValidationPolicy.cpp`, `ElfReader.cpp`): - I confirmed from main's code that `--macos` goes through the same `WindowsLoadImage` and `WindowsRelocationBuilder` (`MacOsMachOPatcher.cpp:64,67`, with only the diagnostics check before them), so on main the macOS cases do print the "Windows output requires..." and "Unsupported Windows relocation type N" messages. That covers the macOS half the earlier test run couldn't reach. - Small note: R_X86_64_NONE (type 0) also passes `ValidationPolicy` and now gets "Relocation type 0 is not supported for this target", along with 2, 5 and 10. - The ELF64 x86-64 check in `WindowsLoadImage` looks unreachable in practice, because `ElfReader::ReadHeader` and `GuestImageReader` reject those inputs first, so the reword is fine without a test. - Optional, out of scope: for a non-JUMP_SLOT entry in DT_JMPREL (e.g. type 6), the message says the type is unsupported for the target, though it's fine in DT_RELA. Naming the table might help in a follow-up. Looks good to me. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!10391
No description provided.