mirror of
https://github.com/HeyPuter/gex.git
synced 2026-11-13 18:34:21 -10:00
A program that patches its own code with mprotect(RWX) around each write (an old MinGW runtime's pseudo-relocations: one per relocation, the whole .text each time) retired the whole section per patch, the relocator's own code with it, which then came back to translation once per patch: a process that does this for thousands of relocations crawled through startup for minutes. The kernel now notes which retired ranges were retired by being made writable while staying executable (MapLog::writable_code). On x86, the browser host keeps the pages of those ranges whose translations were all made while the page was writable and executable (volatile, so each block checks its bytes against a snapshot) and that hold no unit code; every other page is retired as before. The native host keeps no translation of writable code and retires them all. The diagnostic retire counts now count only pages retired. test/native/textpatch: 300 patches of one function from code on the next page of its section; the last patch is seen natively and on the page, warm and cold, and the patching code does not come to translation again for each patch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_e0aa53aa95eb4b86910519b4d14812a5 (cherry picked from commit 030864228b7a57299ada7408dac377148320c774)