Skip to content

Commit 1138435

Browse files
authored
Fix mmap flags for AOT loader on non-Linux SGX platforms (#3890)
1 parent 95edef3 commit 1138435

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/iwasm/aot/aot_loader.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,13 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
304304
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
305305
|| defined(BUILD_TARGET_RISCV64_LP64D) \
306306
|| defined(BUILD_TARGET_RISCV64_LP64)
307-
#ifndef __APPLE__
307+
#if !defined(__APPLE__) && !defined(BH_PLATFORM_LINUX_SGX)
308308
/* The mmapped AOT data and code in 64-bit targets had better be in
309309
range 0 to 2G, or aot loader may fail to apply some relocations,
310310
e.g., R_X86_64_32/R_X86_64_32S/R_X86_64_PC32/R_RISCV_32.
311311
We try to mmap with MMAP_MAP_32BIT flag first, and if fails, mmap
312312
again without the flag. */
313+
/* sgx_tprotect_rsrv_mem() and sgx_alloc_rsrv_mem() will ignore flags */
313314
map_flags = MMAP_MAP_32BIT;
314315
if ((mem = os_mmap(NULL, size, map_prot, map_flags,
315316
os_get_invalid_handle()))) {

0 commit comments

Comments
 (0)