aot loader: Call os_mmap with MMAP_MAP_32BIT only when target is x86-64 or riscv64 (#3755)
Mac on aarch64 uses posix_memmap.c os_mmap which doesn't do anything with the flag MMAP_MAP_32BIT for that build so this condition ends up asserting unless the mapping ends up in the first 4 gigs worth of addressable space. Thsi PR changes to call os_mmap with MMAP_MAP_32BIT flag only when the target is x86-64 or riscv64, and the macro __APPLE__ isn't enabled. The behavior is similar to what the posix os_mmap does.
This commit is contained in:
@ -302,7 +302,10 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
|
|||||||
int map_flags;
|
int map_flags;
|
||||||
void *mem;
|
void *mem;
|
||||||
|
|
||||||
#if UINTPTR_MAX == UINT64_MAX
|
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|
||||||
|
|| defined(BUILD_TARGET_RISCV64_LP64D) \
|
||||||
|
|| defined(BUILD_TARGET_RISCV64_LP64)
|
||||||
|
#ifndef __APPLE__
|
||||||
/* The mmapped AOT data and code in 64-bit targets had better be in
|
/* The mmapped AOT data and code in 64-bit targets had better be in
|
||||||
range 0 to 2G, or aot loader may fail to apply some relocations,
|
range 0 to 2G, or aot loader may fail to apply some relocations,
|
||||||
e.g., R_X86_64_32/R_X86_64_32S/R_X86_64_PC32/R_RISCV_32.
|
e.g., R_X86_64_32/R_X86_64_32S/R_X86_64_PC32/R_RISCV_32.
|
||||||
@ -316,6 +319,7 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
|
|||||||
bh_assert((uintptr_t)mem < INT32_MAX);
|
bh_assert((uintptr_t)mem < INT32_MAX);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
map_flags = MMAP_MAP_NONE;
|
map_flags = MMAP_MAP_NONE;
|
||||||
|
|||||||
Reference in New Issue
Block a user