mirror of
https://github.com/libretro/parallel-ps2.git
synced 2026-11-10 17:26:34 -10:00
* Memory: fall back to room in the core's image when no range is in reach When no free range within reach of the core was found for the main and code maps, they went wherever the OS put them, and the recompilers aborted at the first operand they could not encode. In Kodi on x86-64 Linux, which has mapped a lot around the core by the time a game starts, that happens on every launch. Keep room for both maps in the core's own .bss and, as the last resort, map them over it. Being part of the image, it is always within reach of the globals and of each other. It is handed back as zeroed memory when the maps are released. * Memory: keep the image's room for the maps uncommitted and off the reach budget The room for the main and code maps lives in a NOBITS .lbss section of its own, which the linkers place at the top of the image, and a constructor turns it into read-only, uncommitted zeroes as soon as the image is loaded. Loading the core no longer costs 625 MB of commit and VmData, and LeakSanitizer can still scan it. The normal placement measures the image without the room, so its reach window is what it was before the room. The maps go over the room through near_place_pair_in_room, which checks that image and room lie within RIP_LIMIT, and are handed back to it as read-only zeroes. If handing a range back fails, the room is given up for good rather than mapped over again with MAP_FIXED. tests/nearplace checks the room's state after load, that it is the top of the image, and that with nothing in reach free the pair is placed in it and handed back, twice. --------- Co-authored-by: libretroadmin <[email protected]>