memmap2-rs icon indicating copy to clipboard operation
memmap2-rs copied to clipboard

Support POSIX MAP_FIXED

Open ShaneEverittM opened this issue 3 years ago • 5 comments

Would it be possible to support this flag? Currently the much older crate mmap supports it, but it hasn't been updated in 6 years (!).

ShaneEverittM avatar Oct 29 '21 23:10 ShaneEverittM

Why do you need it?

Anyway, patches are welcome.

RazrFalcon avatar Oct 30 '21 13:10 RazrFalcon

It's kind of an niche use case, I'm playing around with writing a ELF loader. I could submit a patch, but it would be just for me. Though as I work on it more I probably won't need to use MAP_FIXED it's kind of a hack.

ShaneEverittM avatar Oct 30 '21 22:10 ShaneEverittM

I think the main point of this crate is providing a portable abstraction of the memory mapping facilities available on Unix- and Windows-like operating systems. I suspect that your ELF loader does not have those portability requirements? Maybe using a Unix-specific lower level crate like nix or libc would be a better choice due to this?

adamreichold avatar Oct 31 '21 06:10 adamreichold

There's already flagged things like mremap which are under #[cfg(linux)], so adding MAP_FIXED under a flag seems like not that big of a stretch.

norcalli avatar Oct 04 '23 12:10 norcalli

@norcalli The are OS-specific stuff now, but not 2 years ago.

Either way, patches are welcome.

RazrFalcon avatar Oct 04 '23 13:10 RazrFalcon