Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
roboterspinne:fix/relinker-macos-relocation-message
Oct 26, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
roboterspinne:fix/relinker-macos-relocation-message

Conversation

@roboterspinne

Copy link
Copy Markdown
Contributor

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 feat(relinker): trace function imports on macOS #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)

The macOS output reuses the Windows load image and relocation builder,
so a --macos conversion failed with "Unsupported Windows relocation type
2" for PC32, COPY and 32, and with "Windows output requires a
position-independent ELF image" for an ET_EXEC input. These errors now
read "Relocation type N is not supported for this target" and "This
target requires ...", like the builder's other errors that name no
target. Which inputs are accepted does not change.
@maximilianfv

Copy link
Copy Markdown
Contributor

Tested on Apple M1 Pro, macOS 27.0.1 (x86_64 build under Rosetta 2)

Applied at f81854f0e to mugurc's macOS series (27e968974) merged with main at 1e20650e84, with other open macOS fixes, then toggled only this PR. Release build.

elf_header executable_tls_relocations
Without this PR (old relinker, old tests) Passed Passed
Old relinker with this PR's tests Failed: type-1-0-2 (ET_EXEC, --windows) prints Windows output requires a position-independent ELF image Failed: windows-pc32 prints Unsupported Windows relocation type 2 (offset 0x1000)
With this PR Passed Passed

So the new test cases fail without the source change and pass with it. Each test stops at its first failed case, so I did not see the old relinker's message for the --macos cases.

  • I ran both tests through ctest -R and directly with uv run. The results matched.
  • All 137 ctest tests under core/relinker passed with and without this PR.
  • No other test in the tree checks the old messages, and current main (5ed5427bac) still has them.

AI-assisted: yes (Claude Code applied the PR, ran the tests and wrote this report).

@harisibrar1 harisibrar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against main c9b7582 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.

@adriadam10
adriadam10 merged commit aa04180 into boykopovar:main Oct 26, 2026
13 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked that the three messages are the only uses of the old texts, that elf_header and executable_tls_relocations fail without the change (also confirmed by @maximilianfv on macOS), and that the relinker jobs are green on all platforms; merged.

@roboterspinne
roboterspinne deleted the fix/relinker-macos-relocation-message branch October 26, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants