Repository navigation
fix(relinker): resolve symbol-name imports through NIDs on Linux - #9234
Conversation
|
Native Linux runtime check of exact head Ubuntu 24.04.3, GCC 13.3, Release. I built the official ps5-payload-dev/sdk v0.44 hello_world source using the v0.44 SDK release and clang/lld 18. This is a newly built ELF, not the reporter's binary (SHA256 I built the relinker separately at this head and at parent relinker --to-intel --skip-sce-module --trap-sdk-syscall-stubs --registry hello_world.elf app.elfEach output used the same freshly built
The remaining crash is in the SDK's As a separate import-path diagnostic, I copied the input and changed only ELF The PR's relinker-only CTest suite also passes 239/239. No repository source edits. This verifies the filename/NID fix and identifies a separate payload-entry ABI blocker; it does not establish that #9180's full SDK payload now runs. |
|
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.
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.
|
|
Tried this branch with a full build (not relinker-only) on
Both fixtures import unqualified names that a host library exports by name, and both are registered only in the full build, so the relinker-only run stays green. The executable side works on a real SDK binary: a probe built with the ps5-payload-dev SDK (own I have a branch that only rewrites images naming a |
|
Tried the branch ( Command, with no relinker --to-intel --skip-sce-module --trap-sdk-syscall-stubs src/eboot.elf app.elf
So both failures from #9180 are gone on Linux. The crash is outside this PR. Both jump to Tested with AI assistance (Claude Code); the commands and outputs above were run locally. |
Homebrew built with the ps5-payload-dev SDK names its system libraries with .sprx and imports by symbol name, while the libraries in libs/ are .prx files that export NIDs. On Linux such an executable converted but stopped at load time on the first .sprx dependency and, once that was found, on the first symbol name. The Linux patcher now loads a dependency named with .sprx, .suprx or .debug_prx as the .prx library of the same stem. In an executable that names such a dependency, an import without a module that is named by symbol gets the NID of that name. A name that a bundled module exports still binds to that module. There is no lookup by the name as written, because the host loader also searches the host C library. Other executables keep their unqualified imports as written.
28b31a3 to
be51ab7
Compare
|
@wail-arch thanks, you're right. Rewriting every unqualified import broke fixtures that import @rocklouis055 @simonbbby thanks for running it against full |
|
@mossyanwar Thanks. On be51ab7, I turned #9261 into the bundled-module follow-up, stacked on be51ab7 with |
|
Re-ran on
I'll open a separate issue for the |
|
Checked the |
…0x400000 base Linux executables now load at 0x400000 by default (boykopovar#9234), so the stub's call reaches the guest entry moved by that base.
What
Homebrew built with the ps5-payload-dev SDK needs
libkernel_web.sprx,libSceLibcInternal.sprxand so on, and imports by symbol name (memset,accept,__error). The libraries inlibs/are.prxfiles that export NIDs, so on Linux the converted executable stopped at the first.sprxdependency, and after that at the first symbol name (#9180). #6697 fixed the same thing on Windows.Linux output now:
.sprx,.suprxor.debug_prxdependency as the.prxlibrary of the same stem (Domain::NeededLibraryName, as on Windows);SysVDynamicSectionBuilderrecords these imports by relocation address inSysVDynamicSection::NamedImports, andLinuxElfPatcherrenames them after the guest module builder has run, so a name that a bundled module exports still binds to that module (shared#guest). Qualified imports and imports with a module are unchanged.Other executables keep their unqualified imports as written. Test fixtures import helpers such as
LoadExecFirst_nid_no_patchby name from host libraries that export them by name.Unlike Windows, there is no first lookup by the name as written:
ld.sosearches the global scope, which includes the host glibc and libstdc++ that every library inlibs/links, somallocorpthread_createwould bind to glibc. The SDK's own loader resolves these names by NID on the console (sprx_sym2addr). NoDT_NEEDEDis added forlibc.prxorlibkernel.prx, because every Linux library inlibs/already links both.The call registry and
needed.jsonare unchanged. The Windows debt entry now only mentions macOS, and a new Linux entry records what is still open: imports of bundled modules are still bound by name.guest_needed_modules,guest_module_identityandguest_needed_nested_modulesexpected a.suprxor.debug_prxhost dependency to be kept as written. It is now the.prxname.Tested
WSL2 Ubuntu 24.04, GCC 13.3, Ninja Release, on
main99844c7ee.New
linux_named_importstest. A host library built at test time exports9E8ipSX3c9g, the NID ofshared. An executable that importssharedwithout a module:DT_NEEDEDofavailable.sprx, which now loadsavailable.prxsharedand binds to a provider exportingsharedwhen it only needsavailable.prxundefined symbol: 9E8ipSX3c9gagainst a provider that only exportssharedas written, when it needsavailable.sprxsharedwhen the import isshared#A#Bshared#guestwhen a bundled module exportssharedOn
mainit fails at the first case: the output still importsshared, and running it givesundefined symbol: shared.Relinker-only build:
ctest239/239.Full build with
BUILD_TESTING=ON:loadexec_arguments,agc_driver_guest_memory_lifetime_converted,linux_named_imports,windows_named_imports,executable_tls_relocations,guest_needed_modules,guest_module_identityandguest_needed_nested_modulespass. With the relinker from the previous head28b31a306, the first two fail withundefined symbol: dt+StXeB4JQandundefined symbol: vIMLEVWjQbg, as @wail-arch reported. The rest of the full suite was not run.python3 tools/check_conventions.py --base origin/mainpasses.ftpsrv.elffrom the pacbrew-repo v0.41.1ps5-payload-daemons.zip(sha256ab59eb744eccd197d68af4d4a0b882940861e3c45010e766c83704188ff753a5), relinked with--skip-syscall-check --skip-sce-module --registry.--skip-syscall-checkis needed because its inline syscalls don't convert yet (relinker: the SDK SYS_mount stub is not trapped, so two public ps5-payload-dev payloads do not convert #8624).main: needslibkernel_web.sprx,libSceLibcInternal.sprxandlibSceNet.sprx, and 84 of its 87 imports are plain names..prxnames, and all 87 imports are NIDs (__erroris9BcDykPmo1I,atoiisfPxypibz2MY). The call registry is identical tomain's.@rocklouis055 and @simonbbby ran the previous head against full
libsbuilds: SDKhello_worldand LÖVE load with every dependency a.prxname and every import a NID, then stop in the SDK's_start, which expects apayload_args_t*inrdi. That entry is outside this PR.Not tested: running on Windows or macOS. Those code paths are unchanged.
#9261, opened after this one, makes the same change and also covers imports of bundled modules.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)