Refactor AOT loader to support compatible versions (#3891)

This commit refactors the AOT loader in `aot_loader.c` to support compatible
versions of the AOT_CURRENT_VERSION constant. Previously, the loader only
accepted the exact AOT_CURRENT_VERSION value, but now it also accepts
version 3. This change ensures that the runtime can load modules AoT-compiled
with different versions of wamrc as long as they have compatible
AOT_CURRENT_VERSION values.

Related to #3880.
This commit is contained in:
liang.he
2024-11-01 10:16:24 +08:00
committed by GitHub
parent c7b2683f17
commit e352f0ab10
2 changed files with 22 additions and 4 deletions

View File

@ -4236,6 +4236,16 @@ fail:
return false;
}
static bool
aot_compatible_version(uint32 version)
{
/*
* refer to "AoT-compiled module compatibility among WAMR versions" in
* ./doc/biuld_wasm_app.md
*/
return version == 4 || version == 3;
}
static bool
load(const uint8 *buf, uint32 size, AOTModule *module,
bool wasm_binary_freeable, bool no_resolve, char *error_buf,
@ -4254,7 +4264,7 @@ load(const uint8 *buf, uint32 size, AOTModule *module,
}
read_uint32(p, p_end, version);
if (version != AOT_CURRENT_VERSION) {
if (!aot_compatible_version(version)) {
set_error_buf(error_buf, error_buf_size, "unknown binary version");
return false;
}