feat(nid): patch NIDs in Mach-O libraries #2247
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2247"
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 mugurc on 2026-10-09T13:10:18Z.
What
nid_patcherturns the_nid_postfixnames of a library into NIDs for ELF and PE. This adds Mach-O, so that a library built on macOS gets its NIDs too. It is the piece of the macOS port thatninja libsneeds there; the build changes that use it come in separate PRs. Nothing changes for ELF and PE.__LINKEDIT, which has to end the file, and a signed image is refused._nid_postfixor_nid_no_patchkeep their names, because dyld coalesces those across images by name..prxdylib that are guest facing (a_nid_postfixname or ansceprefix) are patched in place. A name that would grow, or that shares storage with another import, is an error. An image that uses bind opcodes instead of chained fixups is refused.--preserve-exportsreads a reference Mach-O the way it reads ELF and PE references.Tested
nid_patcher_macho: builds small Mach-O dylibs byte by byte and runsnid_patcheron them. It checks the rebuilt export trie (including a weak export that must stay), the patched and untouched chained imports, a trie that grows and is appended to__LINKEDIT,--preserve-exports, and the three refusals (signed image, bind opcodes, an import NID longer than its name). It needs no macOS. I also ran it against two copies of the patcher with a deliberate break each (no import patching, weak exports patched), and both fail it.cmp, and the port'spatched_librariestest loads them all.ctest, run by manual dispatch on my fork: https://github.com/mugurc/AnyPS5/actions/runs/37931715161 (Linux 508 of 508, Windows 517 of 517,nid_patcher_machoincluded). The relinker jobs on a pull request do not buildnid_patcher, so they do not cover this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T16:07:12Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
f3c51474, merged ontomaind70b8998together with #1324, #2039 and #2193.nid_patcher_machopasses on Windows.🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:15:00Z.
Checked the build and ctest scoped to
core/libs(11/11,nid_patcher_machoincluded), a clean merge onto currentmain, and popcoder565's native Windows run of the new test. ELF/PE paths are unchanged and the Mach-O test pins the rebuilt trie, the patched and untouched chained imports,--preserve-exportsand the three refusals. Merging.