fix(relinker): preserve executable exports in macOS output #7361
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7361"
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 RockENZO on 2026-10-18T02:05:43Z.
What
macOS executables currently drop the defined dynamic symbols that the pipeline already preserves. A dependent library that imports a function or global from the main executable therefore fails to load, and
dlsymcannot find those exports. The regression fixture converts successfully on currentmain, but running it under Rosetta aborts withsymbol not found in flat namespace '_FixtureData'.Populate the Mach-O executable export trie from the rebuilt dynamic symbol table. Preserve function/data addresses, 64-bit absolute values, weak-definition flags and protected visibility; omit hidden/local symbols. TLS exports use the existing descriptor representation and validate their range. Unsupported attributes/sections, duplicate stripped names and unmapped addresses fail explicitly.
The new test checks the trie on every host and, on macOS, runs the converted x86-64 executable with a small native dependency that imports and calls its function, reads its global and queries weak/absolute/protected exports through
dlsym. This uses no game files or full runtime libraries. It is a loader prerequisite, not a claim that a particular game now runs.Mach-O flag semantics follow Apple's loader.h:
EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE,EXPORT_SYMBOL_FLAGS_WEAK_DEFINITIONandMH_WEAK_DEFINES.Overlap:
tools/pr_overlap.py --branch codex/macos-executable-exports --repo boykopovar/AnyPS5completed with no confirmed duplicate implementation or conflict. It could not compare shared files in already-conflicting PRs #2780, #5021, #6044, #6697, #6879, #6977 and #7332. Manual inspection found CMake registration changes in the first six; #7332 also changes macOS TLS/fixed-base code and does not implement executable exports. #6802 changes the patcher's load-image construction, not this export population. There is no functional dependency on those PRs; whichever lands later may need to rebase.Tested
2026-10-19 revalidation: rebased onto upstream
c820102bd03cc5ec4f3ebd35ccc20570e5d50f5d; headec5c0dcd0cfcdd51cfe4056cfedb50b01ed998e5.git range-diffconfirms the patch is unchanged. Fresh Release relinker-only builds on macOS 27.2 pass all 193 registered tests for arm64 and all 193 for x86-64 under Rosetta. Both runs execute the converted x86-64 export/import anddlsymprobe successfully.input_magicand both macOS loader tests are registered. Conventions and whitespace checks pass. The original baseline evidence below remains historical; no game or full-runtime compatibility is claimed.macOS 27.2, Apple Silicon, AppleClang 21.0.0.21000334, Release, based on
main195d0d08a. CMake 4.4.4, Ninja 1.13.2, Python 3.9.6._FixtureDatasymbol.dlsymchecks.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T02:16:26Z.
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/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T18:44:09Z.
Checked the export population against the dynsym (function/data, absolute, weak, protected, hidden/local skipped), the TLS range validation, the
MacOsExportfield change (the other user inMacOsGuestModuleWriter.cppstill compiles with the positional initializer), and the new test (trie contents and flags, plus the failure cases); merged.