Repository navigation
fix(relinker): resolve relocations against null symbol entries to 0 - #4452
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
A relocation whose dynamic symbol entry is all zero, like the null symbol, now takes the value 0 plus its addend, as the gABI defines for STN_UNDEF. The Linux output imports such an entry as an unnamed weak symbol, which the host loader resolves to 0. The Windows and macOS outputs write the value into the slot instead of failing with "Empty import symbol name". Such references are left out of the call registry. An unnamed symbol entry that is not all zero still fails the relink. OliSe Player (PPSA01153) has seven of these entries and calls through the slots only when they are not 0 (boykopovar#4437). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orishamir
force-pushed
the
fix/relinker-null-symbol-imports
branch
from
October 12, 2026 12:25
559f8f3 to
1205d03
Compare
Contributor
|
Verified on Windows 11 (26300), AMD Radeon 860M, WinLibs GCC 15.2.0, Release, OliSe Player (PPSA01153, catalog 02.001.000), relinked with
Tests
AI-assisted: yes (Claude Code) |
10 tasks done
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
This was referenced Oct 12, 2026
9 tasks done
Contributor
|
Tested on Linux (Ubuntu 24.04, lavapipe) with main 2a5eca1 + this PR + #4470, OliSe Player PPSA01153 with
AI-assisted: yes |
This was referenced Oct 12, 2026
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A relocation whose dynamic symbol entry is all zero, the same bytes as the null symbol, now takes the value 0 plus its addend, as the gABI defines for
STN_UNDEF. Until now the relinker turned such a reference into an import with an empty name:Empty import symbol name.symbol lookup error: ./app.elf: undefined symbol:with an empty name.With this change:
RelinkerPipelineaccepts an unnamed symbol only when its whole entry is zero, and leaves such references out of the call registry. Any other unnamed entry fails the relink withUnnamed import symbol is not a null symbol entry.SysVDynamicSectionBuilderimports it as an unnamed weak symbol (STB_WEAK,STT_NOTYPE), which the Linux loader resolves to 0.WindowsRelocationBuilder, which builds the imports of Windows and macOS executables, writes the value into the slot and adds no import.Title. OliSe Player (PPSA01153, catalog 02.001.000, GPL-3.0) has seven such relocations: six
GLOB_DATand oneJUMP_SLOTagainst the all-zero entries 247 and 326 to 330 (#4437). Its code uses them as weak references. It reads 0x18c5bb8 at 16 places, each a compare with 0 that skips the call through the PLT stub of 0x18c60c8 when the slot is 0. Each of the other five slots has a wrapper that jumps through it when it is not 0 and otherwise returns 0 or -1. The title is built with the ps5-payload-dev SDK, so it relinks only with--trap-sdk-syscall-stubs(#3804).On
main3d8ffeb:FAIL: Empty import symbol name (offset 0x18c5bb8)./app.elf: symbol lookup error: ./app.elf: undefined symbol:With this change merged onto that
main, both get past these slots and stop at the next absent import,XU4yLKvcDh0(__divti3, open in #4037):FAIL: unresolved ELF import XU4yLKvcDh0 from libSceLibcInternal.prx./app.elf: symbol lookup error: ./app.elf: undefined symbol: XU4yLKvcDh0tools/import_audit.pythen listsstatvfsandfdopendiras its other two absent imports.Fixes #4437.
Tested
null_symbol_relocations. A fixture has aGLOB_DATand anR_X86_64_64(addend 0x1234) against an all-zero symbol entry. It relinks for Linux, Windows and macOS atunused-filter=0and=1, each with an empty registry. The Linux output imports both as unnamed weak symbols. On Windows the executable reads 0 and 0x1234 from the slots and returns 42. An unnamed entry that is not all zero fails the relink on all three targets.WindowsRelocationBuilder.cppreverted the Windows relink fails. WithSysVDynamicSectionBuilder.cppreverted the Linux symbols areGLOBAL FUNC. WithRelinkerPipeline.cppreverted the registry lists two empty NIDs.BUILD_TESTING=ON:main3d8ffeb with this commit; the new test runs its Windows executable there.--trap-sdk-syscall-stubs, by the relinker ofmain029c1bc with and without this change. 171 of the 174 outputs are byte-identical, registries included. The 3 that differ are OliSe Player's: its Linux output, and its Windows and macOS relinks, which now succeed.tools/check_conventions.py --base origin/mainpasses, andtools/pr_overlap.py --branchreports no overlap.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code