fix(relinker): emit separate macOS run paths from ELF lists #5298
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5298"
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 Ondra97 on 2026-10-13T16:42:59Z.
What
A --macos conversion with --rpath '$ORIGIN/first:$ORIGIN/second' wrote one LC_RPATH containing a literal colon and an untranslated second $ORIGIN. dyld therefore searched a different directory. Split the ELF list into separate load commands, translating each path for the executable or guest library and preserving order. Empty components fail explicitly before output. This follows Apple's run-path dependent library contract.
Tested
Windows, supported WinLibs GCC 15.2, Release relinker-only full build and 150/150 tests passed. The new actual Mach-O output regression failed on main with ['@executable_path/first:$ORIGIN/second']; after the fix, executable and guest module load commands contain separate correctly relocated paths. Absolute lists and empty-component rejection are covered. This is structural validation; no macOS title execution is claimed.
Local conventions and whitespace checks passed. Current open PRs were checked for overlapping files, lines and functions.
CI relinker builds and test suites passed on Linux, Windows and macOS for
eb10acbfb(Build). Full runtime-library jobs were skipped by the automatic PR policy.Combined local validation of #5283, #5286, #5298, #5302, #5305, #5308 and #5310 on main
61b8742b6: all seven patches merge without conflicts; the full relinker-only build and 150/150 CTest tests passed.Checklist
Based on current
main; no other open PR implements the same functionsOne topic per PR; follow-ups go in a new PR
No comments in code except technical debt
Unimplemented paths throw (
NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt fileNo notes, investigation
.mdfiles or images added to the repository (attach them to this PR)New third-party code is a submodule built from source
Generic behaviour, not specific to one title
Depends on: none
Unblocks: none
GPUs tested: n/a
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-13T18:13:32Z.
Checked on a real Mac (macOS 27.0.1, Apple silicon, relinker-only Release), this PR (
eb10acbfb) merged intomain18c438b10: 146/146 tests pass. I also converted a small executable plus one module with--macos --rpath '$ORIGIN/first:$ORIGIN/second'and read the output with Apple'sotool -l:main: oneLC_RPATHeach:@executable_path/first:$ORIGIN/secondand@loader_path/../../first:$ORIGIN/../../second.@executable_path/first,@executable_path/secondand@loader_path/../../first,@loader_path/../../second, in order.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-13T18:14:14Z.
Checked on macOS 27.0.1 (Apple silicon, Rosetta 2) with this PR merged into
main18c438b10;macos_output,guest_runpathandguest_module_argspass.Runtime check with dyld,
--macos --rpath '$ORIGIN/first:$ORIGIN/second'and an x86-64libkernel.prxonly insecond/:DYLD_PRINT_SEARCHING=1showsfirst/libkernel.prxtried, thenfound: dylib-from-disk: ".../second/libkernel.prx". Withmain, dyld tries.../first:$ORIGIN/second/libkernel.prxand stops withLibrary not loaded: @rpath/libkernel.prx.LC_RPATHis@loader_path/../../first,@loader_path/../../second. Loading it from an x86-64 Python, asguest_module_argsdoes, resolveslibkernel.prxandlibc.prxfromsecond/, and itsDT_INITrecords the expectedargs/argpand result. Withmainthe load fails on.../first:$ORIGIN/../../second/libc.prx. The module used a fixture with separate RX/RW segments, because dyld on macOS 27 refuses binds into the current RWX fixture (#5362).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:33:01Z.
Checked that
MachORunPathssplits the ELF list into oneLC_RPATHper component for both the executable and guest modules, in order, with$ORIGINtranslated per component and empty components rejected before any output is written. The newmacos_outputcheck fails without the change and passes with it; relinker build and ctest pass locally and on CI (linux, windows, macos), and theotool -l/ dyld runs by @simonbronk and @thuanquang on macOS confirm the result. Merging.