Module miri::shims::unix::mem

source ·
Expand description

This is an incomplete implementation of mmap/munmap which is restricted in order to be implementable on top of the existing memory system. The point of these function as-written is to allow memory allocators written entirely in Rust to be executed by Miri. This implementation does not support other uses of mmap such as file mappings.

mmap/munmap behave a lot like alloc/dealloc, and for simple use they are exactly equivalent. That is the only part we support: no MAP_FIXED or MAP_SHARED or anything else that goes beyond a basic allocation API.

Note that in addition to only supporting malloc-like calls to mmap, we only support free-like calls to munmap, but for a very different reason. In principle, according to the man pages, it is possible to unmap arbitrary regions of address space. But in a high-level language like Rust this amounts to partial deallocation, which LLVM does not support. So any attempt to call our munmap shim which would partially unmap a region of address space previously mapped by mmap will report UB.

Traits§