fix(nid): share string suffixes when rebuilding .dynstr #242
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/242"
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 adriadam10 on 2026-10-01T18:10:00Z.
What
nid_patcherrebuilds.dynstrin place and fails when the new table is larger than the original section ("rebuilt .dynstr (N bytes) exceeds original section size"). The linker tail-merges dynamic strings (a name that is the suffix of another, likecosinsideacosorsin@...insideasin@..., is stored once), but the patcher wrote every string separately and lost that sharing. Libraries with many exports get away with it because NIDs are shorter than most export names; a library with few exports and many imports does not:libSceAudioInlinked against SDL (3 exports, ~220 imports) overflows by 5 bytes.The patcher now collects the final strings, sorts them by their reversed text, and lets a string that ends the previous one point into it (standard suffix merging). Offsets for symbols,
DT_NEEDED/DT_SONAMEand verneed entries are mapped as before.Tested
Linux (CachyOS, GCC): rebuilt
libswith the old and the new patcher and compared, for all 106 patched.prx, the dynamic symbol names (nm -D) andDT_NEEDED/DT_SONAME(readelf -d): identical. Full test suite passes. The SDL-backedlibSceAudioIn(follow-up PR) patches only with this change. Windows only through CI (PE patching is not touched).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)