Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
mopga:fix/relinker-null-symbol-index-zero
Oct 19, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
mopga:fix/relinker-null-symbol-index-zero

Conversation

@mopga

@mopga mopga commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

…and macOS

Code analysis rejected R_X86_64_64, GLOB_DAT and JUMP_SLOT relocations whose symbol index is 0 (STN_UNDEF) with 'invalid relocation symbol', so the Windows and macOS conversions failed while Linux converted the same input. 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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

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

@oneandonlydean oneandonlydean self-assigned this Oct 19, 2026
@oneandonlydean
oneandonlydean merged commit b6583dd into boykopovar:main Oct 19, 2026
15 checks passed
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.

2 participants