fix(relinker): reject imports of data exports at address 0 on Linux #24152
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24152"
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 dsandall on 2026-11-20T08:10:23Z.
What
glibc's
check_match(elf/dl-lookup.c) skips a defined symbol whosest_valueis 0 unless it isSHN_ABSorSTT_TLS. The Linux guest-module writer already gives a function export at address 0 ajmpthunk (the ps5-payload-dev SDK links a shared object's code at 0). A data or untyped export at 0 stays at 0, though, so an import of it converted without complaint and then stopped at startup as an undefined symbol.GuestModuleBuildernow marks every Linux export the host loader cannot see: value 0, notSTT_TLS, and not a function the writer thunks (SHN_ABSexports were already left out of the export map). When a relocated import of the executable or of a guest module binds to a marked export, the conversion fails withGuest import <name> in <importer> binds to an export at address 0 in <provider> that the Linux loader skips. An import that no relocation references is not rejected, because the loader never resolves it. Windows and macOS are unchanged.The debt entry "Guest exports at address 0 on Linux" keeps its text and only its last sentence is cut to the cases that are still not checked: an executable import that names no module and that several guest modules export (the host loader picks the provider), and a module's own relocations against such an export. #23865 changes the same debt entry; whichever merges second folds its fragment, and I will rebase this PR if #23865 lands first.
Tested
Arch Linux x86-64, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON, Release), homebrew synthetic ELFs only, no title.test_linux_guest_zero_address_exports.pygains synthetic-ELF cases. For bothSTT_NOTYPEandSTT_OBJECTexports at address 0, an import from a guest module and an import from the executable each fail the conversion with exit code 2, name the import, importer and provider, and write no output. The same import with no relocation still converts. The new cases fail onmain(the conversion succeeds) and pass with this change. The existing function-thunk cases and the native run of the thunked function still pass. Full relinker suite:ctest --test-dir build-relinker -j8passes 1046 of 1046 tests.tools/check_conventions.py --base upstream/mainpasses, andtools/debt_fold.py --checkpasses.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T08:23:05Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and its targeted cases appear sound based on the source read.
What I ran
Reviewed head
d39019f719dfc5137d47148f026dc74a3824bb2cusing the prepared diff andrepo_read.pyfor targeted source context. No build or tests were run during this review; the test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full relinker suite, Linux execution test, convention check, and debt-fold check were not run in this review. Read:
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp,core/relinker/relinker/tests/test_linux_guest_zero_address_exports.py,core/relinker/relinker/src/guest/GuestImageReader.cpp(targeted range), anddocs/dev/debt/changes/fix-relinker-addr0-data-import.md. The manifest lists three changed files and all three were read. No exclusions were reported in the available manifest.To get this to a good state
Nothing is required. The PR description reports successful tests and checks; those results were not independently verified.
Imported from boykopovar/AnyPS5. Originally posted by edglz on 2026-11-20T21:52:40Z.
Review: APPROVED
Summary
glibc's
check_matchskips a defined symbol withst_value == 0unless it isSHN_ABSorSTT_TLS, so an import bound to a data or untyped export at 0 converted cleanly and then failed at load time.HostInvisiblemirrors that rule minus the functions the writer thunks, and the rejection only fires for relocated imports, so unreferenced imports still convert. The executable path checks both the declared-provider and single-provider cases; the ambiguous multi-provider case is documented as remaining debt.Verification
Environment: macOS 26, Apple M4 (arm64), Apple clang 21.0.0, CMake relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON), PR diff applied on currentmain.linux_guest_zero_address_exportswith the builder change revertedNot verified: execution of the converted outputs on Linux or Windows; the tests that run them are host-gated.
Notes
If #23865 lands first, the fragment's "two names for it get two
jmps at different addresses" no longer holds and should be dropped on rebase, as the description already anticipates.Verdict
Approved.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T01:21:39Z.
Review: COMMENTED
Reviewed — no blocking findings
The change at
e7124b74d293b71901a89ba233c8360b45016f18rejects referenced Linux imports that bind to defined guest exports at address zero when the host loader skips them; I found no verified blocking defect.What I ran
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
files.jsonwas not available in the prepared review bundle, so I could not compare the files read against its reviewed list. The manifest lists three changed files, and all three were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T01:24:00Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
1d2d0f8f-d6a2-4c0b-9371-5862f27085a6Reviewing files that changed from the base of the PR and between
2608316185ande7124b74d2.core/relinker/relinker/src/guest/GuestModuleBuilder.cppcore/relinker/relinker/tests/test_linux_guest_zero_address_exports.pydocs/dev/debt/changes/linux-zero-export-aliases.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.