Repository navigation
Consolidate PE loading and virtual memory into CoreCLR minipal - #135902
Merged
Merged
Conversation
Make OS-loaded PE layouts Windows-only and share native section mapping through placeholder-backed VMToOSInterface APIs. Use POSIX descriptors for Unix and WASM PE files, retaining buffer copies on WASM and native mapping elsewhere. Remove the obsolete Unix PAL PE loader and cover source ownership and concurrent loading. Preserve 64-bit file offsets in 32-bit section mapping. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Deduplicate PE file-handle access and use a shared invalid-file sentinel. Unify the TryOpenFile default while explicitly locking binder opens. Restore tagged SIZE_T image-part boundaries and derive cleanup extents without storing per-part sizes. Route native copied-image allocation and protection through VMToOSInterface, remove Unix PAL release bookkeeping, and simplify Unix allocation with direct mmap handling. Use aligned heap allocation for WASM copies and document placeholder mapping semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… PAL APIs Migrates all non-Windows-only call sites of ClrVirtualAlloc/VirtualAlloc, ClrVirtualFree/VirtualFree, ClrVirtualProtect/VirtualProtect, and ClrVirtualQuery/VirtualQuery from the CoreCLR PAL to the CoreCLR minipal VMToOSInterface abstraction (src/coreclr/minipal), introducing new minipal APIs (ReserveMemoryWithinRange, CommitReservedMemory, DecommitMemory) as needed. Windows-only call paths and native Windows APIs are left intact. Migrated call sites: - utilcode/executableallocator.cpp (Reserve/Commit/Release/ReserveWithinRange) - utilcode/util.cpp (ClrVirtualAllocWithinRange) - utilcode/hostimpl.cpp and vm/hosting.cpp (ClrVirtualAlloc/Free/Protect wrappers; ClrVirtualQuery is now gated #ifdef HOST_WINDOWS since no non-Windows caller remains) - debug/ee/controller.cpp (breakpoint-patch VirtualProtect call sites) - debug/ee/debugger.cpp (DebuggerHeapExecutableMemoryAllocator) - Loader-heap and stub-heap owners (loaderheap.cpp, explicitcontrolloaderheap.cpp, interleavedloaderheap.cpp, loaderheap_shared.cpp/.h, loaderallocator.cpp/.hpp, dynamicmethod.cpp, virtualcallstub.cpp/.h) now thread an explicit size through Release() instead of relying on PAL-tracked allocation bookkeeping. Removes the four PALAPI-exported functions (VirtualAlloc, VirtualFree, VirtualProtect, VirtualQuery) and their declarations from pal/src/map/virtual.cpp and pal/inc/pal.h, along with now-dead helper functions and the HAVE_VM_ALLOCATE Mach-specific block that were only reachable from those four functions. Internal PAL machinery used by other callers (ExecutableMemoryAllocator, CMI bookkeeping, PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange, PAL_JitWriteProtect, GetVirtualPageSize) is preserved. Deletes the now-obsolete PAL API-conformance test suites for these four APIs (VirtualAlloc, VirtualFree, VirtualProtect, VirtualQuery test directories) and adapts a handful of unrelated PAL tests that used these APIs only as incidental setup (ProbeMemory, IsBadReadPtr, IsBadWritePtr, PAL_EXCEPT_FILTER, ReadFile, WriteFile) to use mmap/mprotect/malloc instead. Validated via: - Full Debug clr+libs+host build and Checked clr + Release libs build, both 0 errors/warnings. - Full PAL test suite run shows no regressions versus baseline (same 20 pre-existing failures on both). - EventPipe GCEvents test passes. - Smoke test exercising GC, JIT/dynamic-method compilation, and GCStress 0xC (exercising gccover.cpp code-patching) passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ClrVirtualAlloc, ClrVirtualFree, ClrVirtualQuery, and ClrVirtualProtect are now declared and defined only when HOST_WINDOWS is set (src/coreclr/inc/clrhost.h, src/coreclr/utilcode/hostimpl.cpp, src/coreclr/vm/hosting.cpp). All remaining non-Windows callers now call the underlying minipal VMToOSInterface APIs directly instead of going through the EE's ClrVirtual* wrapper layer: - vm/gccover.cpp, vm/peimagelayout.cpp: VMToOSInterface::ProtectMemory (peimagelayout.cpp gains a small Win32ProtectionToMemoryProtection helper for its PAGE_* -> MemoryProtection translation; the existing Apple/arm64 PAL_JitWriteProtect special case is preserved unchanged) - vm/eventing/eventpipe/ep-rt-coreclr.h: AllocateMemory / ReleaseMemoryReservation - vm/frozenobjectheap.cpp: ReserveMemoryWithinRange, CommitReservedMemory, ReleaseMemoryReservation - vm/cachelinealloc.cpp: AllocateMemory / ReleaseMemoryReservation - utilcode/util.cpp, utilcode/executableallocator.cpp: ReserveMemoryWithinRange - debug/daccess/daccess.cpp: AllocateMemory / ReleaseMemoryReservation - md/enc/stgio.cpp: ReserveMemoryWithinRange, CommitReservedMemory, ProtectMemory, DecommitMemory, ReleaseMemoryReservation vm/ceeload.cpp's SetTargetForVTableEntry (only reachable under FEATURE_IJW, a Windows-only feature) and vm/threads.cpp's DebugLogStackRegionMBIs/Thread::DebugLogStackMBIs (only reachable from Windows-only RestoreGuardPage) are now gated accordingly, since their definitions referenced ClrVirtualProtect/ClrVirtualQuery without previously being gated themselves. The Windows-only ForceReloc/Debug_AllowCallout debug logic in ClrVirtualAlloc and the UEF debug-check logic in ClrVirtualProtect are preserved unchanged, just de-nested from the now-removed non-Windows branches. Validated with a full Checked CoreCLR build (0 warnings/errors), a GC/JIT smoke test, the GCEvents EventPipe test, and the full PAL test suite (219 passed, 0 failed, no regressions). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ToOSInterface calls Remove the Windows-specific ClrVirtual* branch at call sites that previously had a parallel #ifdef TARGET_UNIX VMToOSInterface::* / #else ClrVirtual* dual path, now that VMToOSInterface's Windows backend forwards directly to the native Win32 APIs for everything except AllocateMemory (which still goes through ClrVirtualAlloc, preserving the ForceRelocs debug-stress logic for PE image mapping). - ep-rt-coreclr.h, frozenobjectheap.cpp, cachelinealloc.cpp, executableallocator.cpp, util.cpp, daccess.cpp, stgio.cpp: coalesced straightforward alloc/commit/decommit/release dual-path sites. - gccover.cpp: coalesced breakpoint-sprinkling ProtectMemory calls (the discarded oldProtect out-param on Windows made this a pure simplification). - ceemain.cpp InitGSCookie: coalesced the GS cookie protect/restore pair; both platforms now use the already-existing Unix-style approach of restoring directly to ReadOnly without querying for a prior protection value. - peimagelayout.cpp ApplyBaseRelocations: coalesced the three ClrVirtualProtect/VMToOSInterface::ProtectMemory call sites to use the existing Unix-style manual old-protection tracking (SectionCharacteristicsToPageProtection/Win32ProtectionToMemoryProtection) unconditionally, since VMToOSInterface::ProtectMemory has no mechanism to return the true previous protection value. The Apple/ARM64 PAL_JitWriteProtect branch is preserved unchanged. - minipal.h/Windows/mapping.cpp: added a MemoryProtection::WriteCopy value (PAGE_WRITECOPY on Windows, same as ReadWrite on Unix where the PAL never offered true copy-on-write) so Win32ProtectionToMemoryProtection no longer collapses PAGE_WRITECOPY to ReadWrite - which would have made VirtualProtect fail on Windows for relocations applied to a FILE_MAP_COPY-backed R2R image view (relocationMustWriteCopy path). Verified via incremental CoreCLR Checked build (0 warnings/errors) and smoke tests exercising FrozenObjectHeap, GC, GS cookie, EventPipe, and R2R base-relocation application (corerun loading System.Private.CoreLib.dll). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… in peimagelayout.cpp ApplyBaseRelocations tracked protection state as Win32 PAGE_* DWORD constants and translated them to VMToOSInterface::MemoryProtection at each ProtectMemory call site. Since this function no longer calls any Win32 protection API directly, track the protection state as VMToOSInterface::MemoryProtection directly instead: - SectionCharacteristicsToPageProtection -> SectionCharacteristicsToMemoryProtection, returning VMToOSInterface::MemoryProtection directly. - Win32ProtectionToMemoryProtection removed entirely. - dwOldProtection (DWORD, 0 meaning 'none') replaced with an explicit hasOldProtection bool plus a VMToOSInterface::MemoryProtection oldProtection value (0 is not a valid MemoryProtection enumerant on all platforms, so a separate flag is needed instead of a sentinel value). - The exec-region checks (bExecRegion bitwise tests against PAGE_EXECUTE/PAGE_EXECUTE_READ/PAGE_EXECUTE_READWRITE/PAGE_EXECUTE_WRITECOPY) replaced with a small IsExecutableProtection(MemoryProtection) helper. No behavior change; this is purely replacing DWORD-based Win32 protection constants with the native MemoryProtection enum already used everywhere else in this function. Verified via incremental CoreCLR Checked build (0 warnings/errors) and smoke tests (corerun loading System.Private.CoreLib.dll as R2R, GC, EventPipe). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the near-code reservation allocator and JIT write protection into CoreCLR minipal. Remove obsolete PAL page-size, initialization, and DAC export plumbing. Add a heap-backed WASM ExecutableAllocator implementation and exclude native-only mapping and range helpers from WASM builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jkoritzinsky
marked this pull request as ready for review
October 16, 2026 17:48
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
jkotas
reviewed
Oct 16, 2026
jkotas
reviewed
Oct 16, 2026
jkotas
reviewed
Oct 16, 2026
jkotas
reviewed
Oct 16, 2026
janvorli
reviewed
Oct 16, 2026
jkotas
reviewed
Oct 16, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Confirmed page-size contract mismatches break large Unix DAC allocations and debugger allocations on larger-page systems.
2 open findings
What changed in this PR
Consolidates CoreCLR PE loading and virtual-memory operations into minipal, removing duplicated Unix PAL functionality.
Changes:
- Adds mapping, allocation, protection, and ownership abstractions with platform-specific implementations.
- Migrates runtime, debugger, and DAC callers; adds dedicated WASM allocation support.
- Removes obsolete PAL tests and adds assembly ownership and concurrency coverage.
Validation here was limited to source inspection; no builds or tests were run.
| File | Description |
|---|---|
| src/tests/Loader/CollectibleAssemblies/AssemblyOnDisk/Program.cs | Adds ownership and concurrent-loading tests. |
| src/coreclr/vm/virtualcallstub.h | Tracks reservation size. |
| src/coreclr/vm/virtualcallstub.cpp | Releases reservations with their sizes. |
| src/coreclr/vm/util.hpp | Removes PAL PE ownership helper. |
| src/coreclr/vm/threads.cpp | Restricts memory-query diagnostics to Windows. |
| src/coreclr/vm/peimagelayout.h | Adopts minipal holders and platform-specific layouts. |
| src/coreclr/vm/peimage.h | Uses platform-native file handles. |
| src/coreclr/vm/peimage.cpp | Implements Unix file-descriptor ownership. |
| src/coreclr/vm/loaderallocator.hpp | Stores loader-heap reservation size. |
| src/coreclr/vm/loaderallocator.cpp | Passes reservation size during cleanup. |
| src/coreclr/vm/hosting.cpp | Restricts virtual-memory wrappers to Windows. |
| src/coreclr/vm/gccover.cpp | Migrates code-page protection. |
| src/coreclr/vm/frozenobjectheap.cpp | Migrates heap reservation and commitment. |
| src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h | Migrates EventPipe buffer allocation. |
| src/coreclr/vm/dynamicmethod.cpp | Supplies code-heap release size. |
| src/coreclr/vm/corhost.cpp | Excludes allocator statistics on WASM. |
| src/coreclr/vm/coreassemblyspec.cpp | Locks shared image-file opening. |
| src/coreclr/vm/ceemain.cpp | Migrates startup allocation and protection. |
| src/coreclr/vm/ceeload.cpp | Guards mixed-mode vtable protection. |
| src/coreclr/vm/cachelinealloc.cpp | Migrates cache-line allocation and release. |
| src/coreclr/utilcode/util.cpp | Delegates Unix range reservations to minipal. |
| src/coreclr/utilcode/loaderheap.cpp | Tracks reservation extents during cleanup. |
| src/coreclr/utilcode/loaderheap_shared.h | Adds size-aware reservation holder. |
| src/coreclr/utilcode/loaderheap_shared.cpp | Implements size-aware release. |
| src/coreclr/utilcode/interleavedloaderheap.cpp | Updates cleanup and WASM handling. |
| src/coreclr/utilcode/hostimpl.cpp | Restricts virtual-memory wrappers to Windows. |
| src/coreclr/utilcode/explicitcontrolloaderheap.cpp | Supplies reservation sizes to cleanup. |
| src/coreclr/utilcode/executableallocator.wasm.cpp | Adds heap-backed WASM allocator. |
| src/coreclr/utilcode/executableallocator.cpp | Migrates executable-memory operations. |
| src/coreclr/utilcode/CMakeLists.txt | Selects platform-specific allocator source. |
| src/coreclr/pal/tests/palsuite/paltestlist.txt | Removes obsolete test registrations. |
| src/coreclr/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/test3.cpp | Uses native read-only mapping. |
| src/coreclr/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/test2.cpp | Uses native page protections. |
| src/coreclr/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/test.cpp | Uses native memory mappings. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/VirtualQuery.cpp | Deletes obsolete query test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.cpp | Deletes obsolete protection test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.cpp | Deletes obsolete protection test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.cpp | Deletes obsolete protection test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.cpp | Deletes obsolete protection test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.cpp | Deletes obsolete protection test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.cpp | Deletes obsolete protection test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/VirtualFree.cpp | Deletes obsolete release test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/VirtualFree.cpp | Deletes obsolete release test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/VirtualFree.cpp | Deletes obsolete release test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.cpp | Deletes obsolete recommit test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.cpp | Deletes obsolete recommit test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.cpp | Deletes obsolete allocation test. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/ProbeMemory.cpp | Uses heap allocation for probing. |
| src/coreclr/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/ProbeMemory_neg.cpp | Uses inaccessible native mapping. |
| src/coreclr/pal/tests/palsuite/file_io/WriteFile/test2/WriteFile.cpp | Migrates protected test buffers. |
| src/coreclr/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp | Migrates protected test buffers. |
| src/coreclr/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/pal_except_filter.cpp | Uses native mappings for fault recovery. |
| src/coreclr/pal/tests/palsuite/compilableTests.txt | Removes deleted test entries. |
| src/coreclr/pal/tests/palsuite/CMakeLists.txt | Removes deleted test sources. |
| src/coreclr/pal/src/thread/thread.cpp | Uses minipal page-size queries. |
| src/coreclr/pal/src/thread/process.cpp | Removes obsolete virtual-memory include. |
| src/coreclr/pal/src/thread/context.cpp | Uses minipal page-size queries. |
| src/coreclr/pal/src/misc/cgroup.cpp | Removes obsolete virtual-memory include. |
| src/coreclr/pal/src/loader/module.cpp | Removes PAL PE-loading APIs. |
| src/coreclr/pal/src/init/pal.cpp | Removes PAL virtual-memory initialization. |
| src/coreclr/pal/src/include/pal/virtual.h | Deletes obsolete virtual-memory header. |
| src/coreclr/pal/src/include/pal/module.h | Removes PE-loading declarations. |
| src/coreclr/pal/src/include/pal/map.hpp | Removes PE mapping bookkeeping. |
| src/coreclr/pal/src/exception/signal.cpp | Uses minipal page-size queries. |
| src/coreclr/pal/src/exception/seh.cpp | Removes obsolete virtual-memory include. |
| src/coreclr/pal/src/exception/machexception.cpp | Uses minipal page-size queries. |
| src/coreclr/pal/src/debug/debug.cpp | Uses minipal page-size queries. |
| src/coreclr/pal/src/CMakeLists.txt | Removes PAL virtual-memory source. |
| src/coreclr/pal/inc/pal.h | Removes obsolete PAL APIs and flags. |
| src/coreclr/pal/inc/pal_error.h | Removes obsolete initialization error. |
| src/coreclr/minipal/Windows/CMakeLists.txt | Includes new Windows memory sources. |
| src/coreclr/minipal/Windows/allocation.cpp | Adds Windows allocation wrapper. |
| src/coreclr/minipal/Unix/memory.cpp | Adds WASM allocation and JIT write protection. |
| src/coreclr/minipal/Unix/doublemapping.cpp | Uses minipal executable reservations. |
| src/coreclr/minipal/Unix/CMakeLists.txt | Selects native mapping sources. |
| src/coreclr/minipal/minipal.h | Defines memory APIs and ownership holders. |
| src/coreclr/minipal/mapping.cpp | Implements shared ownership holders. |
| src/coreclr/minipal/CMakeLists.txt | Exposes minipal include directory. |
| src/coreclr/md/enc/stgio.cpp | Migrates metadata paging operations. |
| src/coreclr/inc/vptr_list.h | Restricts loader layouts to Windows. |
| src/coreclr/inc/utilcode.h | Excludes range-allocation declaration on WASM. |
| src/coreclr/inc/switches.h | Updates allocator ownership comment. |
| src/coreclr/inc/executableallocator.h | Updates allocator contracts and platform guards. |
| src/coreclr/inc/clrhost.h | Restricts memory wrappers to Windows. |
| src/coreclr/dlls/mscoree/exports.cpp | Initializes Unix executable-memory pool. |
| src/coreclr/dlls/mscordac/mscordac_unixexports.src | Removes obsolete PAL export entries. |
| src/coreclr/debug/ee/debugger.cpp | Migrates debugger heap allocation. |
| src/coreclr/debug/ee/controller.cpp | Migrates Unix breakpoint-page protection. |
| src/coreclr/debug/daccess/daccess.cpp | Migrates DAC block allocation and cleanup. |
🧠 Review effort: Balanced
This was referenced Oct 16, 2026
Closed
janvorli
reviewed
Oct 22, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jkotas
reviewed
Oct 23, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
janvorli
reviewed
Oct 26, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jkotas
reviewed
Oct 27, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-pe-layout-mapping
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
A few leftovers that lost their last users in this PR:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
janvorli
approved these changes
Oct 29, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
janvorli
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
The Unix PAL contained its own PE loader (parsing and mapping sections) to emulate loading PEs, when we already had a concept of a "manually loaded" PE file in our ConvertedImageLayout type. This PR removes that duplication and moves native memory mapping/allocation/protection behind
VMToOSInterfacein CoreCLR minipal.Changes
LoadedImageLayoutandNativeImageLayoutare now Windows-only.PEImageowns a file descriptor and maps sections with a shared non-WASM placeholder-based mapper (LoadImageByMappingParts), keeping file backing and page sharing. WASM uses heap-buffer layouts.ClrVirtualAlloc/Free/Protect/Query(andVirtualAlloc/...) toVMToOSInterface, restrict theClrVirtual*wrappers to Windows, and remove the Virtual* APIs from the CoreCLR PAL.AssemblyOnDisktests for layout ownership and concurrency.Validation
WASM size
Compared
dotnet.native.wasmfrom merge-base175bffb899e6(calculated withgit merge-base origin/main HEAD) against PR head86ef27f0271b.Both used clean Release CoreCLR
browser-wasmbuilds with identical settings and Emscripten 6.0.2. Compression used Brotli 1.2.0, quality 11, and lgwin 22.Both builds succeeded (exit code 0) using:
Note
This PR description was generated with AI assistance (GitHub Copilot).