fix(relinker): resolve relocations against null symbol entries to 0 #4452
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4452"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-12T12:08:27Z.
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
main3d8ffeb2: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:main3d8ffeb2with this commit; the new test runs its Windows executable there.--trap-sdk-syscall-stubs, by the relinker ofmain029c1bc1with 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
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T13:16:23Z.
Verified on Windows 11 (26300), AMD Radeon 860M, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, with head1205d03damerged onto currentmainf8dee0595.OliSe Player (PPSA01153, catalog 02.001.000), relinked with
--windows --trap-sdk-syscall-stubs:main:FAIL: Empty import symbol name (offset 0x18c5bb8), as in #4437.mainnow has__divti3(#4037), so the run gets one step further than in the description and stops atFAIL: unresolved ELF import j+XjoRSIvwU from libSceLibcInternal.prx(fdopendir), exit0xc0000139. No open PR addsfdopendirorstatvfsyet.Tests
ctestundercore/relinker: 109/109.null_symbol_relocations: 3/3.main: withWindowsRelocationBuilder.cpp,SysVDynamicSectionBuilder.cpporRelinkerPipeline.cppreverted,null_symbol_relocationsfails each time.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T14:12:35Z.
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.
main)core/relinker/relinker/src/output/SysVDynamicSectionBuilder.cppL135-136, L146-147core/relinker/relinker/src/pipeline/RelinkerPipeline.cppL260-261core/relinker/elfpatcher/src/windows/WindowsRelocationBuilder.cppL0-1, L41-42core/relinker/relinker/src/output/SysVDynamicSectionBuilder.cppL134-136, L145-147core/relinker/relinker/src/pipeline/RelinkerPipeline.cppL260-261core/relinker/relinker/src/output/SysVDynamicSectionBuilder.cppL135-136, L146-147core/relinker/relinker/src/pipeline/RelinkerPipeline.cppL260-261Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-12T17:45:53Z.
Tested on Linux (Ubuntu 24.04, lavapipe) with main
2a5eca11+ this PR + #4470, OliSe Player PPSA01153 with--trap-sdk-syscall-stubs../app.elf: symbol lookup error: ./app.elf: undefined symbol:(empty name). The input has the seven null-symbol relocations you describe (six GLOB_DAT, one JUMP_SLOT, at .got 0x18C5BB8 to 0x18C60C8)../app.elf: symbol lookup error: ./app.elf: undefined symbol: j+XjoRSIvwU.AI-assisted: yes