mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-31 14:01:18 +08:00
hurd: Implement prefer_map_32bit_exec tunable
This makes the prefer_map_32bit_exec tunable no longer Linux-specific. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423215526.346009-4-bugaevc@gmail.com>
This commit is contained in:
parent
35b7bf2fe0
commit
c02b26455b
@ -462,6 +462,11 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
if (prot & PROT_EXEC)
|
||||
vmprot |= VM_PROT_EXECUTE;
|
||||
|
||||
#ifdef __LP64__
|
||||
if ((addr == NULL) && (prot & PROT_EXEC)
|
||||
&& HAS_ARCH_FEATURE (Prefer_MAP_32BIT_EXEC))
|
||||
flags |= MAP_32BIT;
|
||||
#endif
|
||||
mask = (flags & MAP_32BIT) ? ~(vm_address_t) 0x7FFFFFFF : 0;
|
||||
|
||||
if (flags & MAP_ANON)
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
#include <ldsodefs.h>
|
||||
#include <hurd.h>
|
||||
#include <hurd/fd.h>
|
||||
|
||||
@ -55,6 +56,11 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
|
||||
copy = ! (flags & MAP_SHARED);
|
||||
|
||||
#ifdef __LP64__
|
||||
if ((addr == NULL) && (prot & PROT_EXEC)
|
||||
&& HAS_ARCH_FEATURE (Prefer_MAP_32BIT_EXEC))
|
||||
flags |= MAP_32BIT;
|
||||
#endif
|
||||
mask = (flags & MAP_32BIT) ? ~(vm_address_t) 0x7FFFFFFF : 0;
|
||||
|
||||
switch (flags & MAP_TYPE)
|
||||
|
@ -1,25 +1,2 @@
|
||||
# The default ABI is 64.
|
||||
default-abi := 64
|
||||
|
||||
ifeq ($(subdir),elf)
|
||||
|
||||
tests-map-32bit = \
|
||||
tst-map-32bit-1a \
|
||||
tst-map-32bit-1b \
|
||||
# tests-map-32bit
|
||||
tst-map-32bit-1a-no-pie = yes
|
||||
tst-map-32bit-1b-no-pie = yes
|
||||
tests += $(tests-map-32bit)
|
||||
|
||||
modules-map-32bit = \
|
||||
tst-map-32bit-mod \
|
||||
# modules-map-32bit
|
||||
modules-names += $(modules-map-32bit)
|
||||
|
||||
$(objpfx)tst-map-32bit-mod.so: $(libsupport)
|
||||
tst-map-32bit-1a-ENV = LD_PREFER_MAP_32BIT_EXEC=1
|
||||
$(objpfx)tst-map-32bit-1a: $(objpfx)tst-map-32bit-mod.so
|
||||
tst-map-32bit-1b-ENV = GLIBC_TUNABLES=glibc.cpu.prefer_map_32bit_exec=1
|
||||
$(objpfx)tst-map-32bit-1b: $(objpfx)tst-map-32bit-mod.so
|
||||
|
||||
endif
|
||||
|
22
sysdeps/x86_64/64/Makefile
Normal file
22
sysdeps/x86_64/64/Makefile
Normal file
@ -0,0 +1,22 @@
|
||||
ifeq ($(subdir),elf)
|
||||
|
||||
tests-map-32bit = \
|
||||
tst-map-32bit-1a \
|
||||
tst-map-32bit-1b \
|
||||
# tests-map-32bit
|
||||
tst-map-32bit-1a-no-pie = yes
|
||||
tst-map-32bit-1b-no-pie = yes
|
||||
tests += $(tests-map-32bit)
|
||||
|
||||
modules-map-32bit = \
|
||||
tst-map-32bit-mod \
|
||||
# modules-map-32bit
|
||||
modules-names += $(modules-map-32bit)
|
||||
|
||||
$(objpfx)tst-map-32bit-mod.so: $(libsupport)
|
||||
tst-map-32bit-1a-ENV = LD_PREFER_MAP_32BIT_EXEC=1
|
||||
$(objpfx)tst-map-32bit-1a: $(objpfx)tst-map-32bit-mod.so
|
||||
tst-map-32bit-1b-ENV = GLIBC_TUNABLES=glibc.cpu.prefer_map_32bit_exec=1
|
||||
$(objpfx)tst-map-32bit-1b: $(objpfx)tst-map-32bit-mod.so
|
||||
|
||||
endif
|
Loading…
x
Reference in New Issue
Block a user