-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aarch64 AOT module fails to load on android #2274
Comments
Hi, could you try using |
Hi, thanks for the quick response. I get the following error when trying to compile with However, passing |
Yes, it is expected, I have a test, LLVM AArch64 does not support code model medium (i.e. --size-level=1) and code model kernel (i.e. --size-level=2). Code model large (i.e. --size-level=0) is supported. |
Sorry, I should have been more clear. I meant is it expected that the AOT module fails to load when |
Also, is there any way to estimate how much the size of the AOT file would increase (relatively) changing the |
Hi, I tested some cases, it seems the size increased is not very much (bytes):
You can also test these cases under |
Thanks, that's good to know. I'm still a bit concerned that the AOT module fails to load when |
It may be due to that diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c
index 480a00b9..84d73497 100644
--- a/core/iwasm/aot/aot_loader.c
+++ b/core/iwasm/aot/aot_loader.c
@@ -1475,11 +1475,7 @@ load_object_data_sections(const uint8 **p_buf, const uint8 *buf_end,
/* Create each data section */
for (i = 0; i < module->data_section_count; i++) {
int map_prot = MMAP_PROT_READ | MMAP_PROT_WRITE;
-#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
- || defined(BUILD_TARGET_RISCV64_LP64D) \
- || defined(BUILD_TARGET_RISCV64_LP64)
- /* aot code and data in x86_64 must be in range 0 to 2G due to
- relocation for R_X86_64_32/32S/PC32 */
+#if UINTPTR_MAX == UINT64_MAX
int map_flags = MMAP_MAP_32BIT;
#else
int map_flags = MMAP_MAP_NONE;
@@ -3021,11 +3017,7 @@ create_sections(AOTModule *module, const uint8 *buf, uint32 size,
if ((section_size > 0) && !module->is_indirect_mode) {
int map_prot =
MMAP_PROT_READ | MMAP_PROT_WRITE | MMAP_PROT_EXEC;
-#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
- || defined(BUILD_TARGET_RISCV64_LP64D) \
- || defined(BUILD_TARGET_RISCV64_LP64)
- /* aot code and data in x86_64 must be in range 0 to 2G due
- to relocation for R_X86_64_32/32S/PC32 */
+#if UINTPTR_MAX == UINT64_MAX
int map_flags = MMAP_MAP_32BIT;
#else
int map_flags = MMAP_MAP_NONE; |
I'm still getting the same error |
I run into this issue too. |
@zoraaver Would you do a test to see that fix your issue too? |
And enable merged os_mmap for aot data and text sections except on platform nuttx and esp-idf. Fix issue that aarch64 AOT module fails to load on android: #2274
Enable merged os_mmap for aot data sections first, and try enabling merged os_mmap for them and aot text except on platform nuttx and esp-idf. This fixes the issue that aarch64 AOT module fails to load on android: #2274 And also refine os_mmap related code.
@wenyongh i see the branch is mark as merged and my commit is totally lost in the final history should i fire another pr to merge the final change? |
@bianchui the code changes had been merged into main branch, but I chose the BTW, could you test this issue again? If it is fixed, maybe we can mark this issue as fixed and close it? |
@bianchui I merged branch |
@wenyongh fix this issue was the original reason for merging text and data and thank you for your reply and the merge |
Welcome. And let's close this issue as it is fixed. |
Glad to know that WAMR is tested in nearly 1million devices, it is cool! |
And enable merged os_mmap for aot data and text sections except on platform nuttx and esp-idf. Fix issue that aarch64 AOT module fails to load on android: bytecodealliance#2274
When trying to load an aarch64 AOT file on android, the module fails to load due to an overflow check failing,
AOT module load failed: target address out of range.
.Expected behaviour
aarch64 AOT module loads without error
Actual behaviour
aarch64 AOT module fails to load
Steps to reproduce
I've attached the example android studio project which reproduces the issue consistently on an arm64 emulator:
WasmAOT.zip
C++ code to load the AOT module:
This is the rust code for the AOT module:
which was compiled via
cargo build --target=wasm32-wasi
andThe same rust code, when compiled for armv7 loads without issue on an armv7 android build.
The text was updated successfully, but these errors were encountered: