fix(relinker): preserve DF_SYMBOLIC on guest modules #5981
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5981"
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 MarcZX10 on 2026-10-14T18:05:15Z.
What
Accept
DF_SYMBOLICon guest ELF modules and preserve it when the relinker writes Linux guest modules. The ELF ABI uses this flag to make references from a shared object search that object before the executable and other shared objects. The Linux module writer now emitsDF_SYMBOLIC | DF_BIND_NOWfor those modules; modules without the input flag keepDF_BIND_NOWonly.Addresses the
DF_SYMBOLICconversion blocker in #5927. It does not address the separate ambiguous undeclared imports or the intermittent Windows relinker crash reported there, and it does not claim RetroArch cores now load or run.Tested
ANYPS5_RELINKER_ONLY=ON):relinkerbuilt.guest_module_directoriesandguest_intel_trampolines: passed (2/2). The integration case verifies a symbolic guest module converts and its Linux output has flags0xA, while an ordinary module remains at0x8; Windows conversion also accepts the input flag.python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --checkpassed.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 repositoryImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T20:06:01Z.
Review: COMMENTED
macOS data point, including the Mach-O output.
Apple M2 Max, macOS 27.2 (26B5091g), AppleClang, Ninja Release, relinker-only. Head
7ccf79a6fmerged without conflicts intomainc26982f63.-DCMAKE_OSX_ARCHITECTURES=x86_64, Python 3.9.6): 159/163; the 4 failures (pr_overlap_encoding,stubgen_stdout_newlines,release_package,linux_fixed_base) fail the same way on unmodifiedmainhere.hardware_oracle_compare(Python, not touched here) also hit its 20 s timeout once in the parallel run while the machine was loaded; it passes when run alone.main,guest_module_directoriesfails on both builds withprovider.prx: Unsupported guest dynamic flags; with the PR,guest_module_directoriesandguest_intel_trampolinespass.The test converts with the Linux and Windows targets only. I added
--macosby hand: a provider built withmodule_with_symbol(True, symbolic=...)plus a type 6 relocation at0x2320against its own exportedshared, next to the test's consumer module (arm64 and x86_64 relinker binaries, same results):DF_SYMBOLICprovider onmainUnsupported guest dynamic flags)DT_FLAGS0xa(non-symbolic:0x8)--macos--windowsIn the Mach-O output the self-reference is a rebase, not a bind: the rebase opcodes are
11 22 a0 06 51 23 08 51 00(segment 2 offset0x320, segment 3 offset0x8) and the bind table is empty, with or withoutDF_SYMBOLICin the input. From readingWriteMacOs, relocations against symbols the module defines appear to be resolved inside the module, so on macOS accepting the flag looks sufficient; I only checked this one fixture.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T16:13:52Z.
Thanks for the macOS results and the exact source pins. The arm64 163/163 result is useful; I’ll keep the Rosetta failures and the parallel-only timeout recorded as platform-specific results that also reproduce on your unmodified main, rather than attributing them to this PR.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T23:36:51Z.
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.
core/relinker/elfpatcher/include/elfpatcher/general/ElfConstants.hppcore/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cppcore/relinker/elfpatcher/src/windows/WindowsGuestModuleWriter.cppcore/relinker/relinker/include/relinker/guest/GuestImage.hppcore/relinker/relinker/src/guest/GuestImageReader.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T00:22:03Z.
I manually compared the shared-file patches with #6977 after the overlap bot could not compare them against its conflicting base. The hunks are currently independent: this PR carries
GuestImage::Symbolic, readsDF_SYMBOLIC, and emits it withDF_BIND_NOW; #6977 changesHasInit, PS4 module-import parsing, and own-TLS relocation handling. I do not see a same-line conflict or a dependency between these changes. The branches may still need conflict resolution when #6977 is rebased because they edit the same files.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T17:22:38Z.
Linux looks right. On Windows the flag is accepted but no writer uses
image.Symbolic, so a symbolic module's references to its own exports resolve the ordinary way. Could Windows either keep refusingDF_SYMBOLICuntil symbolic resolution is implemented there, or record the gap in the relinker debt file?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:30:31Z.
Good catch. The Windows writer currently has no
DF_SYMBOLIChandling, so accepting the flag would silently give the wrong lookup semantics. I updated the branch in86d3c085eto rejectDF_SYMBOLICguest modules explicitly in the Windows writer, and added a regression towindows_guest_export_alias_tests. The changed writer and test translation units cross-compile with MinGW; conventions, diff checks, and the overlap scan pass. I have not run the Windows-specific test executable in this Linux environment, so the hosted Windows test remains the runtime validation.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:34:16Z.
The first hosted run caught a fixture interaction:
guest_module_directoriespasses one symbolic provider through both Linux and Windows writer modes. Commit2f7eb66c6keeps the symbolic provider for Linux (where this PR implements it) and uses a non-symbolic provider for the Windows directory-discovery case; the dedicated Windows writer regression still asserts that symbolic input is rejected. I rebuilt the relinker and reranguest_module_directorieslocally: 1/1 passed. The rerun on this head will exercise the remaining Windows-specific check.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:35:42Z.
I added an end-to-end assertion in
guest_module_directoriesthat--windowsconversion of aDF_SYMBOLICmodule exits with the explicit unsupported error and does not write an output. The relinker-only build succeeds and the focused CTest passes (1/1) locally. This exercises the Windows writer path on Linux CI as well as retaining the direct writer regression for Windows.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T18:33:24Z.
Merged while @adriadam10 is away: the review passed and full CI is green on this head.