diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-04-24 00:55:23 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-04-24 22:42:12 +0200 |
commit | 70b9173caa3a6e8e4cc1c8ebe93ed15a19388687 (patch) | |
tree | 99a5c9ff253c8e1c2f7d3a0e3a9c39b74711ef2d /sysdeps/mach/hurd/dl-sysdep.c | |
parent | 533deafbdf189f5fbb280c28562dd43ace2f4b0f (diff) | |
download | glibc-70b9173caa3a6e8e4cc1c8ebe93ed15a19388687.tar glibc-70b9173caa3a6e8e4cc1c8ebe93ed15a19388687.tar.gz glibc-70b9173caa3a6e8e4cc1c8ebe93ed15a19388687.tar.bz2 glibc-70b9173caa3a6e8e4cc1c8ebe93ed15a19388687.zip |
hurd: Implement MAP_32BIT
This is a flag that can be passed to mmap () to request that the mapping
being established should be located in the lower 2 GB area of the
address space, so only the lower 31 (not 32) bits can be set in its
address, and the address can be represented as a 32-bit integer without
truncating it.
This flag is intended to be compatible with Linux, FreeBSD, and Darwin
flags of the same name. Out of those systems, it appears Linux and
FreeBSD take MAP_32BIT to mean "map 31 bit", whereas Darwin allows the
32nd bit to be set in the address as well. The Hurd follows Linux and
FreeBSD behavior.
Unlike on those systems, on the Hurd MAP_32BIT is defined on all
supported architectures (which currently are only i386 and x86_64).
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423215526.346009-1-bugaevc@gmail.com>
Diffstat (limited to 'sysdeps/mach/hurd/dl-sysdep.c')
-rw-r--r-- | sysdeps/mach/hurd/dl-sysdep.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 6e167e12d8..d7b309e05d 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -451,7 +451,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) { error_t err; vm_prot_t vmprot; - vm_address_t mapaddr; + vm_address_t mapaddr, mask; mach_port_t memobj_rd, memobj_wr; vmprot = VM_PROT_NONE; @@ -462,6 +462,8 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) if (prot & PROT_EXEC) vmprot |= VM_PROT_EXECUTE; + mask = (flags & MAP_32BIT) ? ~(vm_address_t) 0x7FFFFFFF : 0; + if (flags & MAP_ANON) memobj_rd = MACH_PORT_NULL; else @@ -476,7 +478,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) mapaddr = (vm_address_t) addr; err = __vm_map (__mach_task_self (), - &mapaddr, (vm_size_t) len, 0, + &mapaddr, (vm_size_t) len, mask, !(flags & MAP_FIXED), memobj_rd, (vm_offset_t) offset, @@ -491,7 +493,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) if (! err) err = __vm_map (__mach_task_self (), &mapaddr, (vm_size_t) len, - 0, + mask, !(flags & MAP_FIXED), memobj_rd, (vm_offset_t) offset, flags & (MAP_COPY|MAP_PRIVATE), |