Hi all, does anyone have any context behind the comment here https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/app-mgr/app-manager/module_wasm_app.c#L1451? I'm not sure what relocation for R_X86_64_32/32S/PC32
refers to. Does this mean that it's unsafe to enable AOT on platforms where we cannot set the underlying MAP_32BIT
flag here https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/shared/platform/common/posix/posix_memmap.c#L72 ? Thanks in advance.
@Gary Hu For AOT, as the aot file loading is processed by runtime but not system dynamic loader (e.g. use dlopen to load .so file), runtime needs to allocate memory for aot code and aot data, and apply relocation for them, or patch/modify the aot code/data according to relocation records. And as the codegen is LLVM based, the relocation records are generated by LLVM, and there may be some special requirements. For relocation type R_X86_64_32/32S/PC32, it requires that destination address is 32-bit, and the target address may be an address pointing to some position aot code, so the aot code is should be in 32-bit range. As aot code is allocated by mmap, so we add MAP_32BIT flag for it.
The 32-bit relocation types are normally required by LLVM codegen size level 2 and 3, if you don't want to generate them, you can try generating the AOT file with size level 1: wamrc --size-level=1 -o <aot file> <wasm file>
. Thanks.
Last updated: Dec 23 2024 at 12:05 UTC