fix(relinker): accept relocations against symbol index 0 for Windows and macOS #7902

Merged
mopga merged 1 commit from upstream-pr/7902 into main 2026-10-19 17:22:01 +00:00
mopga commented 2026-10-19 13:04:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mopga on 2026-10-19T13:04:39Z.


What

Code analysis rejected R_X86_64_64, GLOB_DAT and JUMP_SLOT relocations whose symbol index is 0 (STN_UNDEF) with Code analysis: invalid relocation symbol, so --windows and --macos failed on an input that the Linux conversion accepts. The pipeline already resolves such relocations to 0 plus the addend, as the gABI defines and as the relinker technical debt entry records for null symbol entries; only an all-zero entry at a nonzero index was accepted. Index 0 is now treated as an import slot like that entry.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), relinker-only build of this branch on current main:

  • test_null_symbol_relocations.py now also runs both relocations against symbol index 0. On main it fails with Code analysis: invalid relocation symbol (offset 0x308) for Windows; with the fix the Windows executable exits 42 (slot 0x308 holds 0, slot 0x310 holds the addend), macOS converts, and the Linux imports match the index 1 case.
  • ctest: 210/210 passed.
  • python3 tools/check_conventions.py --base origin/main passes.

Open PRs #6586, #6607, #6618, #6684, #6974, #6977 and #7037 change other parts of CodeInstructionCollector.cpp; none changes this check. The PR overlap check could not compare #6618 and #6977, which conflict with main. Checked by hand: both already conflict with main in this file without this change (#6977 carries the R_X86_64_RELATIVE change merged as #6357), and neither changes the line this PR changes.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4921386449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7902). Originally posted by [mopga](https://github.com/mopga) on 2026-10-19T13:04:39Z. --- ### What Code analysis rejected `R_X86_64_64`, `GLOB_DAT` and `JUMP_SLOT` relocations whose symbol index is 0 (`STN_UNDEF`) with `Code analysis: invalid relocation symbol`, so `--windows` and `--macos` failed on an input that the Linux conversion accepts. The pipeline already resolves such relocations to 0 plus the addend, as the gABI defines and as the relinker technical debt entry records for null symbol entries; only an all-zero entry at a nonzero index was accepted. Index 0 is now treated as an import slot like that entry. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), relinker-only build of this branch on current `main`: - `test_null_symbol_relocations.py` now also runs both relocations against symbol index 0. On `main` it fails with `Code analysis: invalid relocation symbol (offset 0x308)` for Windows; with the fix the Windows executable exits 42 (slot 0x308 holds 0, slot 0x310 holds the addend), macOS converts, and the Linux imports match the index 1 case. - `ctest`: 210/210 passed. - `python3 tools/check_conventions.py --base origin/main` passes. Open PRs #6586, #6607, #6618, #6684, #6974, #6977 and #7037 change other parts of `CodeInstructionCollector.cpp`; none changes this check. The PR overlap check could not compare #6618 and #6977, which conflict with `main`. Checked by hand: both already conflict with `main` in this file without this change (#6977 carries the `R_X86_64_RELATIVE` change merged as #6357), and neither changes the line this PR changes. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-19 13:13:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T13:13:38Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6618 core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp
PR 6977 core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6268073716 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7902#issuecomment-6268073716). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T13:13:38Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6618](https://www.github.com/boykopovar/AnyPS5/pull/6618) | `core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp` |
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!7902
No description provided.