mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 00:22:57 -05:00
nid_patcher turns the _nid_postfix names of a library into NIDs for ELF and PE. A library built on macOS is a Mach-O dylib, whose exports are in a dyld export trie and whose imports are in the chained fixups, so it gets its own patcher. - The export trie is read, every exported C name (without Mach-O's leading underscore) is resolved to its NID, and the trie is rebuilt the way ld64 lays it out: the offsets are uleb128, so the layout is repeated until it is stable. A trie that no longer fits is appended to __LINKEDIT, which has to end the file, and a signed image is refused. - Weak definitions that are not marked _nid_postfix or _nid_no_patch keep their names: dyld coalesces those across images by name. - In the chained imports, names bound to a .prx dylib that are guest facing (a _nid_postfix name or an sce prefix) are patched in place; a name that would grow, or that shares storage with another import, is an error. Images that use bind opcodes instead of chained fixups are refused. - ExportExclusions reads the exports of a reference Mach-O, so the exclusion list works for libraries built on macOS as well.